Author: raja
Date: 2005-05-03 07:32:22 -0400 (Tue, 03 May 2005)
New Revision: 43920
Added:
trunk/mcs/tests/test-372.cs
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/pending.cs
trunk/mcs/tests/ChangeLog
trunk/mcs/tests/Makefile
Log:
Fix #74773.
* mcs/pending.cs (VerifyPendingMethods): If a base type implements the
requested interface, don't bother checking individual methods of
the base type. As a side-effect, this prevents the creation of
unnecessary proxies.
* tests/test-372.cs: New test from #74773.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-05-03 11:09:31 UTC (rev 43919)
+++ trunk/mcs/mcs/ChangeLog 2005-05-03 11:32:22 UTC (rev 43920)
@@ -1,3 +1,11 @@
+2005-05-03 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #74773.
+ * pending.cs (VerifyPendingMethods): If a base type implements the
+ requested interface, don't bother checking individual methods of
+ the base type. As a side-effect, this prevents the creation of
+ unnecessary proxies.
+
2005-05-02 Martin Baulig <[EMAIL PROTECTED]>
Fix #70182.
Modified: trunk/mcs/mcs/pending.cs
===================================================================
--- trunk/mcs/mcs/pending.cs 2005-05-03 11:09:31 UTC (rev 43919)
+++ trunk/mcs/mcs/pending.cs 2005-05-03 11:32:22 UTC (rev 43920)
@@ -526,6 +526,14 @@
return false;
MethodInfo base_method = (MethodInfo) list [0];
+
+ //
+ // FIXME: We shouldn't be creating proxies
unconditionally.
+ // The runtime can handle most cases.
+ //
+ // At worst, if we can't avoid creating the
proxy, we
+ // may need to make the proxy use Callvirt.
+ //
if (!base_method.IsAbstract)
DefineProxy (iface_type, base_method, mi, args);
return true;
@@ -545,6 +553,10 @@
Type type = pending_implementations [i].type;
int j = 0;
+ bool base_implements_type = type.IsInterface &&
+ container.TypeBuilder.BaseType != null
&&
+ TypeManager.ImplementsInterface
(container.TypeBuilder.BaseType, type);
+
foreach (MethodInfo mi in
pending_implementations [i].methods){
if (mi == null)
continue;
@@ -559,7 +571,7 @@
continue;
}
- if (BaseImplements (type, mi))
+ if (base_implements_type ||
BaseImplements (type, mi))
continue;
if (pending_implementations
[i].optional)
Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog 2005-05-03 11:09:31 UTC (rev 43919)
+++ trunk/mcs/tests/ChangeLog 2005-05-03 11:32:22 UTC (rev 43920)
@@ -1,3 +1,7 @@
+2005-05-03 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * test-372.cs: New test from #74773.
+
2005-05-02 Raja R Harinath <[EMAIL PROTECTED]>
* Makefile (BOOTSTRAP_MCS): Fix.
Modified: trunk/mcs/tests/Makefile
===================================================================
--- trunk/mcs/tests/Makefile 2005-05-03 11:09:31 UTC (rev 43919)
+++ trunk/mcs/tests/Makefile 2005-05-03 11:32:22 UTC (rev 43920)
@@ -32,7 +32,8 @@
# Martin Baulig will manually move them into TEST_SOURCES_common after merging
the code into GMCS.
# He may also move some to TEST_EXCLUDE_net_2_0 if some of the merges are
inappropriate for GMCS.
#
-NEW_TEST_SOURCES_common = test-336 test-369 cls-test-6 test-294
+NEW_TEST_SOURCES_common = test-336 test-369 cls-test-6 test-294 \
+ test-372
#
# Please do _not_ add any tests here - all new tests should go into
NEW_TEST_SOURCES_common
Added: trunk/mcs/tests/test-372.cs
===================================================================
--- trunk/mcs/tests/test-372.cs 2005-05-03 11:09:31 UTC (rev 43919)
+++ trunk/mcs/tests/test-372.cs 2005-05-03 11:32:22 UTC (rev 43920)
@@ -0,0 +1,63 @@
+// Some interfaces, one is a superset of the other
+public interface Node
+{
+ int GetStat();
+}
+public interface FileNode : Node
+{
+ int NotUsed();
+}
+
+// Some basic implementations, one is a superset of the other
+public class GenericNode : Node
+{
+ public virtual int GetStat() { return 0; }
+}
+
+public class GenericFileNode : GenericNode , FileNode
+{
+ public virtual int NotUsed() { return -1; }
+}
+
+
+// Now the ability to override a method depends on if we specify again that we
+// implement an interface -- although we must because we derive from a class
+// that does.
+public class WorkingTest : GenericFileNode , FileNode
+{
+ public override int GetStat() { return 42; }
+}
+
+public class FailingTest : GenericFileNode
+{
+ // This never gets called, but it builds, so what did we override?!!!
+ public override int GetStat() { return 42; }
+}
+
+public class TestWrapper
+{
+ static bool Test(Node inst, string name)
+ {
+ if(inst.GetStat() == 42)
+ {
+ System.Console.WriteLine("{0} -- Passed", name);
+ return true;
+ } else
+ {
+ System.Console.WriteLine("{0} -- FAILED", name);
+ return false;
+ }
+ }
+
+ public static int Main()
+ {
+ if( Test(new WorkingTest(), "WorkingTest")
+ && Test(new FailingTest(), "FailingTest") )
+ return 0; // everything worked
+ else
+ return 1;
+ }
+}
+
+
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches