-
Notifications
You must be signed in to change notification settings - Fork 906
Closed
Description
With version 1.12.0 google-java-format does not properly recognize imports utilized only during pattern matched switches.
As an example, for the following hierarchy
package example.model;
public sealed interface SealedInterface {}
public non-sealed interface TypeA {}
public non-sealed interface TypeB {}and a Java file using this hierarchy with a pattern matched switch
package example;
import example.model.SealedInterface;
import example.model.TypeA;
import example.model.TypeB;
public class Main {
public void apply(SealedInterface sealedInterface) {
switch(sealedInterface) {
case TypeA a -> System.out.println("A!");
case TypeB b -> System.out.println("B!");
}
}
}google-java-format will flag import example.model.TypeA and import example.model.TypeB as unused and candidates for removal.
I've recreated this bug in a small repo that illustrates the issue.
tk-png, Joaclar, cushon and siy
Metadata
Metadata
Assignees
Labels
No labels