Fix #74852.
* decl.cs (MemberCache.AddMethods): Register override methods,
rather than non-override methods.
* typemanager.cs (RegisterOverride): New.
(IsOverride): Update.
In tests:
* Makefile (test-harness-run): Depend on $(TEST_HARNESS_EXTRAS).
* harness.mk: Substitute the current profile into the compiler
options where the string 'PROFILE' is used.
* test-377.cs, test-377-default-il.il, test-377-net_2_0-il.il:
New tests from #74852.
svn path=/trunk/mcs/; revision=44270
+2005-05-09 Raja R Harinath <rharinath@novell.com>
+
+ Fix #74852.
+ * decl.cs (MemberCache.AddMethods): Register override methods,
+ rather than non-override methods.
+ * typemanager.cs (RegisterOverride): New.
+ (IsOverride): Update.
+
2005-05-09 Marek Safar <marek.safar@seznam.cz>
Fix #73105.
AddMethods (BindingFlags.Instance | BindingFlags.NonPublic, type);
}
+ static ArrayList overrides = new ArrayList ();
+
void AddMethods (BindingFlags bf, Type type)
{
MethodBase [] members = type.GetMethods (bf);
while (curr.IsVirtual && (curr.Attributes & MethodAttributes.NewSlot) == 0) {
MethodInfo base_method = curr.GetBaseDefinition ();
- if (base_method == curr) {
+ if (base_method == curr)
// Not every virtual function needs to have a NewSlot flag.
- TypeManager.RegisterNonOverride (base_method);
break;
- }
-
+
+ overrides.Add (curr);
list.Add (new CacheEntry (null, base_method, MemberTypes.Method, bf));
curr = base_method;
}
+ if (overrides.Count > 0) {
+ for (int i = 0; i < overrides.Count; ++i)
+ TypeManager.RegisterOverride ((MethodBase) overrides [i], curr);
+ overrides.Clear ();
+ }
+
// Unfortunately, the elements returned by Type.GetMethods() aren't
// sorted so we need to do this check for every member.
BindingFlags new_bf = bf;
static Hashtable method_params;
// <remarks>
- // It is not straightforward, using reflection, to determine if a method overrides another.
- // Oftentimes, a non-override is marked with both the 'virtual' and 'newslot' method attributes.
- // However, it's not always the case. We use this table to store those non-override methods
- // that aren't so conveniently marked.
+ // A hash table from override methods to their base virtual method.
// <remarks>
- static Hashtable method_non_override;
+ static Hashtable method_overrides;
// <remarks>
// Keeps track of methods
builder_to_method = new PtrHashtable ();
method_arguments = new PtrHashtable ();
method_params = new PtrHashtable ();
- method_non_override = new PtrHashtable ();
+ method_overrides = new PtrHashtable ();
indexer_arguments = new PtrHashtable ();
builder_to_ifaces = new PtrHashtable ();
return (ParameterData) pd;
}
- static public void RegisterNonOverride (MethodBase m)
+ static public void RegisterOverride (MethodBase override_method, MethodBase base_method)
{
- method_non_override [m] = m;
+ 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;
}
static public bool IsOverride (MethodBase m)
{
return m.IsVirtual &&
(m.Attributes & MethodAttributes.NewSlot) == 0 &&
- !method_non_override.Contains (m);
+ (m is MethodBuilder || method_overrides.Contains (m));
}
/// <summary>
+2005-05-09 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (test-harness-run): Depend on $(TEST_HARNESS_EXTRAS).
+ * harness.mk: Substitute the current profile into the compiler
+ options where the string 'PROFILE' is used.
+ * test-377.cs, test-377-default-il.il, test-377-net_2_0-il.il:
+ New tests from #74852.
+
2005-05-06 Marek Safar <marek.safar@seznam.cz>
* test-376.cs: New enum test.
# means we can use --options, yay.
MCS = $(with_mono_path) $(INTERNAL_MCS)
endif
-ILASM = $(with_mono_path) $(INTERNAL_ILASM)
+ilasm = $(topdir)/class/lib/net_1_1_bootstrap/ilasm.exe
+ILASM = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(ilasm)
ifeq (net_2_0, $(PROFILE))
BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/net_2_0_bootstrap/mcs.exe
# 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 \
- test-372 test-375 test-376
+ test-372 test-375 test-376 test-377
#
# Please do _not_ add any tests here - all new tests should go into NEW_TEST_SOURCES_common
# Some tests may require additional files to be available in the current directory.
# To promote interoperability, we prefer that those files not be referred to with ../ or ..\\
# To that end, we will copy those files to the test-harness directory, so that we can refer to simple filenames.
-TEST_HARNESS_EXTRAS = $(wildcard *.inc) test-74.cs test-353-2.cs test-361-2.cs
+TEST_HARNESS_EXTRAS = $(wildcard *.inc) test-74.cs test-353-2.cs test-361-2.cs test-377-$(PROFILE)-il.dll
all-local install-local uninstall-local:
clean-local:
-rm -fr dir-*
- -rm -f *.exe *.netmodule *.out *.pdb casts.cs
+ -rm -f *.exe *.dll *.netmodule *.out *.pdb casts.cs
dist-local: dist-default
rm -f $(distdir)/casts.cs
exe_tests := $(filter %-exe, $(TEST_SOURCES))
-test-harness-run:
+test-harness-run: $(TEST_HARNESS_EXTRAS)
@-rm -f $(TEST_TAG).log
@-rm -fr dir-$(TEST_TAG)
@mkdir dir-$(TEST_TAG)
xmldocdiff.exe:
$(CSCOMPILE) xmldocdiff.cs
+
+%-il.dll: %-il.il
+ $(ILASM) /dll $<
all-local $(STD_TARGETS:=-local):
%.res:
- @f=../$*.cs; options=`sed -n 's,^// Compiler options:,,p' $$f`; \
+ @f=../$*.cs; options=`sed -n 's,^// Compiler options:,,p' $$f | sed 's,PROFILE,$(PROFILE),g'`; \
case $$options in *-t:library*) ext=dll ;; *-t:module*) ext=netmodule ;; *) ext=exe ;; esac; \
testlogfile="$*.log" ; \
echo '*** $(CSCOMPILE)' "$$options -out:$*.$$ext $$f" > $$testlogfile ; \
--- /dev/null
+.assembly extern mscorlib
+{
+ .ver 1:0:5000:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'test-377-default-il'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'test-377-default-il.dll' // GUID = {F4E03A1B-389D-4487-83FD-FFA830293B9D}
+
+
+ .class interface public auto ansi abstract beforefieldinit Foo
+ extends [mscorlib]System.Object
+ {
+ // method line 2
+ .method public virtual abstract
+ instance default void foo (int32) cil managed
+ {
+ // Method begins at RVA 0x0
+ } // end of method Foo::instance default void foo ()
+
+ } // end of class Foo
+
+
--- /dev/null
+.assembly extern mscorlib
+{
+ .ver 2:0:3600:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'test-377-net_2_0-il'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module 'test-377-net_2_0-il.dll' // GUID = {F4E03A1B-389D-4487-83FD-FFA830293B9D}
+
+
+ .class interface public auto ansi abstract beforefieldinit Foo
+ extends [mscorlib]System.Object
+ {
+ // method line 2
+ .method public virtual abstract
+ instance default void foo (int32) cil managed
+ {
+ // Method begins at RVA 0x0
+ } // end of method Foo::instance default void foo ()
+
+ } // end of class Foo
+
+
--- /dev/null
+// Compiler options: -t:library -r:test-377-PROFILE-il.dll
+
+using System;
+using System.Reflection;
+
+public class Tests {
+
+ public void test () {
+ Foo f = null;
+ f.foo (5);
+ }
+}