File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ public override void Populate(TextWriter trapFile)
2929 return ;
3030 }
3131
32- trapFile . typeref_type ( ( NamedTypeRef ) TypeRef , this ) ;
32+ if ( UsesTypeRef )
33+ trapFile . typeref_type ( ( NamedTypeRef ) TypeRef , this ) ;
3334
3435 if ( symbol . IsGenericType )
3536 {
@@ -148,7 +149,14 @@ class NamedTypeFactory : ICachedEntityFactory<INamedTypeSymbol, NamedType>
148149 public NamedType Create ( Context cx , INamedTypeSymbol init ) => new NamedType ( cx , init ) ;
149150 }
150151
151- public override Type TypeRef => NamedTypeRef . Create ( Context , symbol ) ;
152+ // Do not create typerefs of constructed generics as they are always in the current trap file, and there is a possibility
153+ // that a generic could make the typedef ambiguous which leads to performance problems in QL.
154+ // Create typerefs for constructed error types in case they are fully defined elsewhere.
155+ // We cannot use `!this.NeedsPopulation` because this would not be stable as it would depend on
156+ // the assembly that was being extracted at the time.
157+ bool UsesTypeRef => symbol . TypeKind == TypeKind . Error || SymbolEqualityComparer . Default . Equals ( symbol . OriginalDefinition , symbol ) ;
158+
159+ public override Type TypeRef => UsesTypeRef ? ( Type ) NamedTypeRef . Create ( Context , symbol ) : this ;
152160 }
153161
154162 class NamedTypeRef : Type < INamedTypeSymbol >
You can’t perform that action at this time.
0 commit comments