[NI] Fix adapting arguments for callable references with receivers

#KT-35912 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-01-20 13:35:56 +03:00
parent 43858e8169
commit 7bd7db839d
7 changed files with 61 additions and 1 deletions
@@ -2573,6 +2573,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
}
@TestMetadata("callableReferenceToVarargWithOverload.kt")
public void testCallableReferenceToVarargWithOverload() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/callableReferenceToVarargWithOverload.kt");
}
@TestMetadata("chooseCallableReferenceDependingOnInferredReceiver.kt")
public void testChooseCallableReferenceDependingOnInferredReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt");
@@ -266,7 +266,7 @@ class CallableReferencesCandidateFactory(
val mappedArgument: KotlinType?
if (substitutedParameter.isVararg) {
val (varargType, newVarargMappingState) = varargParameterTypeByExpectedParameter(
inputOutputTypes.inputTypes[index],
inputOutputTypes.inputTypes[index + unboundReceiverCount],
substitutedParameter,
varargMappingState,
builtins
@@ -0,0 +1,16 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KFunction2
class Foo
fun test(fn: KFunction2<Foo, Array<out String>, String>) = null
fun Foo.bar(vararg x: String) = ""
fun Foo.bar(vararg x: Int) = ""
fun actualTest() {
<!INAPPLICABLE_CANDIDATE!>test<!>(<!UNRESOLVED_REFERENCE!>Foo::bar<!>)
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KFunction2
class Foo
fun test(fn: KFunction2<Foo, Array<out String>, String>) = null
fun Foo.bar(vararg x: String) = ""
fun Foo.bar(vararg x: Int) = ""
fun actualTest() {
test(Foo::bar)
}
@@ -0,0 +1,13 @@
package
public fun actualTest(): kotlin.Unit
public fun test(/*0*/ fn: kotlin.reflect.KFunction2<Foo, kotlin.Array<out kotlin.String>, kotlin.String>): kotlin.Nothing?
public fun Foo.bar(/*0*/ vararg x: kotlin.String /*kotlin.Array<out kotlin.String>*/): kotlin.String
public fun Foo.bar(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.String
public final class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -2580,6 +2580,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
}
@TestMetadata("callableReferenceToVarargWithOverload.kt")
public void testCallableReferenceToVarargWithOverload() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/callableReferenceToVarargWithOverload.kt");
}
@TestMetadata("chooseCallableReferenceDependingOnInferredReceiver.kt")
public void testChooseCallableReferenceDependingOnInferredReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt");
@@ -2575,6 +2575,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
}
@TestMetadata("callableReferenceToVarargWithOverload.kt")
public void testCallableReferenceToVarargWithOverload() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/callableReferenceToVarargWithOverload.kt");
}
@TestMetadata("chooseCallableReferenceDependingOnInferredReceiver.kt")
public void testChooseCallableReferenceDependingOnInferredReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/chooseCallableReferenceDependingOnInferredReceiver.kt");