[svn] r6175: nemerle/trunk/ncc: hierarchy/TypeBuilder.n
testsuite/negative/implements.n
nazgul
svnadmin at nemerle.org
Thu Apr 6 19:45:52 CEST 2006
Log:
Do not consider static methods as good candidates for wrapper interface implementation
Author: nazgul
Date: Thu Apr 6 19:45:27 2006
New Revision: 6175
Modified:
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
nemerle/trunk/ncc/testsuite/negative/implements.n
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Thu Apr 6 19:45:27 2006
@@ -2044,6 +2044,26 @@
} else false
}
+ def partition_correct_meth (ifmethods, proposed_meth, scream) {
+ def is_correct (iface_meth : IMethod) {
+ // Message.Debug ( $ "try req: $proposed_meth req $iface_meth --- "
+ // "$(proposed_meth.GetMemType ()) req "
+ // "$(GetMemType ().TypeOfMethod (iface_meth))");
+ if (method_type_ok (iface_meth, proposed_meth))
+ if (proposed_meth.Attributes %&& NemerleAttributes.Public &&
+ !(proposed_meth.Attributes %&& NemerleAttributes.Static))
+ true
+ else {
+ when (scream)
+ Message.Error (proposed_meth.Location, "method implementing interface"
+ " member must be public and nonstatic");
+ false
+ }
+ else false
+ };
+ List.Partition (ifmethods, is_correct)
+ }
+
foreach (tc : TypeInfo in InterfacesToImplement ()) {
// Message.Debug ($ "in $this, $tc .GetMembers == $(tc.GetMembers (BindingFlags.DeclaredOnly %| BindingFlags.Public %| BindingFlags.Instance))");
foreach (m : IMember in tc.GetMembers (BindingFlags.DeclaredOnly %|
@@ -2127,28 +2147,13 @@
def lookup_iface_members () {
match (iface_methods.Get (meth.Name)) {
| Some (meths) =>
- def is_correct (iface_meth : IMethod) {
- // Message.Debug ( $ "try req: $meth req $iface_meth --- "
- // "$(meth.GetMemType ()) req "
- // "$(GetMemType ().TypeOfMethod (iface_meth))");
- if (method_type_ok (iface_meth, meth))
- if (meth.Attributes %&& NemerleAttributes.Public &&
- !(meth.Attributes %&& NemerleAttributes.Static))
- true
- else {
- Message.Error (meth.Location, "method implementing interface"
- " member must be public and nonstatic");
- false
- }
- else false
- };
- match (List.Partition (meths, is_correct)) {
+ match (partition_correct_meth (meths, meth, true)) {
| (lst, notcorrect) =>
iface_methods.Set (meth.Name, notcorrect);
def already =
if (already_bound.Contains (meth.Name)) {
def lst = already_bound [meth.Name] : list [IMethod];
- def additional = lst.Filter (is_correct);
+ def (additional, _) = partition_correct_meth (lst, meth, false);
unless (additional.IsEmpty)
Message.Error (meth.Location,
$ "ambiguous implements-match for "
@@ -2201,19 +2206,14 @@
// choose only methods from within possible implementors
foreach (meth is IMethod in possible_impls) {
- def is_correct (iface_meth : IMethod)
- {
- meth.Attributes %&& NemerleAttributes.Public &&
- method_type_ok (iface_meth, meth)
- };
-
- match (List.Partition (meths, is_correct)) {
+ match (partition_correct_meth (meths, meth, false)) {
| ([], _) => ()
| (correct, notcorrect) =>
meths = notcorrect;
// create a wrapper in the current type
def meth_header = meth.GetHeader ();
+ //Message.Debug ("additional " + meth_header.name);
def meth_parms = List.Map (meth_header.parms, fun (fp : Fun_parm) {
<[ parameter : $(fp.name : usesite) : $(fp.ty : typed) ]>
Modified: nemerle/trunk/ncc/testsuite/negative/implements.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/implements.n (original)
+++ nemerle/trunk/ncc/testsuite/negative/implements.n Thu Apr 6 19:45:27 2006
@@ -107,3 +107,10 @@
public variant V { | X | Y }
public variant V2 : V { | A | B } // E: cannot use variant as base type
+
+
+class Bug648 : System.Collections.Generic.IEqualityComparer [int] { // E: unimplemented interface method System.Collections.Generic.IEqualityComparer.Equals
+ public GetHashCode(_ : int) : int {
+ 2
+ }
+}
\ No newline at end of file
More information about the svn
mailing list