diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index 09fa6019217..63d02d0ab04 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ fun ResolvedCall.usesDefaultArguments(): Boolean { fun > Call.hasUnresolvedArguments(context: ResolutionContext): Boolean { val arguments = valueArguments.map { it.getArgumentExpression() } return arguments.any (fun (argument: KtExpression?): Boolean { - if (argument == null || ArgumentTypeResolver.isFunctionLiteralArgument(argument, context)) return false + if (argument == null || ArgumentTypeResolver.isFunctionLiteralOrCallableReference(argument, context)) return false val resolvedCall = argument.getResolvedCall(context.trace.bindingContext) as MutableResolvedCall<*>? if (resolvedCall != null && !resolvedCall.hasInferredReturnType()) return false diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt new file mode 100644 index 00000000000..01aa24b26d3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt @@ -0,0 +1,18 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KCallable + +class Foo { + fun installRoute(handler: T) where T : (String) -> Any?, T : KCallable<*> { + } + + fun installRoute(handler: T) where T : () -> Any?, T : KCallable<*> { + } + + fun foo() { + installRoute(::route) + } + +} + +fun route(s: String): Any? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.txt b/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.txt new file mode 100644 index 00000000000..9c088672473 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.txt @@ -0,0 +1,13 @@ +package + +public fun route(/*0*/ s: kotlin.String): kotlin.Any? + +public final class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun kotlin.Any?> installRoute(/*0*/ handler: T): kotlin.Unit where T : kotlin.reflect.KCallable<*> + public final fun kotlin.Any?> installRoute(/*0*/ handler: T): kotlin.Unit where T : kotlin.reflect.KCallable<*> + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.kt index 238a9821de2..39a5dffaf25 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withPlaceholderTypes.kt @@ -20,7 +20,7 @@ val x1 = fn1(1, ::foo, ::foo) val x2 = fn1(1, ::foo, ::bar) val x3 = fn2(::bar, ::foo) -val x4 = fn2(::foo, ::bar) -val x5 = fn2(::foo, ::foo) +val x4 = fn2(::foo, ::bar) +val x5 = fn2(::foo, ::foo) val x6 = fn3(1, ::qux) \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index d484b7e16ad..7fa8e99b59d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -2580,6 +2580,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("intersectionTypeOverloadWithWrongParameter.kt") + public void testIntersectionTypeOverloadWithWrongParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt"); + doTest(fileName); + } + @TestMetadata("kt10036.kt") public void testKt10036() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 7a3e32f2c20..6d4271cfc32 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -2580,6 +2580,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing doTest(fileName); } + @TestMetadata("intersectionTypeOverloadWithWrongParameter.kt") + public void testIntersectionTypeOverloadWithWrongParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt"); + doTest(fileName); + } + @TestMetadata("kt10036.kt") public void testKt10036() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.kt");