From d62e8eee31a02266578b8ec6423bf363a2cc017a Mon Sep 17 00:00:00 2001 From: Jason Malinowski Date: Tue, 26 Nov 2019 17:41:25 -0800 Subject: [PATCH] Remove calls to our extensions of TypeInfo that return annotated nullability TypeInfo explicitly returns a Type or ConvertedType, the top-level nullability of which is the flow state nullability. It also explicitly gives you annotated nullability prior to us including nullability in with types. This PR removes the explicit use of the annotated nullability when it doesn't matter, namely when the thing you're calling GetTypeInfo is already a TypeSyntax so the 'flow state' was never really a flow state to begin with. --- .../ExtractMethod/CSharpSelectionResult.ExpressionResult.cs | 2 +- .../CSharpGenerateParameterizedMemberService.cs | 2 +- .../CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs | 2 +- .../LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Features/CSharp/Portable/ExtractMethod/CSharpSelectionResult.ExpressionResult.cs b/src/Features/CSharp/Portable/ExtractMethod/CSharpSelectionResult.ExpressionResult.cs index dfb72abc78b..9a6ef1db571 100644 --- a/src/Features/CSharp/Portable/ExtractMethod/CSharpSelectionResult.ExpressionResult.cs +++ b/src/Features/CSharp/Portable/ExtractMethod/CSharpSelectionResult.ExpressionResult.cs @@ -62,7 +62,7 @@ public override bool ContainingScopeHasAsyncKeyword() var variableDeclExpression = node.GetAncestorOrThis(); if (variableDeclExpression != null) { - return model.GetTypeInfo(variableDeclExpression.Type).GetTypeWithAnnotatedNullability(); + return model.GetTypeInfo(variableDeclExpression.Type).Type; } } diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs b/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs index 34b218b7b9c..cacd0ad779e 100644 --- a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs +++ b/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs @@ -171,7 +171,7 @@ protected override ImmutableArray DetermineTypeArguments(Cancellati foreach (var typeArgument in ((GenericNameSyntax)State.SimpleNameOpt).TypeArgumentList.Arguments) { var typeInfo = this.Document.SemanticModel.GetTypeInfo(typeArgument, cancellationToken); - result.Add(typeInfo.GetTypeWithAnnotatedNullability()); + result.Add(typeInfo.Type); } } diff --git a/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs b/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs index f2d1ea62a56..0ae9756972f 100644 --- a/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/TypeStyle/UseExplicitTypeCodeFixProvider.cs @@ -90,7 +90,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) if (parensDesignation is null) { - var typeSymbol = semanticModel.GetTypeInfo(typeSyntax.StripRefIfNeeded()).GetConvertedTypeWithAnnotatedNullability(); + var typeSymbol = semanticModel.GetTypeInfo(typeSyntax.StripRefIfNeeded()).ConvertedType; // We're going to be passed through the simplifier. Tell it to not just convert // this back to var (as that would defeat the purpose of this refactoring entirely). diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs index e6b516b5063..c71d82a329d 100644 --- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs +++ b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs @@ -1194,7 +1194,7 @@ private IEnumerable InferTypeInPropertyDeclaration(PropertyDe Debug.Assert(propertyDeclaration?.Type != null, "Property type should never be null"); var typeInfo = SemanticModel.GetTypeInfo(propertyDeclaration.Type); - return CreateResult(typeInfo.GetTypeWithAnnotatedNullability()); + return CreateResult(typeInfo.Type); } private IEnumerable InferTypeInExpressionStatement(ExpressionStatementSyntax expressionStatement, SyntaxToken? previousToken = null) -- GitLab