overload resolution: apply site substitution before potential compatibility check (IDEA-150807)

This commit is contained in:
Anna Kozlova
2016-01-25 12:31:26 +03:00
parent ec2c691cbf
commit 883f7f3f39
3 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
import java.util.function.Function;
class Test {
static class MyMap<V>
{
V put( char[] key, V value )
{
return null;
}
V put( String key, V value )
{
return null;
}
}
static final MyMap<Test.F> s_funcMap = new MyMap<>();
interface F extends Function<Thread,Number> { }
static
{
// without casts
s_funcMap.put( "ID", Thread::getId );
s_funcMap.put( "ID", thread -> thread.getId() + 1 );
s_funcMap.put( "ID", thread -> { return thread.getId() + 1; } );
// with casts
s_funcMap.put( "ID", (Test.F) Thread::getId );
s_funcMap.put( "ID", (Test.F) thread -> thread.getId() + 1 );
s_funcMap.put( "ID", (Test.F) thread -> { return thread.getId() + 1; } );
}
}