Fix #16268: classify IDisposable in type-occurrence positions as Interface, not DisposableType#19809
Fix #16268: classify IDisposable in type-occurrence positions as Interface, not DisposableType#19809T-Gro wants to merge 3 commits into
Conversation
…rface, not DisposableType Reorder the classification checks in SemanticClassification.fs so that isInterfaceTy is checked before isDisposableTy. This ensures that interface types (including System.IDisposable itself) used in type-occurrence positions (e.g. `interface IDisposable with`, `#IDisposable` constraints, upcasts) are colorized as Interface rather than DisposableType. Concrete disposable classes such as MemoryStream remain classified as DisposableType via the unchanged Item.CtorGroup arm. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
T-Gro
left a comment
There was a problem hiding this comment.
Review: Looks good — clean, correct fix with solid test coverage.
The fix: Reordering isInterfaceTy before isDisposableTy is the right approach. Interface types (including IDisposable itself) should always be classified as Interface in semantic classification — the DisposableType classification is meant for concrete classes that implement IDisposable, not for interface types that happen to extend it.
Tests: Good coverage across four distinct scenarios: interface impl position, concrete disposable class (negative test guarding against regression), type constraint usage, and a custom non-IDisposable interface.
Minor nit (non-blocking): The test file is missing a trailing newline (the diff shows \ No newline at end of file).
Description
Fixes #16268
When a type like IDisposable appears in a type-occurrence position (e.g., type annotations, interface implementations), it was being classified as DisposableType instead of Interface. This caused incorrect semantic highlighting in editors.
Changes