eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Casted receiver completion doesn't work properly with array types

Open
#3,739 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

Consider completion after the `|` in the following class:

```java
public class DemoClass {
public void myMethod() {
Object obj = new Object();
if (obj instanceof DemoClass[]) {
obj.len|
}
}
}
```

the `length` completion item completes to:

```java
public class DemoClass {
public void myMethod() {
Object obj = new Object();
if (obj instanceof DemoClass[]) {
((DemoClass)obj).length
}
}
}
```

It's casted to `DemoClass` instead of `DemoClass[]`, which results in a compilation error.

There is at least two tests that assert that this behaviour is correct: `CompletionTests.testCompletionAfterInstanceof24_1` and `CompletionTests.testCompletionAfterInstanceof24_2`

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.