Skip to content

Commit 0fb9dc5

Browse files
committed
C#: Adjust caching of tuple types
1 parent 1974602 commit 0fb9dc5

File tree

1 file changed

+5
-7
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp/Entities/Types

1 file changed

+5
-7
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/NamedType.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ class NamedType : Type<INamedTypeSymbol>
1919
}
2020

2121
public static NamedType Create(Context cx, INamedTypeSymbol type) =>
22-
type.IsTupleType
23-
? NamedTupleTypeFactory.Instance.CreateEntity(cx, (type, false), (type, false))
24-
: NamedTypeFactory.Instance.CreateEntityFromSymbol(cx, type);
22+
NamedTypeFactory.Instance.CreateEntityFromSymbol(cx, type);
2523

2624
/// <summary>
2725
/// Creates a named type entity from a tuple type. Unlike `Create`, this
@@ -30,7 +28,7 @@ public static NamedType Create(Context cx, INamedTypeSymbol type) =>
3028
/// `System.ValueTuple<int, string>`.
3129
/// </summary>
3230
public static NamedType CreateNamedTypeFromTupleType(Context cx, INamedTypeSymbol type) =>
33-
NamedTupleTypeFactory.Instance.CreateEntity(cx, (type, true), (type, true));
31+
UnderlyingTupleTypeFactory.Instance.CreateEntity(cx, (new SymbolEqualityWrapper(type), typeof(TupleType)), type);
3432

3533
public override bool NeedsPopulation => base.NeedsPopulation || symbol.TypeKind == TypeKind.Error;
3634

@@ -182,11 +180,11 @@ class NamedTypeFactory : ICachedEntityFactory<INamedTypeSymbol, NamedType>
182180
public NamedType Create(Context cx, INamedTypeSymbol init) => new NamedType(cx, init, false);
183181
}
184182

185-
class NamedTupleTypeFactory : ICachedEntityFactory<(INamedTypeSymbol, bool), NamedType>
183+
class UnderlyingTupleTypeFactory : ICachedEntityFactory<INamedTypeSymbol, NamedType>
186184
{
187-
public static readonly NamedTupleTypeFactory Instance = new NamedTupleTypeFactory();
185+
public static readonly UnderlyingTupleTypeFactory Instance = new UnderlyingTupleTypeFactory();
188186

189-
public NamedType Create(Context cx, (INamedTypeSymbol, bool) init) => new NamedType(cx, init.Item1, init.Item2);
187+
public NamedType Create(Context cx, INamedTypeSymbol init) => new NamedType(cx, init, true);
190188
}
191189

192190
// Do not create typerefs of constructed generics as they are always in the current trap file.

0 commit comments

Comments
 (0)