Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 478533 - [compiler][1.8][lambda] check visibility of target context is broken
Summary: [compiler][1.8][lambda] check visibility of target context is broken
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.6 M4   Edit
Assignee: Sasikanth Bharadwaj CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 468122 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-09-28 07:20 EDT by Alexey Dubrovskiy CLA
Modified: 2017-05-25 17:08 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Dubrovskiy CLA 2015-09-28 07:20:24 EDT
Using: 
  Eclipse: Mars Release (4.5.0), Build id: 20150621-1200
  Java: JDK 1.8.0_60

Eclipse produces context visibility errors on the following code. The same code compiles and runs in 4.4.2:

// ----------/test/subpackage/A.java
package test.subpackage;

interface A<I> {
	String invoke(I input);
}

// ----------/test/subpackage/B.java
package test.subpackage;

public interface B extends A<Integer> {}


// ----------/test/BugDemonstrator.java
package test;

import test.subpackage.B;

public class BugDemonstrator {

	public static void main(String[] args) {
		// OK
		invoke(new B() {
			public String invoke(Integer input) {
				return null;
			}
		});

		// ERROR
		invoke((Integer i) -> { // Error is here: The type A<Object,Integer> from the descriptor computed for the target context is not visible here.
			return null;
		});
	}

	private static String invoke(B b) {
		return b.invoke(1);
	}
}
Comment 1 Sasikanth Bharadwaj CLA 2015-09-29 04:32:22 EDT
FunctionalExpression.kosherDescriptor checks for the visibility of sam.declaringclass, but according to the spec, 

It is a compile-time error if any class or interface mentioned by either U or the
function type of U is not accessible from the class or interface in which the lambda
expression appears.

So the check should probably be for the visibility of expected type and not declaring class
Comment 2 Eclipse Genie CLA 2015-10-20 15:48:17 EDT
New Gerrit change created: https://git.eclipse.org/r/58554
Comment 3 Sasikanth Bharadwaj CLA 2015-10-21 01:13:46 EDT
(In reply to comment #2)
> New Gerrit change created: https://git.eclipse.org/r/58554
That change was based on wrong branch resulting in test failures and hence abandoned. Will create another one shortly
Comment 4 Eclipse Genie CLA 2015-10-21 01:31:48 EDT
New Gerrit change created: https://git.eclipse.org/r/58570
Comment 6 Sasikanth Bharadwaj CLA 2015-11-27 02:01:52 EST
Released for M4
Comment 7 Manoj N Palat CLA 2015-12-08 03:33:16 EST
Verified for Eclipse Neon Version: Neon 4.6M4 Build id: I20151207-0800
Comment 8 Stephan Herrmann CLA 2017-05-25 17:08:59 EDT
*** Bug 468122 has been marked as a duplicate of this bug. ***