dotnet / dotnet/roslyn

IntelliSense loses track of types of variables

Open
#75,652 5 comments 1 reaction 0 assignees View on GitHub
Area-Compilers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**: 17.12 P4

**Steps to Reproduce**:

https://github.com/user-attachments/assets/4fde08d1-5ae8-4233-aa00-d8eda1c0df4b

**Diagnostic Id**:

**Expected Behavior**:

The type of `dataSource` should be clear, because:
- `dataSourceFactory.GetDataSourceAsync` returns a `ValueTask` (awaited)
- it has no other overloads, in fact the only method of that interface (`GetDocumentAsync` has no overloads either)
- neither the syntax tree is broken which could invalidate the declarations earlier
- no other symbol named `dataSource` outside of this context
- none of the related types are declared in the enclosing scope

**Actual Behavior**:

Quick Info can't infer the type of `dataSource`, code completion doesn't work either.

Diagnostics don't report it as an individual error, it reports only that `GetDocumentAsync` is missing an argument - which is correct, and also means that some underlying parts could still infer the type correctly.

This must be an edge case, because I encounter this error rarely.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.