diffplug / diffplug/spotless

removeUnusedImport check fails when there are pattern matching switch expressions with inner classes

Open
#2,492 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 13h
Merged PRs (30d)
34

Description

I have the following switch expression
```java
result = switch (literal) {
case Literal.Integer(int value, int ignored) -> value;
case Literal.Long(long value, int ignored) -> value;
case Literal.Float(float value) -> value;
case Literal.Double(double value) -> value;
case Literal.Character(char value) -> value;
case Literal.String(String value) -> value;
};
```

and it causes the `removeUnusedImport` rule to fail with the following message:
```
src/main/java/daomephsta/unpick/impl/constantmappers/datadriven/ExpressionEvaluator.java:L142 removeUnusedImports(removeUnusedImports) error: '.class' expected
```

[full code](https://github.com/FabricMC/unpick/blob/5523cc9d5dceecf929df4db9888eead201ddb8ce/src/main/java/daomephsta/unpick/impl/constantmappers/datadriven/ExpressionEvaluator.java#L141)

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.