vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

incorrect warning about unused import for import used in permits clause

Open softwareCobbler opened this issue 2 years ago • 1 comments

Incorrect warning about unused import when that import

  • references a nested class in the same file
  • is used only in a permits clause on the file's top-level class
Environment
  • Operating System: Win10
  • JDK version: 21
  • Visual Studio Code version: 1.85
  • Java extension version: v1.26.2023122208
Steps To Reproduce

The following code issues a warning in the IDE about unused imports:

package foo.x;

// these imports are warned against as unused,
// but the permits clause doesn't compile without them
import foo.x.A.B;
import foo.x.A.C;

public sealed interface A permits B, C {
    record B(int data) implements A {}
    record C(String data) implements A {}
}

Current Result

warning on the import of foo.x.A.B and foo.x.A.C

Expected Result

no warnings

Additional Informations

softwareCobbler avatar Dec 31 '23 14:12 softwareCobbler

This is an upstream JDT issue - https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1808

snjeza avatar Jan 03 '24 15:01 snjeza