@@ -121,8 +121,6 @@ bool IdDependsOnImpl(ITypeSymbol? type)
121
121
named = named . TupleUnderlyingType ;
122
122
if ( IdDependsOnImpl ( named . ContainingType ) )
123
123
return true ;
124
- if ( IdDependsOnImpl ( named . GetNonObjectBaseType ( cx ) ) )
125
- return true ;
126
124
if ( IdDependsOnImpl ( named . ConstructedFrom ) )
127
125
return true ;
128
126
return named . TypeArguments . Any ( IdDependsOnImpl ) ;
@@ -160,18 +158,15 @@ bool IdDependsOnImpl(ITypeSymbol? type)
160
158
/// <param name="trapFile">The trap builder used to store the result.</param>
161
159
/// <param name="symbolBeingDefined">The outer symbol being defined (to avoid recursive ids).</param>
162
160
/// <param name="constructUnderlyingTupleType">Whether to build a type ID for the underlying `System.ValueTuple` struct in the case of tuple types.</param>
163
- public static void BuildTypeId ( this ITypeSymbol type , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType = false ) =>
164
- type . BuildTypeId ( cx , trapFile , symbolBeingDefined , true , constructUnderlyingTupleType ) ;
165
-
166
- private static void BuildTypeId ( this ITypeSymbol type , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool addBaseClass , bool constructUnderlyingTupleType )
161
+ public static void BuildTypeId ( this ITypeSymbol type , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType = false )
167
162
{
168
163
using ( cx . StackGuard )
169
164
{
170
165
switch ( type . TypeKind )
171
166
{
172
167
case TypeKind . Array :
173
168
var array = ( IArrayTypeSymbol ) type ;
174
- array . ElementType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
169
+ array . ElementType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
175
170
array . BuildArraySuffix ( trapFile ) ;
176
171
return ;
177
172
case TypeKind . Class :
@@ -181,16 +176,16 @@ private static void BuildTypeId(this ITypeSymbol type, Context cx, EscapingTextW
181
176
case TypeKind . Delegate :
182
177
case TypeKind . Error :
183
178
var named = ( INamedTypeSymbol ) type ;
184
- named . BuildNamedTypeId ( cx , trapFile , symbolBeingDefined , addBaseClass , constructUnderlyingTupleType ) ;
179
+ named . BuildNamedTypeId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType ) ;
185
180
return ;
186
181
case TypeKind . Pointer :
187
182
var ptr = ( IPointerTypeSymbol ) type ;
188
- ptr . PointedAtType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
183
+ ptr . PointedAtType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
189
184
trapFile . Write ( '*' ) ;
190
185
return ;
191
186
case TypeKind . TypeParameter :
192
187
var tp = ( ITypeParameterSymbol ) type ;
193
- tp . ContainingSymbol . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
188
+ tp . ContainingSymbol . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
194
189
trapFile . Write ( '_' ) ;
195
190
trapFile . Write ( tp . Name ) ;
196
191
return ;
@@ -207,7 +202,7 @@ private static void BuildTypeId(this ITypeSymbol type, Context cx, EscapingTextW
207
202
}
208
203
}
209
204
210
- private static void BuildOrWriteId ( this ISymbol ? symbol , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool addBaseClass , bool constructUnderlyingTupleType = false )
205
+ private static void BuildOrWriteId ( this ISymbol ? symbol , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType = false )
211
206
{
212
207
if ( symbol is null )
213
208
{
@@ -232,7 +227,7 @@ private static void BuildOrWriteId(this ISymbol? symbol, Context cx, EscapingTex
232
227
if ( SymbolEqualityComparer . Default . Equals ( symbol , symbolBeingDefined ) )
233
228
trapFile . Write ( "__self__" ) ;
234
229
else if ( symbol is ITypeSymbol type && type . IdDependsOn ( cx , symbolBeingDefined ) )
235
- type . BuildTypeId ( cx , trapFile , symbolBeingDefined , addBaseClass , constructUnderlyingTupleType ) ;
230
+ type . BuildTypeId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType ) ;
236
231
else if ( symbol is INamedTypeSymbol namedType && namedType . IsTupleType && constructUnderlyingTupleType )
237
232
trapFile . WriteSubId ( NamedType . CreateNamedTypeFromTupleType ( cx , namedType ) ) ;
238
233
else
@@ -287,7 +282,7 @@ private static void BuildFunctionPointerTypeId(this IFunctionPointerTypeSymbol f
287
282
BuildFunctionPointerSignature ( funptr , trapFile , s => s . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ) ;
288
283
}
289
284
290
- private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool addBaseClass , bool constructUnderlyingTupleType )
285
+ private static void BuildNamedTypeId ( this INamedTypeSymbol named , Context cx , EscapingTextWriter trapFile , ISymbol symbolBeingDefined , bool constructUnderlyingTupleType )
291
286
{
292
287
if ( ! constructUnderlyingTupleType && named . IsTupleType )
293
288
{
@@ -297,7 +292,7 @@ private static void BuildNamedTypeId(this INamedTypeSymbol named, Context cx, Es
297
292
{
298
293
trapFile . Write ( ( f . CorrespondingTupleField ?? f ) . Name ) ;
299
294
trapFile . Write ( ":" ) ;
300
- f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
295
+ f . Type . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
301
296
}
302
297
) ;
303
298
trapFile . Write ( ")" ) ;
@@ -308,7 +303,7 @@ void AddContaining()
308
303
{
309
304
if ( named . ContainingType is not null )
310
305
{
311
- named . ContainingType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass ) ;
306
+ named . ContainingType . BuildOrWriteId ( cx , trapFile , symbolBeingDefined ) ;
312
307
trapFile . Write ( '.' ) ;
313
308
}
314
309
else if ( named . ContainingNamespace is not null )
@@ -333,35 +328,17 @@ void AddContaining()
333
328
}
334
329
else
335
330
{
336
- named . ConstructedFrom . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass , constructUnderlyingTupleType ) ;
331
+ named . ConstructedFrom . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , constructUnderlyingTupleType ) ;
337
332
trapFile . Write ( '<' ) ;
338
333
// Encode the nullability of the type arguments in the label.
339
334
// Type arguments with different nullability can result in
340
335
// a constructed type with different nullability of its members and methods,
341
336
// so we need to create a distinct database entity for it.
342
337
trapFile . BuildList ( "," , named . GetAnnotatedTypeArguments ( ) ,
343
- ta => ta . Symbol . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass )
338
+ ta => ta . Symbol . BuildOrWriteId ( cx , trapFile , symbolBeingDefined )
344
339
) ;
345
340
trapFile . Write ( '>' ) ;
346
341
}
347
-
348
- if ( addBaseClass && named . GetNonObjectBaseType ( cx ) is INamedTypeSymbol @base )
349
- {
350
- // We need to limit unfolding of base classes. For example, in
351
- //
352
- // ```csharp
353
- // class C1<T> { }
354
- // class C2<T> : C1<C3<T>> { }
355
- // class C3<T> : C1<C2<T>> { }
356
- // class C4 : C3<C4> { }
357
- // ```
358
- //
359
- // when we generate the label for `C4`, the base class `C3<C4>` has itself `C1<C2<C4>>` as
360
- // a base class, which in turn has `C1<C3<C4>>` as a base class. The latter has the original
361
- // base class `C3<C4>` as a type argument, which would lead to infinite unfolding.
362
- trapFile . Write ( " : " ) ;
363
- @base . BuildOrWriteId ( cx , trapFile , symbolBeingDefined , addBaseClass : false ) ;
364
- }
365
342
}
366
343
367
344
private static void BuildNamespace ( this INamespaceSymbol ns , Context cx , EscapingTextWriter trapFile )
0 commit comments