@@ -483,7 +483,7 @@ private void GenerateVariableInfoMap(
483
483
if ( symbol is IParameterSymbol && variableDeclared )
484
484
continue ;
485
485
486
- var type = GetSymbolType ( symbol ) ;
486
+ var type = GetSymbolTypeWithUpdatedNullability ( symbol ) ;
487
487
if ( type == null )
488
488
continue ;
489
489
@@ -527,16 +527,9 @@ PooledDisposer<PooledHashSet<ISymbol>> GetPooledSymbolSet(ImmutableArray<ISymbol
527
527
return disposer ;
528
528
}
529
529
530
- ITypeSymbol ? GetSymbolType ( ISymbol symbol )
530
+ ITypeSymbol ? GetSymbolTypeWithUpdatedNullability ( ISymbol symbol )
531
531
{
532
- var type = symbol switch
533
- {
534
- ILocalSymbol local => local . Type ,
535
- IParameterSymbol parameter => parameter . Type ,
536
- IRangeVariableSymbol rangeVariable => GetRangeVariableType ( rangeVariable ) ,
537
- _ => throw ExceptionUtilities . UnexpectedValue ( symbol )
538
- } ;
539
-
532
+ var type = GetUnderlyingSymbolType ( symbol ) ;
540
533
if ( type is null )
541
534
return type ;
542
535
@@ -578,6 +571,17 @@ static VariableInfo CreateFromSymbol(
578
571
}
579
572
}
580
573
574
+ private ITypeSymbol ? GetUnderlyingSymbolType ( ISymbol symbol )
575
+ {
576
+ return symbol switch
577
+ {
578
+ ILocalSymbol local => local . Type ,
579
+ IParameterSymbol parameter => parameter . Type ,
580
+ IRangeVariableSymbol rangeVariable => GetRangeVariableType ( rangeVariable ) ,
581
+ _ => throw ExceptionUtilities . UnexpectedValue ( symbol )
582
+ } ;
583
+ }
584
+
581
585
private static void AddVariableToMap ( IDictionary < ISymbol , VariableInfo > variableInfoMap , ISymbol localOrParameter , VariableInfo variableInfo )
582
586
=> variableInfoMap . Add ( localOrParameter , variableInfo ) ;
583
587
@@ -745,17 +749,7 @@ private void AppendMethodTypeVariableFromDataFlowAnalysis(
745
749
IDictionary < int , ITypeParameterSymbol > sortedMap )
746
750
{
747
751
foreach ( var symbol in variableInfoMap . Keys )
748
- {
749
- var type = symbol switch
750
- {
751
- IParameterSymbol parameter => parameter . Type ,
752
- ILocalSymbol local => local . Type ,
753
- IRangeVariableSymbol rangeVariable => GetRangeVariableType ( rangeVariable ) ,
754
- _ => throw ExceptionUtilities . UnexpectedValue ( symbol ) ,
755
- } ;
756
-
757
- AddTypeParametersToMap ( TypeParameterCollector . Collect ( type ) , sortedMap ) ;
758
- }
752
+ AddTypeParametersToMap ( TypeParameterCollector . Collect ( GetUnderlyingSymbolType ( symbol ) ) , sortedMap ) ;
759
753
}
760
754
761
755
private void AppendMethodTypeParameterFromConstraint ( SortedDictionary < int , ITypeParameterSymbol > sortedMap )
0 commit comments