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

The method run(Supplier<String[]>) is ambiguous for the type TestJ ava(67108966)

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

Description

The following code produces an `The method run(Supplier) is ambiguous for the type TestJ ava(67108966)`, This code compiles fine with javac.

```java
import java.util.function.Supplier;

public class Test {

private Processor processor1;

private Processor processor2;

public String[] processors1() {
// An error will be reported here.
return run(processor1::processors);
}

public String[] processors2() {
// With the same code, since the processor2 field declares a generic type, no error will be reported here.
return run(processor2::processors);
}

private T run(Supplier supplier) {
return supplier.get();
}

private void run(Runnable task) {

}

public static abstract class Processor {

public String[] processors() {
return new String[0];
}

}

}

```

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.