Author: raja
Date: 2006-01-09 10:21:07 -0500 (Mon, 09 Jan 2006)
New Revision: 55226
Added:
trunk/mcs/tests/test-483-lib.il
trunk/mcs/tests/test-483.cs
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/expression.cs
trunk/mcs/gmcs/typemanager.cs
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/typemanager.cs
trunk/mcs/tests/ChangeLog
trunk/mcs/tests/Makefile
trunk/mcs/tests/known-issues-gmcs
Log:
Fix #75636.
* mcs/expression.cs (Invocation.OverloadResolve): Replace reflected
override methods with their base virtual methods, rather than
skipping over them.
* gmcs/expression.cs: Likewise.
* mcs/typemanager.cs (TypeManager.GetOverride): New.
* gmcs/typemanager.cs: Likewise.
* tests/Makefile (TEST_ILS): New list of CIL test libraries.
* tests/test-483-lib.il, tests/test-483.cs: New test from #75636.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/gmcs/ChangeLog 2006-01-09 15:21:07 UTC (rev 55226)
@@ -1,3 +1,11 @@
+2006-01-09 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #75636.
+ * expression.cs (Invocation.OverloadResolve): Replace reflected
+ override methods with their base virtual methods, rather than
+ skipping over them.
+ * typemanager.cs (TypeManager.GetOverride): New.
+
2005-12-21 Miguel de Icaza <[EMAIL PROTECTED]>
* driver.cs: Report the case of no source files and no -out:
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/gmcs/expression.cs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -4681,45 +4681,55 @@
MethodBase[] methods = me.Methods;
+ int nmethods = methods.Length;
+
+ if (!me.IsBase) {
+ //
+ // Methods marked 'override' don't take part in
'applicable_type'
+ // computation, nor in the actual overload
resolution.
+ // However, they still need to be emitted
instead of a base virtual method.
+ // So, we salt them away into the
'candidate_overrides' array.
+ //
+ // In case of reflected methods, we replace
each overriding method with
+ // its corresponding base virtual method. This
is to improve compatibility
+ // with non-C# libraries which change the
visibility of overrides (#75636)
+ //
+ int j = 0;
+ for (int i = 0; i < methods.Length; ++i) {
+ MethodBase m = methods [i];
+ if (TypeManager.IsOverride (m)) {
+ if (candidate_overrides == null)
+ candidate_overrides =
new ArrayList ();
+ candidate_overrides.Add (m);
+ m = TypeManager.GetOverride (m);
+ }
+ if (m != null)
+ methods [j++] = m;
+ }
+ nmethods = j;
+ }
+
//
// First we construct the set of applicable methods
//
bool is_sorted = true;
- for (int i = 0; i < methods.Length; i++){
+ for (int i = 0; i < nmethods; i++){
Type decl_type = methods [i].DeclaringType;
//
// If we have already found an applicable method
// we eliminate all base types (Section
14.5.5.1)
//
- if ((applicable_type != null) &&
- IsAncestralType (decl_type,
applicable_type))
+ if (applicable_type != null && IsAncestralType
(decl_type, applicable_type))
continue;
//
- // Methods marked 'override' don't take part in
'applicable_type'
- // computation, nor in the actual overload
resolution.
- // However, they still need to be emitted
instead of a base virtual method.
- // We avoid doing the 'applicable' test here,
since it'll anyway be applied
- // to the base virtual function, and IsOverride
is much faster than IsApplicable.
- //
- if (!me.IsBase && TypeManager.IsOverride
(methods [i])) {
- if (candidate_overrides == null)
- candidate_overrides = new
ArrayList ();
- candidate_overrides.Add (methods [i]);
- continue;
- }
-
- //
// Check if candidate is applicable (section
14.4.2.1)
// Is candidate applicable in normal form?
//
- bool is_applicable = IsApplicable (
- ec, me, Arguments, arg_count, ref
methods [i]);
+ bool is_applicable = IsApplicable (ec, me,
Arguments, arg_count, ref methods [i]);
- if (!is_applicable &&
- (IsParamsMethodApplicable (
- ec, me, Arguments, arg_count, ref
methods [i]))) {
+ if (!is_applicable && IsParamsMethodApplicable
(ec, me, Arguments, arg_count, ref methods [i])) {
MethodBase candidate = methods [i];
if (candidate_to_form == null)
candidate_to_form = new
PtrHashtable ();
@@ -4750,7 +4760,7 @@
// return by providing info about the closest
match
//
int errors = Report.Errors;
- for (int i = 0; i < methods.Length; ++i) {
+ for (int i = 0; i < nmethods; ++i) {
MethodBase c = (MethodBase) methods [i];
ParameterData pd =
TypeManager.GetParameterData (c);
Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/gmcs/typemanager.cs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -1774,12 +1774,10 @@
static public void RegisterOverride (MethodBase override_method,
MethodBase base_method)
{
- if (method_overrides.Contains (override_method)) {
- if (method_overrides [override_method] != base_method)
- throw new InternalErrorException ("Override
mismatch: " + override_method);
- return;
- }
- method_overrides [override_method] = base_method;
+ if (!method_overrides.Contains (override_method))
+ method_overrides [override_method] = base_method;
+ if (method_overrides [override_method] != base_method)
+ throw new InternalErrorException ("Override mismatch: "
+ override_method);
}
static public bool IsOverride (MethodBase m)
@@ -1789,6 +1787,11 @@
(m is MethodBuilder || method_overrides.Contains (m));
}
+ static public MethodBase GetOverride (MethodBase m)
+ {
+ return (MethodBase) method_overrides [m];
+ }
+
/// <summary>
/// Returns the argument types for an indexer based on its
PropertyInfo
///
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/mcs/ChangeLog 2006-01-09 15:21:07 UTC (rev 55226)
@@ -1,3 +1,11 @@
+2006-01-09 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #75636.
+ * expression.cs (Invocation.OverloadResolve): Replace reflected
+ override methods with their base virtual methods, rather than
+ skipping over them.
+ * typemanager.cs (TypeManager.GetOverride): New.
+
2006-01-05 Jb Evain <[EMAIL PROTECTED]>
* class.cs (Property.Define, Indexer.Define): do not tag the
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/mcs/expression.cs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -4559,45 +4559,55 @@
MethodBase[] methods = me.Methods;
+ int nmethods = methods.Length;
+
+ if (!me.IsBase) {
+ //
+ // Methods marked 'override' don't take part in
'applicable_type'
+ // computation, nor in the actual overload
resolution.
+ // However, they still need to be emitted
instead of a base virtual method.
+ // So, we salt them away into the
'candidate_overrides' array.
+ //
+ // In case of reflected methods, we replace
each overriding method with
+ // its corresponding base virtual method. This
is to improve compatibility
+ // with non-C# libraries which change the
visibility of overrides (#75636)
+ //
+ int j = 0;
+ for (int i = 0; i < methods.Length; ++i) {
+ MethodBase m = methods [i];
+ if (TypeManager.IsOverride (m)) {
+ if (candidate_overrides == null)
+ candidate_overrides =
new ArrayList ();
+ candidate_overrides.Add (m);
+ m = TypeManager.GetOverride (m);
+ }
+ if (m != null)
+ methods [j++] = m;
+ }
+ nmethods = j;
+ }
+
//
// First we construct the set of applicable methods
//
bool is_sorted = true;
- for (int i = 0; i < methods.Length; i++){
+ for (int i = 0; i < nmethods; i++){
Type decl_type = methods [i].DeclaringType;
//
// If we have already found an applicable method
// we eliminate all base types (Section
14.5.5.1)
//
- if ((applicable_type != null) &&
- IsAncestralType (decl_type,
applicable_type))
+ if (applicable_type != null && IsAncestralType
(decl_type, applicable_type))
continue;
//
- // Methods marked 'override' don't take part in
'applicable_type'
- // computation, nor in the actual overload
resolution.
- // However, they still need to be emitted
instead of a base virtual method.
- // We avoid doing the 'applicable' test here,
since it'll anyway be applied
- // to the base virtual function, and IsOverride
is much faster than IsApplicable.
- //
- if (!me.IsBase && TypeManager.IsOverride
(methods [i])) {
- if (candidate_overrides == null)
- candidate_overrides = new
ArrayList ();
- candidate_overrides.Add (methods [i]);
- continue;
- }
-
- //
// Check if candidate is applicable (section
14.4.2.1)
// Is candidate applicable in normal form?
//
- bool is_applicable = IsApplicable (
- ec, Arguments, arg_count, methods [i]);
+ bool is_applicable = IsApplicable (ec,
Arguments, arg_count, methods [i]);
- if (!is_applicable &&
- (IsParamsMethodApplicable (
- ec, Arguments, arg_count, methods
[i]))) {
+ if (!is_applicable && IsParamsMethodApplicable
(ec, Arguments, arg_count, methods [i])) {
MethodBase candidate = methods [i];
if (candidate_to_form == null)
candidate_to_form = new
PtrHashtable ();
@@ -4628,7 +4638,7 @@
// return by providing info about the closest
match
//
int errors = Report.Errors;
- for (int i = 0; i < methods.Length; ++i) {
+ for (int i = 0; i < nmethods; ++i) {
MethodBase c = (MethodBase) methods [i];
ParameterData pd =
TypeManager.GetParameterData (c);
Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/mcs/typemanager.cs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -1489,12 +1489,10 @@
static public void RegisterOverride (MethodBase override_method,
MethodBase base_method)
{
- if (method_overrides.Contains (override_method)) {
- if (method_overrides [override_method] != base_method)
- throw new InternalErrorException ("Override
mismatch: " + override_method);
- return;
- }
- method_overrides [override_method] = base_method;
+ if (!method_overrides.Contains (override_method))
+ method_overrides [override_method] = base_method;
+ if (method_overrides [override_method] != base_method)
+ throw new InternalErrorException ("Override mismatch: "
+ override_method);
}
static public bool IsOverride (MethodBase m)
@@ -1504,6 +1502,11 @@
(m is MethodBuilder || method_overrides.Contains (m));
}
+ static public MethodBase GetOverride (MethodBase m)
+ {
+ return (MethodBase) method_overrides [m];
+ }
+
/// <summary>
/// Returns the argument types for an indexer based on its
PropertyInfo
///
Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/tests/ChangeLog 2006-01-09 15:21:07 UTC (rev 55226)
@@ -1,3 +1,8 @@
+2006-01-09 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * Makefile (TEST_ILS): New list of CIL test libraries.
+ * test-483-lib.il, test-483.cs: New test from #75636.
+
2005-12-21 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* gtest-friend-00-lib.cs: Include the public key in
Modified: trunk/mcs/tests/Makefile
===================================================================
--- trunk/mcs/tests/Makefile 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/tests/Makefile 2006-01-09 15:21:07 UTC (rev 55226)
@@ -61,7 +61,9 @@
TEST_PATTERN = 'test-*.cs'
endif
-run-test-local: test-377-lib.dll test-443-lib.dll
+TEST_ILS := $(wildcard *-lib.il)
+
+run-test-local: $(TEST_ILS:.il=.dll)
MONO_RUNTIME='$(RUNTIME)' $(TEST_RUNTIME) $(RUNTIME_FLAGS)
$(topdir)/class/lib/$(PROFILE)/compiler-tester.exe positive $(TEST_PATTERN)
$(COMPILER) known-issues-$(COMPILER_NAME) $(COMPILER_NAME).log
# do nothing for this target
Modified: trunk/mcs/tests/known-issues-gmcs
===================================================================
--- trunk/mcs/tests/known-issues-gmcs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/tests/known-issues-gmcs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -4,7 +4,6 @@
# csXXXX.cs : test case causes error
# csXXXX.cs IGNORE : adds test to ignore list
-test-442.cs IGNORE # Causes runtime to crash
test-50.cs IGNORE # Windows-only test
test-67.cs IGNORE # Windows-only test
test-anon-27.cs
Added: trunk/mcs/tests/test-483-lib.il
===================================================================
--- trunk/mcs/tests/test-483-lib.il 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/tests/test-483-lib.il 2006-01-09 15:21:07 UTC (rev 55226)
@@ -0,0 +1,24 @@
+.assembly 'test-483-lib' {}
+.assembly extern mscorlib {}
+
+.class public auto ansi beforefieldinit Foo {
+
+ .method famorassem virtual newslot
+ instance default object clone () cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ ret
+ }
+}
+
+.class public auto ansi Bar extends Foo {
+
+ .method public virtual
+ instance default object clone () cil managed
+ {
+ .maxstack 8
+ ldarg.0
+ ret
+ }
+}
Added: trunk/mcs/tests/test-483.cs
===================================================================
--- trunk/mcs/tests/test-483.cs 2006-01-09 15:13:01 UTC (rev 55225)
+++ trunk/mcs/tests/test-483.cs 2006-01-09 15:21:07 UTC (rev 55226)
@@ -0,0 +1,11 @@
+// Compiler options: -r:test-483-lib.dll
+
+using System;
+
+public class Tests {
+
+ public static void Main () {
+ Bar bar = null;
+ try { bar.clone (); } catch (NullReferenceException) {}
+ }
+}
Property changes on: trunk/mcs/tests/test-483.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches