-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Local FunctionsLocal FunctionsLocal FunctionsFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types
Description
This is an existing problem, but it is magnified by PR #40755 which infers a nullable type for var locals.
I did not manage to repro this in isolation yet. The scenarios I'd come up with were fixed by #40422 already.
Repro:
0. using an enlistment of master from roslyn repo (which includes the merged PR #40422 for fix to analysis of local functions)
- change
vartoCompilation?inAbstractTypeImportCompletionServiceas shown below build.cmd -bootstrap(to use latest compiler bits to compile)- get nullable diagnostic
diff --git a/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractTypeImportCompletionService.cs b/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractTypeImportCompletionService.cs
index 31f60b8..b52778d 100644
--- a/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractTypeImportCompletionService.cs
+++ b/src/Features/Core/Portable/Completion/Providers/ImportCompletionProvider/AbstractTypeImportCompletionService.cs
@@ -58,7 +58,7 @@ internal AbstractTypeImportCompletionService(Workspace workspace)
return null;
}
- var currentCompilation = await currentProject.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false);
+ Compilation? currentCompilation = await currentProject.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false);
return getCacheResults.Value.SelectAsArray(GetItemsFromCacheResult);
ImmutableArray<CompletionItem> GetItemsFromCacheResult(GetCacheResult cacheResult)D:\repos\roslyn2\src\Features\Core\Portable\Completion\Providers\ImportCompletionProvider\AbstractTypeImportCompletionService.cs(69,26): error CS8602: Dereference of a possibly null reference. [D:\repos\roslyn2\src\Features\Core\Portable\Microsoft.CodeAnalysis.Features.csproj]
Relates to #40755 which includes a few workarounds in the IDE code to unblock bootstrapping build.
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Local FunctionsLocal FunctionsLocal FunctionsFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types