Mercurial > hg > openjdk > lambda > langtools
changeset 2246:93e9a9aa6e18
8021567: Javac doesn't report "java: reference to method is ambiguous" any more
author | mcimadamore |
---|---|
date | Fri, 26 Jul 2013 13:20:55 +0100 |
parents | 00274133b7d2 |
children | 91c60b02c849 |
files | src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/lambda/8021567/T8021567.java test/tools/javac/lambda/8021567/T8021567.out |
diffstat | 4 files changed, 30 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Fri Jul 26 12:46:37 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Jul 26 13:20:55 2013 +0100 @@ -1379,7 +1379,7 @@ } public void addBound(InferenceBound ib, Type bound, Types types, boolean update) { - Type bound2 = toTypeVarMap.apply(bound); + Type bound2 = toTypeVarMap.apply(bound).baseType(); List<Type> prevBounds = bounds.get(ib); for (Type b : prevBounds) { //check for redundancy - use strict version of isSameType on tvars
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jul 26 12:46:37 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jul 26 13:20:55 2013 +0100 @@ -2384,7 +2384,7 @@ ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ? recoveryInfo : - new LambdaResultInfo(lambdaType.getReturnType(), funcContext); + new ResultInfo(VAL, lambdaType.getReturnType(), funcContext); localEnv.info.returnResult = bodyResultInfo; Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log); @@ -2590,28 +2590,6 @@ super.compatible(found, req, warn); } } - - class LambdaResultInfo extends ResultInfo { - - LambdaResultInfo(Type pt, CheckContext checkContext) { - super(VAL, pt, checkContext); - } - - @Override - protected Type check(DiagnosticPosition pos, Type found) { - return super.check(pos, found.baseType()); - } - - @Override - protected ResultInfo dup(CheckContext newContext) { - return new LambdaResultInfo(pt, newContext); - } - - @Override - protected ResultInfo dup(Type newPt) { - return new LambdaResultInfo(newPt, checkContext); - } - } /** * Lambda compatibility. Check that given return types, thrown types, parameter types
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8021567/T8021567.java Fri Jul 26 13:20:55 2013 +0100 @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8021567 + * @summary Javac doesn't report "java: reference to method is ambiguous" any more + * @compile/fail/ref=T8021567.out -XDrawDiagnostics T8021567.java + */ + +class T8021567 { + + interface I_int { int m(); } + + interface I_char { char m(); } + + interface I_byte { byte m(); } + + void m(I_byte b) { } + void m(I_char b) { } + void m(I_int b) { } + + void test() { + m(() -> 1); //ambiguous + m(() -> 256); //ok - only method(I_int) applicable + m(() -> { int i = 1; return i; }); //ok - only method(I_int) applicable + m(() -> { int i = 256; return i; }); //ok - only method(I_int) applicable + } +}