Skip to content

Commit

Permalink
Do system.object type scan after all references are loaded. Fixes #12991
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Jul 2, 2013
1 parent f35b71e commit 6769392
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
24 changes: 18 additions & 6 deletions mcs/mcs/assembly.cs
Expand Up @@ -1179,15 +1179,27 @@ protected void LoadReferencesCore (ModuleContainer module, out T corlib_assembly
if (loaded.Contains (key))
continue;

// A corlib assembly is the first assembly which contains System.Object
if (corlib_assembly == null && HasObjectType (a)) {
corlib_assembly = a;
continue;
}

loaded.Add (key);
}

if (corlib_assembly == null) {
//
// Requires second pass because HasObjectType can trigger assembly load event
//
for (int i = 0; i < loaded.Count; ++i) {
var assembly = loaded [i];

//
// corlib assembly is the first referenced assembly which contains System.Object
//
if (HasObjectType (assembly.Item2)) {
corlib_assembly = assembly.Item2;
loaded.RemoveAt (i);
break;
}
}
}

foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
a = LoadAssemblyFile (entry.Item2, false);
if (a == null)
Expand Down
21 changes: 14 additions & 7 deletions mcs/mcs/typemanager.cs
Expand Up @@ -835,15 +835,22 @@ public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string
}

if (best_match == null && reportErrors) {
Location loc;
if (found[0].MemberDefinition is MemberCore) {
loc = ((MemberCore) found[0].MemberDefinition).Location;
var found_member = found[0];

if (found_member.Kind == MemberKind.MissingType) {
// CSC: should be different error number
module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is defined in an assembly that is not referenced.", ns, name);
} else {
loc = Location.Null;
module.Compiler.Report.SymbolRelatedToPreviousError (found[0]);
}
Location loc;
if (found_member.MemberDefinition is MemberCore) {
loc = ((MemberCore) found_member.MemberDefinition).Location;
} else {
loc = Location.Null;
module.Compiler.Report.SymbolRelatedToPreviousError (found_member);
}

module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name);
module.Compiler.Report.Error (520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name);
}
}

return best_match;
Expand Down

0 comments on commit 6769392

Please sign in to comment.