From 29ab166e1bbe363cc61a80d3d60533ab14d9df05 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 30 May 2014 09:59:44 +0400 Subject: [PATCH] Refactoring: AbstractResolvedCallsTest Render resolved call to a separate file --- .../functionLiterals/chainedLambdas.kt | 4 - .../functionLiterals/chainedLambdas.txt | 21 +++ .../notInferredLambdaReturnType.kt | 3 - .../notInferredLambdaReturnType.txt | 18 +++ .../functionLiterals/notInferredLambdaType.kt | 3 - .../notInferredLambdaType.txt | 18 +++ .../functionLiterals/simpleGenericLambda.kt | 3 - .../functionLiterals/simpleGenericLambda.txt | 18 +++ .../functionLiterals/simpleLambda.kt | 3 - .../functionLiterals/simpleLambda.txt | 18 +++ .../functionLiterals/unmappedLambda.kt | 2 - .../functionLiterals/unmappedLambda.txt | 18 +++ .../genericCalls/inferredParameter.kt | 3 - .../genericCalls/inferredParameter.txt | 21 +++ .../arguments/genericCalls/simpleGeneric.kt | 2 - .../arguments/genericCalls/simpleGeneric.txt | 20 +++ .../genericCalls/uninferredParameter.kt | 3 - .../genericCalls/uninferredParameter.txt | 21 +++ .../uninferredParameterTypeMismatch.kt | 2 - .../uninferredParameterTypeMismatch.txt | 18 +++ .../namedArguments/positionedAfterNamed.kt | 3 - .../namedArguments/positionedAfterNamed.txt | 22 +++ .../namedArguments/shiftedArgsMatch.kt | 3 - .../namedArguments/shiftedArgsMatch.txt | 22 +++ .../oneArgument/argumentHasNoType.kt | 2 - .../oneArgument/argumentHasNoType.txt | 20 +++ .../arguments/oneArgument/simpleMatch.kt | 2 - .../arguments/oneArgument/simpleMatch.txt | 20 +++ .../arguments/oneArgument/typeMismatch.kt | 2 - .../arguments/oneArgument/typeMismatch.txt | 20 +++ .../arguments/oneArgument/unmappedArgument.kt | 2 - .../oneArgument/unmappedArgument.txt | 18 +++ .../arguments/realExamples/emptyList.kt | 2 - .../arguments/realExamples/emptyList.txt | 22 +++ .../realExamples/emptyMutableList.kt | 2 - .../realExamples/emptyMutableList.txt | 22 +++ .../severalCandidates/mostSpecific.kt | 3 - .../severalCandidates/mostSpecific.txt | 23 +++ .../explicitReceiverIsReceiverArgument.kt | 3 - .../explicitReceiverIsReceiverArgument.txt | 16 ++ .../explicitReceiverIsThisObject.kt | 3 - .../explicitReceiverIsThisObject.txt | 16 ++ .../invokeForExtensionFunctionType.kt | 3 - .../invokeForExtensionFunctionType.txt | 12 ++ .../functionTypes/invokeForFunctionType.kt | 3 - .../functionTypes/invokeForFunctionType.txt | 12 ++ .../valOfExtensionFunctionType.kt | 3 - .../valOfExtensionFunctionType.txt | 16 ++ .../valOfExtensionFunctionTypeInvoke.kt | 3 - .../valOfExtensionFunctionTypeInvoke.txt | 16 ++ .../functionTypes/valOfFunctionType.kt | 3 - .../functionTypes/valOfFunctionType.txt | 16 ++ .../functionTypes/valOfFunctionTypeInvoke.kt | 3 - .../functionTypes/valOfFunctionTypeInvoke.txt | 20 +++ .../hasBothThisObjectAndReceiverArgument.kt | 3 - .../hasBothThisObjectAndReceiverArgument.txt | 22 +++ ...ReceiverArgumentWithoutExplicitReceiver.kt | 3 - ...eceiverArgumentWithoutExplicitReceiver.txt | 24 +++ .../implicitReceiverIsReceiverArgument.kt | 3 - .../implicitReceiverIsReceiverArgument.txt | 16 ++ .../implicitReceiverIsThisObject.kt | 3 - .../implicitReceiverIsThisObject.txt | 16 ++ .../impliedThisNoExplicitReceiver.kt | 3 - .../impliedThisNoExplicitReceiver.txt | 15 ++ .../resolvedCalls/invoke/bothReceivers.kt | 3 - .../resolvedCalls/invoke/bothReceivers.txt | 16 ++ .../invoke/implicitReceiverForInvoke.kt | 3 - .../invoke/implicitReceiverForInvoke.txt | 20 +++ .../receiverArgumentAsReceiverForInvoke.kt | 3 - .../receiverArgumentAsReceiverForInvoke.txt | 15 ++ .../invoke/thisObjectAsReceiverForInvoke.kt | 3 - .../invoke/thisObjectAsReceiverForInvoke.txt | 16 ++ .../realExamples/stringPlusInBuilders.kt | 3 - .../realExamples/stringPlusInBuilders.txt | 48 ++++++ compiler/testData/resolvedCalls/simpleCall.kt | 3 - .../testData/resolvedCalls/simpleCall.txt | 14 ++ .../calls/AbstractResolvedCallsTest.kt | 146 ++++++------------ 77 files changed, 770 insertions(+), 208 deletions(-) create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.txt create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.txt create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.txt create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.txt create mode 100644 compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.txt create mode 100644 compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt create mode 100644 compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.txt create mode 100644 compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.txt create mode 100644 compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.txt create mode 100644 compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.txt create mode 100644 compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.txt create mode 100644 compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.txt create mode 100644 compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.txt create mode 100644 compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.txt create mode 100644 compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.txt create mode 100644 compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt create mode 100644 compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt create mode 100644 compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.txt create mode 100644 compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.txt create mode 100644 compiler/testData/resolvedCalls/explicitReceiverIsThisObject.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.txt create mode 100644 compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.txt create mode 100644 compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.txt create mode 100644 compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.txt create mode 100644 compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.txt create mode 100644 compiler/testData/resolvedCalls/implicitReceiverIsThisObject.txt create mode 100644 compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.txt create mode 100644 compiler/testData/resolvedCalls/invoke/bothReceivers.txt create mode 100644 compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.txt create mode 100644 compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.txt create mode 100644 compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.txt create mode 100644 compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt create mode 100644 compiler/testData/resolvedCalls/simpleCall.txt diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.kt index e5a795e1860..9ef4432d82e 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.kt @@ -1,8 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentMatch(t : Int, SUCCESS) -// !ARG_2: ArgumentMatch(f : (Int) -> String, SUCCESS) -// !ARG_3: ArgumentMatch(g : (String) -> Int, SUCCESS) fun foo(t: T, f: (T) -> S, g: (S) -> R) {} diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.txt new file mode 100644 index 00000000000..7231979ad16 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/chainedLambdas.txt @@ -0,0 +1,21 @@ +// !CALL: foo + +fun foo(t: T, f: (T) -> S, g: (S) -> R) {} + + +fun test() { + foo(1, { x -> "$x"}, { y -> y.length }) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS t : Int = 1 +SUCCESS f : (Int) -> String = { x -> "$x"} +SUCCESS g : (String) -> Int = { y -> y.length } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.kt index debba6f2c77..12a4c1f83ba 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.kt @@ -1,10 +1,7 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentMatch(f : () -> ???, UNINFERRED_TYPE_IN_PARAMETER) fun foo(f: () -> T) {} - fun test() { foo { b } } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.txt new file mode 100644 index 00000000000..ffcccf2acdd --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaReturnType.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo(f: () -> T) {} + +fun test() { + foo { b } +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +MATCH_MODULO_UNINFERRED_TYPES f : () -> ??? = { b } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.kt index 85266c9a74c..27e14388898 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.kt @@ -1,10 +1,7 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentMatch(f : (???) -> String, UNINFERRED_TYPE_IN_PARAMETER) fun foo(f: (T) -> String) {} - fun test() { foo { x -> "$x"} } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.txt new file mode 100644 index 00000000000..9c2fd484423 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/notInferredLambdaType.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo(f: (T) -> String) {} + +fun test() { + foo { x -> "$x"} +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +MATCH_MODULO_UNINFERRED_TYPES f : (???) -> String = { x -> "$x"} \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt index d41b9183940..b56ad44c1d4 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.kt @@ -1,10 +1,7 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentMatch(f : (Int) -> String, SUCCESS) fun foo(f: (T) -> String) {} - fun test() { foo { (x: Int) -> "$x"} } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt new file mode 100644 index 00000000000..ba18f5ecc06 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleGenericLambda.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo(f: (T) -> String) {} + +fun test() { + foo { (x: Int) -> "$x"} +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS f : (Int) -> String = { (x: Int) -> "$x"} \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.kt index 8b0dd255467..0c7dd89422b 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.kt @@ -1,10 +1,7 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentMatch(f : (Int) -> String, SUCCESS) fun foo(f: (Int) -> String) {} - fun test() { foo { x -> "$x"} } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.txt new file mode 100644 index 00000000000..32f2a0e03e5 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/simpleLambda.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo(f: (Int) -> String) {} + +fun test() { + foo { x -> "$x"} +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS f : (Int) -> String = { x -> "$x"} \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.kt b/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.kt index d06718d3308..ab11c610ddb 100644 --- a/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.kt +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: ArgumentUnmapped fun foo() {} diff --git a/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.txt b/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.txt new file mode 100644 index 00000000000..aad1673179e --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/functionLiterals/unmappedLambda.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo() {} + +fun test() { + foo { x -> "$x"} +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +ARGUMENT UNMAPPED: { x -> "$x"} \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.kt b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.kt index 20dac3b0885..680161c97d0 100644 --- a/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.kt +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.kt @@ -1,7 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: 11 = ArgumentMatch(t : Comparable, SUCCESS) -// !ARG_2: ls = ArgumentMatch(l : List>, SUCCESS) fun foo(t: T, l: List) {} diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt new file mode 100644 index 00000000000..cc5180811f4 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt @@ -0,0 +1,21 @@ +// !CALL: foo + +fun foo(t: T, l: List) {} + +fun use(vararg a: Any?) = a + +fun test(a: Any, ls: List) { + use(foo(11, ls)) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS t : Comparable = 11 +SUCCESS l : List> = ls \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.kt b/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.kt index 8261fbfe47b..5a7733044ba 100644 --- a/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.kt +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: A() = ArgumentMatch(t : A, SUCCESS) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.txt b/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.txt new file mode 100644 index 00000000000..570393ab6f4 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/simpleGeneric.txt @@ -0,0 +1,20 @@ +// !CALL: foo + +class A {} + +fun foo(t: T) {} + +fun bar() { + foo(A()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS t : A = A() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.kt b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.kt index 35dd7d38ad3..0f5861ca1d5 100644 --- a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.kt +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.kt @@ -1,7 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: 11 = ArgumentMatch(t : ???, UNINFERRED_TYPE_IN_PARAMETER) -// !ARG_2: ls = ArgumentMatch(l : MutableList, UNINFERRED_TYPE_IN_PARAMETER) fun foo(t: T, l: MutableList) {} diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.txt b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.txt new file mode 100644 index 00000000000..c6fc212243c --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameter.txt @@ -0,0 +1,21 @@ +// !CALL: foo + +fun foo(t: T, l: MutableList) {} + +fun use(vararg a: Any?) = a + +fun test(ls: MutableList) { + use(foo(11, ls)) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +MATCH_MODULO_UNINFERRED_TYPES t : ??? = 11 +MATCH_MODULO_UNINFERRED_TYPES l : MutableList = ls \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.kt b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.kt index f858de84dc3..f24ac60f881 100644 --- a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.kt +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: 11 = ArgumentMatch(l : List, TYPE_MISMATCH) fun foo(l: List) {} diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.txt b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.txt new file mode 100644 index 00000000000..382692b58fc --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/uninferredParameterTypeMismatch.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo(l: List) {} + +fun test() { + foo(11) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +TYPE_MISMATCH l : List = 11 \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.kt b/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.kt index 4837855354b..c42618de1f2 100644 --- a/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.kt +++ b/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.kt @@ -1,7 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: B() = ArgumentMatch(b : B, SUCCESS) -// !ARG_2: A() = ArgumentUnmapped class A {} class B {} diff --git a/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.txt b/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.txt new file mode 100644 index 00000000000..c177029725a --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/namedArguments/positionedAfterNamed.txt @@ -0,0 +1,22 @@ +// !CALL: foo + +class A {} +class B {} + +fun foo(a: A, b: B) {} + +fun bar() { + foo(b = B(), A()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS b : B = B() +ARGUMENT UNMAPPED: A() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.kt b/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.kt index f14f2b5aea9..1971907315d 100644 --- a/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.kt +++ b/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.kt @@ -1,7 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: B() = ArgumentMatch(b : B, SUCCESS) -// !ARG_2: A() = ArgumentMatch(a : A, SUCCESS) class A {} class B {} diff --git a/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.txt b/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.txt new file mode 100644 index 00000000000..14b9c67626a --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/namedArguments/shiftedArgsMatch.txt @@ -0,0 +1,22 @@ +// !CALL: foo + +class A {} +class B {} + +fun foo(a: A, b: B) {} + +fun bar() { + foo(b = B(), a = A()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS b : B = B() +SUCCESS a : A = A() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.kt b/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.kt index 4eafe86e688..0f257a797ec 100644 --- a/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.kt +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: b = ArgumentMatch(a : A, ARGUMENT_HAS_NO_TYPE) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.txt b/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.txt new file mode 100644 index 00000000000..55463da60cc --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/argumentHasNoType.txt @@ -0,0 +1,20 @@ +// !CALL: foo + +class A {} + +fun foo(a: A) {} + +fun bar() { + foo(b) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +ARGUMENT_HAS_NO_TYPE a : A = b \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.kt b/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.kt index 2de151ffeda..1c539e8a7fc 100644 --- a/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.kt +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: A() = ArgumentMatch(a : A, SUCCESS) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.txt b/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.txt new file mode 100644 index 00000000000..ee64e966f6a --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/simpleMatch.txt @@ -0,0 +1,20 @@ +// !CALL: foo + +class A {} + +fun foo(a: A) {} + +fun bar() { + foo(A()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS a : A = A() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.kt b/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.kt index 38c0bf6c254..2bbc989a2cf 100644 --- a/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.kt +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: "" = ArgumentMatch(a : A, TYPE_MISMATCH) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.txt b/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.txt new file mode 100644 index 00000000000..de38d1a98c5 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/typeMismatch.txt @@ -0,0 +1,20 @@ +// !CALL: foo + +class A {} + +fun foo(a: A) {} + +fun bar() { + foo("") +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +TYPE_MISMATCH a : A = "" \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.kt b/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.kt index 6a7f2def715..bfdb7ab34d7 100644 --- a/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.kt +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: "" = ArgumentUnmapped fun foo() {} diff --git a/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.txt b/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.txt new file mode 100644 index 00000000000..44cd69c3822 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/oneArgument/unmappedArgument.txt @@ -0,0 +1,18 @@ +// !CALL: foo + +fun foo() {} + +fun bar() { + foo("") +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +ARGUMENT UNMAPPED: "" \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.kt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.kt index 662ece19587..126f409b36e 100644 --- a/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.kt +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: emptyList() = ArgumentMatch(t : List, UNINFERRED_TYPE_IN_PARAMETER) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt new file mode 100644 index 00000000000..78f56871520 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt @@ -0,0 +1,22 @@ +// !CALL: foo + +class A {} + +fun foo(t: T) {} + +fun emptyList(): List = throw Exception() + +fun bar() { + foo(emptyList()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +MATCH_MODULO_UNINFERRED_TYPES t : List = emptyList() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.kt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.kt index 9fc04836659..188e94324aa 100644 --- a/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.kt +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.kt @@ -1,6 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: emptyList() = ArgumentMatch(t : MutableList, UNINFERRED_TYPE_IN_PARAMETER) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt new file mode 100644 index 00000000000..e7a39096d91 --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt @@ -0,0 +1,22 @@ +// !CALL: foo + +class A {} + +fun foo(t: T) {} + +fun emptyList(): MutableList = throw Exception() + +fun bar() { + foo(emptyList()) +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +MATCH_MODULO_UNINFERRED_TYPES t : MutableList = emptyList() \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.kt b/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.kt index 2c65f7e1949..9a8f7d5d5b8 100644 --- a/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.kt +++ b/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.kt @@ -1,7 +1,4 @@ -// !ONLY_ARGUMENTS // !CALL: foo -// !ARG_1: A() = ArgumentMatch(a : A, SUCCESS) -// !ARG_2: "" = ArgumentMatch(s : String, SUCCESS) class A {} diff --git a/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.txt b/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.txt new file mode 100644 index 00000000000..2c9fc57df6f --- /dev/null +++ b/compiler/testData/resolvedCalls/arguments/severalCandidates/mostSpecific.txt @@ -0,0 +1,23 @@ +// !CALL: foo + +class A {} + +fun foo(a: A) {} +fun foo(a: A, s: String) {} +fun foo(a: A, any: Any) {} + +fun bar() { + foo(A(), "") +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS a : A = A() +SUCCESS s : String = "" \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.kt b/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.kt index a29a87c99a7..03668ab7c84 100644 --- a/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.kt +++ b/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT -// !THIS_OBJECT: NO_RECEIVER -// !RECEIVER_ARGUMENT: a class A {} diff --git a/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.txt b/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.txt new file mode 100644 index 00000000000..c9ab1a45887 --- /dev/null +++ b/compiler/testData/resolvedCalls/explicitReceiverIsReceiverArgument.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +class A {} + +fun A.foo() {} + +fun bar(a: A) { + a.foo() +} + + +Resolved call: + +Explicit receiver kind = RECEIVER_ARGUMENT +This object = NO_RECEIVER +Receiver argument = a \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.kt b/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.kt index 85fcb2e3b5c..a682a5c5268 100644 --- a/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.kt +++ b/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: a -// !RECEIVER_ARGUMENT: NO_RECEIVER class A { fun foo() {} diff --git a/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.txt b/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.txt new file mode 100644 index 00000000000..628ee173498 --- /dev/null +++ b/compiler/testData/resolvedCalls/explicitReceiverIsThisObject.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +class A { + fun foo() {} +} + +fun bar(a: A) { + a.foo() +} + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = a +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.kt b/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.kt index 228db5f50df..427392a2dca 100644 --- a/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.kt +++ b/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS -// !THIS_OBJECT: f -// !RECEIVER_ARGUMENT: 1 fun bar(f: Int.()->Unit) { 1.f() diff --git a/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.txt b/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.txt new file mode 100644 index 00000000000..b15d976157a --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/invokeForExtensionFunctionType.txt @@ -0,0 +1,12 @@ +// !CALL: invoke + +fun bar(f: Int.()->Unit) { + 1.f() +} + + +Resolved call: + +Explicit receiver kind = BOTH_RECEIVERS +This object = f +Receiver argument = 1 \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.kt b/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.kt index 6c37cc9dbda..11989964af1 100644 --- a/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.kt +++ b/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: f -// !RECEIVER_ARGUMENT: NO_RECEIVER fun bar(f: ()->Unit) { f() diff --git a/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.txt b/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.txt new file mode 100644 index 00000000000..5fbbc770795 --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/invokeForFunctionType.txt @@ -0,0 +1,12 @@ +// !CALL: invoke + +fun bar(f: ()->Unit) { + f() +} + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = f +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.kt b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.kt index 837db84c8f6..496841ebd8d 100644 --- a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.kt +++ b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: Class{A} -// !RECEIVER_ARGUMENT: NO_RECEIVER trait A { val foo: Int.()->Unit diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.txt b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.txt new file mode 100644 index 00000000000..566a63f0ff2 --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionType.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +trait A { + val foo: Int.()->Unit + + fun test() { + 1.foo() + } +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = Class{A} +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.kt b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.kt index 53464c75bfd..d07a5c2b8b8 100644 --- a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.kt +++ b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS -// !THIS_OBJECT: foo -// !RECEIVER_ARGUMENT: 1 trait A { val foo: Int.()->Unit diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.txt b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.txt new file mode 100644 index 00000000000..4458bd0cb10 --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/valOfExtensionFunctionTypeInvoke.txt @@ -0,0 +1,16 @@ +// !CALL: invoke + +trait A { + val foo: Int.()->Unit + + fun test() { + 1.foo() + } +} + + +Resolved call: + +Explicit receiver kind = BOTH_RECEIVERS +This object = foo +Receiver argument = 1 \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.kt b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.kt index 86af46416ac..871254e1d7a 100644 --- a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.kt +++ b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: a -// !RECEIVER_ARGUMENT: NO_RECEIVER trait A { val foo: (Int)->Int diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.txt b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.txt new file mode 100644 index 00000000000..26796310fdd --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionType.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +trait A { + val foo: (Int)->Int +} + +fun test(a: A) { + a.foo(1) +} + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = a +Receiver argument = NO_RECEIVER diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.kt b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.kt index 9b9c8079d13..dda6f5901c3 100644 --- a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.kt +++ b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: foo -// !RECEIVER_ARGUMENT: NO_RECEIVER trait A { val foo: (Int)->Int diff --git a/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.txt b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.txt new file mode 100644 index 00000000000..58835e53448 --- /dev/null +++ b/compiler/testData/resolvedCalls/functionTypes/valOfFunctionTypeInvoke.txt @@ -0,0 +1,20 @@ +// !CALL: invoke + +trait A { + val foo: (Int)->Int +} + +fun test(a: A) { + a.foo(1) +} + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = foo +Receiver argument = NO_RECEIVER + +Value arguments mapping: + +SUCCESS p1 : Int = 1 \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.kt b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.kt index 2369b1a54bd..486ac05e8cb 100644 --- a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.kt +++ b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT -// !THIS_OBJECT: A -// !RECEIVER_ARGUMENT: b class A { fun B.foo() {} diff --git a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.txt b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.txt new file mode 100644 index 00000000000..d8a6832dc88 --- /dev/null +++ b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgument.txt @@ -0,0 +1,22 @@ +// !CALL: foo + +class A { + fun B.foo() {} +} + +trait B + +fun bar(a: A, b: B) { + with (a) { + b.foo() + } +} + +fun with(receiver: T, f: T.() -> R) : R = receiver.f() + + +Resolved call: + +Explicit receiver kind = RECEIVER_ARGUMENT +This object = A +Receiver argument = b \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt index 17ef0f72d9b..7958ac03456 100644 --- a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt +++ b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: A -// !RECEIVER_ARGUMENT: B class A { fun B.foo() {} diff --git a/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.txt b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.txt new file mode 100644 index 00000000000..687d5f57d69 --- /dev/null +++ b/compiler/testData/resolvedCalls/hasBothThisObjectAndReceiverArgumentWithoutExplicitReceiver.txt @@ -0,0 +1,24 @@ +// !CALL: foo + +class A { + fun B.foo() {} +} + +trait B + +fun bar(a: A, b: B) { + with (a) { + with (b) { + foo() + } + } +} + +fun with(receiver: T, f: T.() -> R) : R = receiver.f() + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = A +Receiver argument = B \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.kt b/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.kt index d59a3daf2e3..1af661a1964 100644 --- a/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.kt +++ b/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: NO_RECEIVER -// !RECEIVER_ARGUMENT: A class A {} diff --git a/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.txt b/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.txt new file mode 100644 index 00000000000..b1e77032006 --- /dev/null +++ b/compiler/testData/resolvedCalls/implicitReceiverIsReceiverArgument.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +class A {} + +fun A.foo() {} + +fun A.bar() { + foo() +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = A \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.kt b/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.kt index d6d17c1e268..9f58e24c51f 100644 --- a/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.kt +++ b/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: A -// !RECEIVER_ARGUMENT: NO_RECEIVER class A { fun foo() {} diff --git a/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.txt b/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.txt new file mode 100644 index 00000000000..d4198a0ed2e --- /dev/null +++ b/compiler/testData/resolvedCalls/implicitReceiverIsThisObject.txt @@ -0,0 +1,16 @@ +// !CALL: foo + +class A { + fun foo() {} +} + +fun A.bar() { + foo() +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = A +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.kt b/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.kt index 57dee9f5a58..b592edc9290 100644 --- a/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.kt +++ b/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: Class{A} -// !RECEIVER_ARGUMENT: NO_RECEIVER class A { fun foo() {} diff --git a/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.txt b/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.txt new file mode 100644 index 00000000000..149c4f1d712 --- /dev/null +++ b/compiler/testData/resolvedCalls/impliedThisNoExplicitReceiver.txt @@ -0,0 +1,15 @@ +// !CALL: foo + +class A { + fun foo() {} + fun bar() { + foo() + } +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = Class{A} +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/invoke/bothReceivers.kt b/compiler/testData/resolvedCalls/invoke/bothReceivers.kt index 4d66d303456..5f7fb781e35 100644 --- a/compiler/testData/resolvedCalls/invoke/bothReceivers.kt +++ b/compiler/testData/resolvedCalls/invoke/bothReceivers.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: BOTH_RECEIVERS -// !THIS_OBJECT: f -// !RECEIVER_ARGUMENT: 1 class Foo() { fun Int.invoke() {} diff --git a/compiler/testData/resolvedCalls/invoke/bothReceivers.txt b/compiler/testData/resolvedCalls/invoke/bothReceivers.txt new file mode 100644 index 00000000000..7f839d2538e --- /dev/null +++ b/compiler/testData/resolvedCalls/invoke/bothReceivers.txt @@ -0,0 +1,16 @@ +// !CALL: invoke + +class Foo() { + fun Int.invoke() {} +} + +fun bar(f: Foo) { + 1.f() +} + + +Resolved call: + +Explicit receiver kind = BOTH_RECEIVERS +This object = f +Receiver argument = 1 \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.kt b/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.kt index 79aa259fabc..739996ce04c 100644 --- a/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.kt +++ b/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: f -// !RECEIVER_ARGUMENT: Int class Foo() { fun Int.invoke() {} diff --git a/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.txt b/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.txt new file mode 100644 index 00000000000..b3d65cf6105 --- /dev/null +++ b/compiler/testData/resolvedCalls/invoke/implicitReceiverForInvoke.txt @@ -0,0 +1,20 @@ +// !CALL: invoke + +class Foo() { + fun Int.invoke() {} +} + +fun bar(f: Foo, i: Int) { + with (i) { + f() + } +} + +fun with(receiver: T, f: T.() -> R) : R = throw Exception() + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = f +Receiver argument = Int \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.kt b/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.kt index a10dd8fa922..5c33054ca99 100644 --- a/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.kt +++ b/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT -// !THIS_OBJECT: NO_RECEIVER -// !RECEIVER_ARGUMENT: f class Foo fun Foo.invoke() {} diff --git a/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.txt b/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.txt new file mode 100644 index 00000000000..a6f02983a09 --- /dev/null +++ b/compiler/testData/resolvedCalls/invoke/receiverArgumentAsReceiverForInvoke.txt @@ -0,0 +1,15 @@ +// !CALL: invoke + +class Foo +fun Foo.invoke() {} + +fun bar(f: Foo) { + f() +} + + +Resolved call: + +Explicit receiver kind = RECEIVER_ARGUMENT +This object = NO_RECEIVER +Receiver argument = f \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.kt b/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.kt index 85cf906098a..aa49c2a2788 100644 --- a/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.kt +++ b/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.kt @@ -1,7 +1,4 @@ // !CALL: invoke -// !EXPLICIT_RECEIVER_KIND: THIS_OBJECT -// !THIS_OBJECT: f -// !RECEIVER_ARGUMENT: NO_RECEIVER class Foo { fun invoke() {} diff --git a/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.txt b/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.txt new file mode 100644 index 00000000000..172096c4f8c --- /dev/null +++ b/compiler/testData/resolvedCalls/invoke/thisObjectAsReceiverForInvoke.txt @@ -0,0 +1,16 @@ +// !CALL: invoke + +class Foo { + fun invoke() {} +} + +fun bar(f: Foo) { + f() +} + + +Resolved call: + +Explicit receiver kind = THIS_OBJECT +This object = f +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt index 89fd399974a..7b1b5701c1e 100644 --- a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt +++ b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.kt @@ -1,7 +1,4 @@ // !CALL: + -// !EXPLICIT_RECEIVER_KIND: RECEIVER_ARGUMENT -// !THIS_OBJECT: Title -// !RECEIVER_ARGUMENT: "Foo" trait Element { fun render(builder: StringBuilder, indent: String) diff --git a/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt new file mode 100644 index 00000000000..634172c794b --- /dev/null +++ b/compiler/testData/resolvedCalls/realExamples/stringPlusInBuilders.txt @@ -0,0 +1,48 @@ +// !CALL: + + +trait Element { + fun render(builder: StringBuilder, indent: String) +} + +class TextElement(val text: String): Element { + override fun render(builder: StringBuilder, indent: String): Unit = fail +} + +abstract class Tag(val name: String): Element { + protected fun initTag(tag: T, init: T.() -> Unit): T = fail + + override fun render(builder: StringBuilder, indent: String): Unit = fail +} + +abstract class TagWithText(name: String): Tag(name) { + fun String.plus() {} +} + +class HTML(): TagWithText("html") { + fun head(init: Head.() -> Unit): Head = fail + +} + +class Head(): TagWithText("head") { + fun title(init: Title.() -> Unit): Title = fail +} + +class Title(): TagWithText("title") + +fun html(init: HTML.() -> Unit): HTML = fail + +fun result() = + html { + head { + title {+"Foo"} + } + } + +val fail: Nothing get() = throw Exception() + + +Resolved call: + +Explicit receiver kind = RECEIVER_ARGUMENT +This object = Title +Receiver argument = "Foo" \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/simpleCall.kt b/compiler/testData/resolvedCalls/simpleCall.kt index 7d7c5ed6fce..52dc57ee54a 100644 --- a/compiler/testData/resolvedCalls/simpleCall.kt +++ b/compiler/testData/resolvedCalls/simpleCall.kt @@ -1,7 +1,4 @@ // !CALL: foo -// !EXPLICIT_RECEIVER_KIND: NO_EXPLICIT_RECEIVER -// !THIS_OBJECT: NO_RECEIVER -// !RECEIVER_ARGUMENT: NO_RECEIVER fun foo() {} diff --git a/compiler/testData/resolvedCalls/simpleCall.txt b/compiler/testData/resolvedCalls/simpleCall.txt new file mode 100644 index 00000000000..9c60caad578 --- /dev/null +++ b/compiler/testData/resolvedCalls/simpleCall.txt @@ -0,0 +1,14 @@ +// !CALL: foo + +fun foo() {} + +fun bar() { + foo() +} + + +Resolved call: + +Explicit receiver kind = NO_EXPLICIT_RECEIVER +This object = NO_RECEIVER +Receiver argument = NO_RECEIVER \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/resolve/calls/AbstractResolvedCallsTest.kt b/compiler/tests/org/jetbrains/jet/resolve/calls/AbstractResolvedCallsTest.kt index 78aef0b7c4d..f0d8e85a92d 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/calls/AbstractResolvedCallsTest.kt +++ b/compiler/tests/org/jetbrains/jet/resolve/calls/AbstractResolvedCallsTest.kt @@ -20,26 +20,23 @@ import org.jetbrains.jet.ConfigurationKind import org.jetbrains.jet.JetLiteFixture import org.jetbrains.jet.JetTestUtils import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment -import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils import org.jetbrains.jet.lang.psi.JetElement import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall -import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.jet.lang.resolve.scopes.receivers.AbstractReceiverValue import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue import java.io.File -import kotlin.test.assertEquals import kotlin.test.assertTrue import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil -import java.util.ArrayList import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch -import org.jetbrains.jet.lang.diagnostics.rendering.Renderers import org.jetbrains.jet.lang.resolve.calls.util.getAllValueArguments import org.jetbrains.jet.renderer.DescriptorRenderer +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.jet.lang.psi.ValueArgument public abstract class AbstractResolvedCallsTest() : JetLiteFixture() { override fun createEnvironment(): JetCoreEnvironment = createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY) @@ -49,11 +46,7 @@ public abstract class AbstractResolvedCallsTest() : JetLiteFixture() { val text = JetTestUtils.doLoadFile(file) val directives = JetTestUtils.parseDirectives(text) - val onlyArguments = directives.onlyArguments() - val (callName, thisObject, receiverArgument) = with (directives) { - Triple(get("CALL"), get("THIS_OBJECT"), get("RECEIVER_ARGUMENT")) - } - val explicitReceiverKind = directives.getExplicitReceiverKind() + val callName = directives["CALL"] fun analyzeFileAndGetResolvedCallEntries(): Map> { val psiFile = JetTestUtils.loadJetFile(getProject(), file)!! @@ -62,114 +55,63 @@ public abstract class AbstractResolvedCallsTest() : JetLiteFixture() { return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL) } - fun checkResolvedCall(resolvedCall: ResolvedCall<*>, element: JetElement) { - if (onlyArguments) return - - val lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange()) - - val (actualThisObject, actualReceiverArgument, actualExplicitReceiverKind) = with(resolvedCall) { - Triple(getThisObject().getText(), getReceiverArgument().getText(), getExplicitReceiverKind()) - } - val actualDataMessage = "Actual data:\nThis object: $actualThisObject. Receiver argument: $actualReceiverArgument. " + - "Explicit receiver kind: $actualExplicitReceiverKind.\n" - - assertEquals(thisObject, actualThisObject, "${actualDataMessage}This object mismatch: ") - assertEquals(receiverArgument, actualReceiverArgument, "${actualDataMessage}Receiver argument mismatch: ") - assertEquals(explicitReceiverKind, actualExplicitReceiverKind, - "$actualDataMessage" + - "Explicit receiver kind for resolved call for '${element.getText()}'$lineAndColumn in not as expected") - } - - val argumentsExpectedData = directives.getArgumentsExpectedData() - fun checkArguments(resolvedCall: ResolvedCall<*>) { - if (argumentsExpectedData.isEmpty()) return - - for ((index, valueArgument) in resolvedCall.getCall().getAllValueArguments().withIndices()) { - val (argText, argumentMapping) = argumentsExpectedData[index] - if (argText != null) { - assertEquals(argText, valueArgument.getArgumentExpression()!!.getText(), - "An argument expression is incorrect") - } - assertEquals(argumentMapping, resolvedCall.getArgumentMapping(valueArgument).print(), - "Argument mapping is incorrect") - } - } - var callFound = false + fun tryCall(resolvedCall: ResolvedCall<*>, actualName: String?) { + if (callName == null || callName != actualName) return + callFound = true + + val resolvedCallInfoFileName = FileUtil.getNameWithoutExtension(filePath) + ".txt" + JetTestUtils.assertEqualsToFile(File(resolvedCallInfoFileName), "$text\n\n\n${resolvedCall.renderToText()}") + } + for ((element, resolvedCall) in analyzeFileAndGetResolvedCallEntries()) { - - fun tryCall(resolvedCall: ResolvedCall<*>, actualName: String? = element.getText()) { - if (callName == null || callName != actualName) return - callFound = true - checkResolvedCall(resolvedCall, element) - checkArguments(resolvedCall) - } - if (resolvedCall is VariableAsFunctionResolvedCall) { tryCall(resolvedCall.functionCall, "invoke") - tryCall(resolvedCall.variableCall) + tryCall(resolvedCall.variableCall, element.getText()) } else { - tryCall(resolvedCall) + tryCall(resolvedCall, element.getText()) } } assertTrue(callFound, "Resolved call for $callName was not found") } } -private fun ReceiverValue.getText() = - if (this is ExpressionReceiver) { - this.getExpression().getText() - } - else if (this is AbstractReceiverValue) { - this.getType().toString() - } - else toString() - -private val EXPLICIT_RECEIVER_KIND_DIRECTIVE: String = "EXPLICIT_RECEIVER_KIND" -private fun Map.getExplicitReceiverKind(): ExplicitReceiverKind? { - if (onlyArguments()) return null - - val explicitReceiverKind = get(EXPLICIT_RECEIVER_KIND_DIRECTIVE) - assert(explicitReceiverKind != null) { "$EXPLICIT_RECEIVER_KIND_DIRECTIVE should be present." } - try { - return ExplicitReceiverKind.valueOf(explicitReceiverKind!!) - } - catch (e: IllegalArgumentException) { - val message = StringBuilder() - message.append("$EXPLICIT_RECEIVER_KIND_DIRECTIVE must be one of the following: ") - for (kind in ExplicitReceiverKind.values()) { - message.append("$kind, ") - } - message.append("\nnot $explicitReceiverKind.") - throw AssertionError(message) - } +private fun ReceiverValue.getText() = when (this) { + is ExpressionReceiver -> getExpression().getText() + is AbstractReceiverValue -> getType().toString() + else -> toString() } -private fun Map.getArgumentsExpectedData(): List> { - val result = ArrayList>() - for (i in 1..7) { - val argData = get("ARG_$i") - if (argData == null) continue +private fun ValueArgument.getText() = this.getArgumentExpression()?.getText()?.replace("\n", " ") ?: "" - if (argData.contains("=")) { - val strings = argData.split("=") - assert(strings.size == 2, "Incorrect input data for an argument ARG_$i : $argData") - result.add(Pair(strings[0].trim(), strings[1].trim())) - } - else { - result.add(Pair(null, argData)) - } - } - return result -} - -private fun Map.onlyArguments() = containsKey("ONLY_ARGUMENTS") - -fun ArgumentMapping.print() = when (this) { +private fun ArgumentMapping.getText() = when (this) { is ArgumentMatch -> { val parameterType = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(valueParameter.getType()) - "ArgumentMatch(${valueParameter.getName()} : ${parameterType}, ${status.name()})" + "${status.name()} ${valueParameter.getName()} : ${parameterType} =" } - else -> "ArgumentUnmapped" + else -> "ARGUMENT UNMAPPED: " +} + +private fun ResolvedCall<*>.renderToText(): String { + val result = StringBuilder() + fun addLine(line: String) = result.append(line).append("\n") + + addLine("Resolved call:\n") + addLine("Explicit receiver kind = ${getExplicitReceiverKind()}") + addLine("This object = ${getThisObject().getText()}") + addLine("Receiver argument = ${getReceiverArgument().getText()}") + + val valueArguments = getCall().getAllValueArguments() + if (valueArguments.isEmpty()) return result.toString() + + addLine("\nValue arguments mapping:\n") + + for (valueArgument in valueArguments) { + val argumentText = valueArgument.getText() + val argumentMappingText = getArgumentMapping(valueArgument).getText() + + addLine("$argumentMappingText $argumentText") + } + return result.toString() } \ No newline at end of file