Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin.baulig@xamarin.com>2013-10-26 01:56:59 +0400
committerMartin Baulig <martin.baulig@xamarin.com>2013-10-26 02:03:49 +0400
commitb31c9486e3dddb70cc877962a51e3bbe476c42eb (patch)
treeb355fd15df8229b858972d2e524454681d081c56
parentc29ac46c408aa2ae588548fa36a0aa9bf0b01014 (diff)
[linker]: Fix my previous commit.
We need to resolve all the TypeReferences before we update their scopes. After setting the scope to null, calling Resolve() on a nested child would crash.
-rw-r--r--mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
index 20f06f3bb58..552693546be 100644
--- a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
+++ b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
@@ -128,10 +128,23 @@ namespace Mono.Linker.Steps {
return;
resolvedTypeReferences.Add (assembly);
+ var hash = new Dictionary<TypeReference,IMetadataScope> ();
+
foreach (TypeReference tr in assembly.MainModule.GetTypeReferences ()) {
+ if (hash.ContainsKey (tr))
+ continue;
var td = tr.Resolve ();
// at this stage reference might include things that can't be resolved
- tr.Scope = td == null ? null : assembly.MainModule.Import (td).Scope;
+ var scope = td == null ? null : assembly.MainModule.Import (td).Scope;
+ hash.Add (tr, scope);
+ }
+
+ // Resolve everything first before updating scopes.
+ // If we set the scope to null, then calling Resolve() on any of its
+ // nested types would crash.
+
+ foreach (var e in hash) {
+ e.Key.Scope = e.Value;
}
}