From b31c9486e3dddb70cc877962a51e3bbe476c42eb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 25 Oct 2013 23:56:59 +0200 Subject: [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. --- mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 (); + 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; } } -- cgit v1.2.3