| Summary: | [1.8][compiler] Passing interface extending package private functional interface into consuming function causes compiler error | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Karsten Gregorius <distant.calls> |
| Component: | Core | Assignee: | Sasikanth Bharadwaj <sasikanth.bharadwaj> |
| Status: | CLOSED DUPLICATE | QA Contact: | Stephan Herrmann <stephan.herrmann> |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat, stephan.herrmann |
| Version: | 4.5 | ||
| Target Milestone: | 4.6 M4 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | To be verified for 4.7 RC3 | ||
Indeed, javac accepts.
Using ecj HEAD I see exactly one error:
----------
1. ERROR in /tmp/a/b/c/SomeClient.java (at line 11)
return execute(() -> "fail");
^^^^^^^^^^^^
The type I from the descriptor computed for the target context is not visible here.
----------
What other errors do you see?
We report this error since bug 439707. My guess is, that the new check from that bug should use the target type, not the declaring class of the descriptor method.
Looking at JLS 15.27.3, which is what we implement in FE#kosherDescriptor() and which produces the error, I don't see any reason to complain against the declaring type. OTOH, I haven't yet found a JLS section that specifies the situation in bug 439707, so we may be left to our own reasoning.
Hm forget about that "and others" - the mentioned bug is the only one I actually saw. Those "others" went away after I had issued a clean on the project. (In reply to Karsten Gregorius from comment #2) > Hm forget about that "and others" - the mentioned bug is the only one I > actually saw. Those "others" went away after I had issued a clean on the > project. thanks for clarifying. Works as expected on master. Yet to find the change that fixed this *** This bug has been marked as a duplicate of bug 478533 *** |
Assume a package a.b with a package private functional interface a.b.I and another public interface extending I: ----- a.b.I ----- package a.b; interface I { String doSomething(); } ----- a.b.I ----- ----- a.b.Other ----- package a.b; public interface Other extends I { } ----- a.b.Other ----- When passing Other to any consuming function in a class outside a.b, this raises a compiler error: ----- a.b.c.SomeClient ----- package a.b.c; import a.b.Other; public class SomeClient { public static String execute() { /* * "The type I from the descriptor computed for the target context is not visible here." (and others) */ return execute(() -> "fail"); } private static String execute(Other o) { return o.doSomething(); } } ----- a.b.c.SomeClient ----- I'd expect ECJ to compile the above code without errors - at least, Java 1.8 does. Seen in Eclipse 4.5M7 and RC1 (20150521-1252).