@@ -30,8 +30,11 @@ public static void Create(INamedTypeSymbol symbol, SymbolKeyWriter visitor)
3030 break ;
3131 }
3232
33+ var isConstructed = ! symbol . Equals ( symbol . ConstructedFrom ) ;
3334 visitor . WriteInteger ( symbol . Arity ) ;
34- if ( ! symbol . Equals ( symbol . ConstructedFrom ) )
35+ visitor . WriteBoolean ( isConstructed ) ;
36+
37+ if ( isConstructed )
3538 {
3639 visitor . WriteSymbolKeyArray ( symbol . TypeArguments ) ;
3740 }
@@ -63,6 +66,7 @@ public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string fai
6366
6467 var containingSymbolResolution = ResolveContainer ( reader , out var containingSymbolFailureReason ) ;
6568 var arity = reader . ReadInteger ( ) ;
69+ var isConstructed = reader . ReadBoolean ( ) ;
6670
6771 using var typeArguments = reader . ReadSymbolKeyArray < ITypeSymbol > ( out var typeArgumentsFailureReason ) ;
6872
@@ -86,19 +90,17 @@ public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string fai
8690
8791 using var result = PooledArrayBuilder < INamedTypeSymbol > . GetInstance ( ) ;
8892
89- var typeArgumentsArray = arity > 0 ? typeArguments . Builder . ToArray ( ) : null ;
93+ var typeArgumentsArray = isConstructed ? typeArguments . Builder . ToArray ( ) : null ;
9094 foreach ( var container in containingSymbolResolution . OfType < INamespaceOrTypeSymbol > ( ) )
9195 {
92- result . AddIfNotNull ( Construct (
93- reader , container , name , arity , typeArgumentsArray ) ) ;
96+ var originalType = reader . Compilation . CreateErrorTypeSymbol ( container , name , arity ) ;
97+ var errorType = isConstructed ? originalType . Construct ( typeArgumentsArray ) : originalType ;
98+ result . AddIfNotNull ( errorType ) ;
9499 }
95100
96101 // Always ensure at least one error type was created.
97102 if ( result . Count == 0 )
98- {
99- result . AddIfNotNull ( Construct (
100- reader , container : null , name , arity , typeArgumentsArray ) ) ;
101- }
103+ result . AddIfNotNull ( reader . Compilation . CreateErrorTypeSymbol ( container : null , name , arity ) ) ;
102104
103105 return CreateResolution ( result , $ "({ nameof ( ErrorTypeSymbolKey ) } failed)", out failureReason ) ;
104106 }
@@ -131,12 +133,6 @@ private static SymbolKeyResolution ResolveContainer(SymbolKeyReader reader, out
131133
132134 throw ExceptionUtilities . UnexpectedValue ( type ) ;
133135 }
134-
135- private static INamedTypeSymbol Construct ( SymbolKeyReader reader , INamespaceOrTypeSymbol container , string name , int arity , ITypeSymbol [ ] typeArguments )
136- {
137- var result = reader . Compilation . CreateErrorTypeSymbol ( container , name , arity ) ;
138- return typeArguments != null ? result . Construct ( typeArguments ) : result ;
139- }
140136 }
141137 }
142138}
0 commit comments