File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,9 @@ private class UnderlyingTupleTypeFactory : CachedEntityFactory<INamedTypeSymbol,
166
166
// Create typerefs for constructed error types in case they are fully defined elsewhere.
167
167
// We cannot use `!this.NeedsPopulation` because this would not be stable as it would depend on
168
168
// the assembly that was being extracted at the time.
169
- private bool UsesTypeRef => Symbol . TypeKind == TypeKind . Error || SymbolEqualityComparer . Default . Equals ( Symbol . OriginalDefinition , Symbol ) ;
169
+ private bool UsesTypeRef =>
170
+ Symbol . TypeKind == TypeKind . Error ||
171
+ SymbolEqualityComparer . Default . Equals ( Symbol . OriginalDefinition , Symbol ) ;
170
172
171
173
public override Type TypeRef => UsesTypeRef ? ( Type ) NamedTypeRef . Create ( Context , Symbol ) : this ;
172
174
}
Original file line number Diff line number Diff line change @@ -25,6 +25,22 @@ public static bool ConstructedOrParentIsConstructed(INamedTypeSymbol symbol)
25
25
symbol . ContainingType is not null && ConstructedOrParentIsConstructed ( symbol . ContainingType ) ;
26
26
}
27
27
28
+ /// <summary>
29
+ /// Returns true in case we suspect this is broken type.
30
+ /// </summary>
31
+ /// <param name="symbol">Type symbol</param>
32
+ private bool IsBrokenType ( ITypeSymbol symbol )
33
+ {
34
+ if ( ! Context . ExtractionContext . IsStandalone || ! symbol . FromSource ( ) )
35
+ {
36
+ return false ;
37
+ }
38
+ // (1) public class { ... } is a broken type and doesn't have a name.
39
+ // (2) public class var { ... } is a an allowed type, but it overrides the var keyword for all uses.
40
+ // It is probably a better heuristic to treat it as a broken type.
41
+ return string . IsNullOrEmpty ( symbol . Name ) || symbol . Name == "var" ;
42
+ }
43
+
28
44
public Kinds . TypeKind GetTypeKind ( Context cx , bool constructUnderlyingTupleType )
29
45
{
30
46
switch ( Symbol . SpecialType )
@@ -48,6 +64,9 @@ public Kinds.TypeKind GetTypeKind(Context cx, bool constructUnderlyingTupleType)
48
64
if ( Symbol . IsBoundNullable ( ) )
49
65
return Kinds . TypeKind . NULLABLE ;
50
66
67
+ if ( IsBrokenType ( Symbol ) )
68
+ return Kinds . TypeKind . UNKNOWN ;
69
+
51
70
switch ( Symbol . TypeKind )
52
71
{
53
72
case TypeKind . Class : return Kinds . TypeKind . CLASS ;
You can’t perform that action at this time.
0 commit comments