@@ -433,7 +433,7 @@ MemberAccessExpressionSyntax memberAccess when memberAccess.Kind() == SyntaxKind
433433 var tagArguments = invocation . ArgumentList . Arguments . SkipWhile ( ( arg , i ) => arg . NameColon ? . Name . Identifier . Text != "tags" && i < 2 ) ;
434434 var tags = BuildTags ( semanticModel , tagArguments ) ;
435435 VisitBind ( metadataVisitor , semanticModel , invocation , tags , genericName ) ;
436- var rootBindSymbol = semantic . GetTypeSymbol < INamedTypeSymbol > ( semanticModel , rootBindType ) ;
436+ var rootBindSymbol = GetTypeSymbol ( semanticModel , rootBindType ) ;
437437 VisitRoot ( invocation , tags . FirstOrDefault ( ) , metadataVisitor , semanticModel , invocation , invocationComments , rootBindSymbol ) ;
438438 break ;
439439
@@ -616,7 +616,7 @@ MemberAccessExpressionSyntax memberAccess when memberAccess.Kind() == SyntaxKind
616616 nameof ( Strings . Error_InvalidRootType ) ) ;
617617 }
618618
619- var rootSymbol = semantic . GetTypeSymbol < ITypeSymbol > ( semanticModel , rootTypeSyntax ) ;
619+ var rootSymbol = GetTypeSymbol ( semanticModel , rootTypeSyntax ) ;
620620 VisitRoot ( invocation , metadataVisitor , semanticModel , invocation , invocationComments , rootSymbol ) ;
621621 break ;
622622
@@ -1033,7 +1033,7 @@ private void VisitRoot(
10331033 SemanticModel semanticModel ,
10341034 InvocationExpressionSyntax invocation ,
10351035 IReadOnlyCollection < string > invocationComments ,
1036- INamedTypeSymbol rootSymbol )
1036+ ITypeSymbol rootSymbol )
10371037 {
10381038 tag ??= new MdTag ( 0 , null ) ;
10391039 var rootArgs = arguments . GetArgs ( invocation . ArgumentList , "name" , "kind" ) ;
@@ -1062,13 +1062,15 @@ private void VisitBind(
10621062 GenericNameSyntax genericName )
10631063 {
10641064 var contractTypes = genericName . TypeArgumentList . Arguments ;
1065+ // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
10651066 foreach ( var contractType in contractTypes )
10661067 {
1068+ var contractTypeSymbol = GetTypeSymbol ( semanticModel , contractType ) ;
10671069 metadataVisitor . VisitContract (
10681070 new MdContract (
10691071 semanticModel ,
10701072 invocation ,
1071- semantic . GetTypeSymbol < ITypeSymbol > ( semanticModel , contractType ) ,
1073+ contractTypeSymbol ,
10721074 ContractKind . Explicit ,
10731075 tags ) ) ;
10741076 }
@@ -1388,7 +1390,7 @@ private MdResolver CreateResolver(
13881390 var resolverTag = new MdTag ( 0 , tagValue ) ;
13891391 if ( args [ 1 ] is { } argSyntax2 )
13901392 {
1391- var argType2 = GetDefaultType ( semanticModel , invocation , 1 ) ?? GetArgSymbol ( semanticModel , argSyntax2 ) ?? resultType ;
1393+ var argType2 = GetDefaultType ( semanticModel , invocation , 0 ) ?? GetArgSymbol ( semanticModel , argSyntax2 ) ?? resultType ;
13921394 if ( argType2 is null or IErrorTypeSymbol )
13931395 {
13941396 throw new CompileErrorException (
@@ -1461,14 +1463,27 @@ MemberAccessExpressionSyntax memberAccess when memberAccess.Kind() == SyntaxKind
14611463 } ;
14621464
14631465 ITypeSymbol ? defaultType = null ;
1466+ // ReSharper disable once InvertIf
14641467 if ( name is GenericNameSyntax genericName && genericName . TypeArgumentList . Arguments . Count > typeArgPosition )
14651468 {
1466- defaultType = semantic . GetTypeSymbol < ITypeSymbol > ( semanticModel , genericName . TypeArgumentList . Arguments [ typeArgPosition ] ) ;
1469+ var typeArgument = genericName . TypeArgumentList . Arguments [ typeArgPosition ] ;
1470+ defaultType = GetTypeSymbol ( semanticModel , typeArgument ) ;
14671471 }
14681472
14691473 return defaultType ;
14701474 }
14711475
1476+ private ITypeSymbol GetTypeSymbol ( SemanticModel semanticModel , TypeSyntax typeSyntax )
1477+ {
1478+ var typeSymbol = semantic . GetTypeSymbol < ITypeSymbol > ( semanticModel , typeSyntax ) ;
1479+ if ( typeSyntax is NullableTypeSyntax && typeSymbol . IsReferenceType )
1480+ {
1481+ typeSymbol = typeSymbol . WithNullableAnnotation ( NullableAnnotation . Annotated ) ;
1482+ }
1483+
1484+ return typeSymbol ;
1485+ }
1486+
14721487 private static bool HasContextTag ( ExpressionSyntax ? tag , ParameterSyntax contextParameter ) =>
14731488 tag is MemberAccessExpressionSyntax memberAccessExpression
14741489 && memberAccessExpression . IsKind ( SyntaxKind . SimpleMemberAccessExpression )
0 commit comments