eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

ECJ+Save actions Bug: The Varnisher

Open
#167 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
22h 47m
Merged PRs (30d)
28

Description

Somehow my Eclipse 2022.3 found it necessary to adorn all my var statements with type parameters that were already on the right side of the initialization statement:

```java
var joinX = (Join) root.fetch(tToX, JoinType.LEFT);
```
became (due to our save actions automation):

```java
var joinX = (Join) root.fetch(tToX, JoinType.LEFT);
```

I never expected this to be valid Java (and according to the language rules it shouldn't be), so this sparked more interest in finding the most funny representation of this issue. Behold:

### The Varnisher

```java
var>>>>>>>>>>>>>> var = "var";
```

ECJ finds this code to be perfectly correct, whereas javac will give a compilation error on the type parameters (the variable can of course be named `var`, as var is only a restricted type, not a keyword).

I don't think fixing the compiler is the most important issue ever, and this makes for great slides in lightning talks, so please take your time fixing it 😄

The issue causing me to find this ecj bug is of course also interesting and probably more important to fix, but I don't know how to reproduce it.

### Settings for the auto save actions

- Format all lines
- Organize imports

Additional actions:
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Remove unused imports
- Add missing '@Override' annotations
- Add missing '@Override' annotations to implementations of interface methods
- Add missing '@Deprecated' annotations
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
- Use diamond operator

Image with the diffs (I did not edit these lines myself, the save action did that for me):

image

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.