Render candidate and resulting descriptors in resolved call tests
This commit is contained in:
@@ -8,6 +8,9 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T, S, R> foo(t: T, f: (T) -> S, g: (S) -> R): Unit
|
||||
Resulting descriptor: fun <T, S, R> foo(t: Int, f: (Int) -> String, g: (String) -> Int): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
+3
@@ -7,6 +7,9 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(f: () -> T): Unit
|
||||
Resulting descriptor: fun <T> foo(f: () -> ???): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -7,6 +7,9 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(f: (T) -> String): Unit
|
||||
Resulting descriptor: fun <T> foo(f: (???) -> String): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -7,6 +7,9 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(f: (T) -> String): Unit
|
||||
Resulting descriptor: fun <T> foo(f: (Int) -> String): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -7,6 +7,8 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(f: (Int) -> String): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -7,6 +7,8 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,9 @@ fun test(a: Any, ls: List<String>) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(t: T, l: List<T>): Unit
|
||||
Resulting descriptor: fun <T> foo(t: Comparable<out Any?>, l: List<Comparable<out Any?>>): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,9 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(t: T): Unit
|
||||
Resulting descriptor: fun <T> foo(t: A): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,9 @@ fun test(ls: MutableList<String>) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(t: T, l: MutableList<T>): Unit
|
||||
Resulting descriptor: fun <T> foo(t: ???, l: MutableList<???>): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
+3
@@ -7,6 +7,9 @@ fun test() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(l: List<T>): Unit
|
||||
Resulting descriptor: fun <T> foo(l: List<???>): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -10,6 +10,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A, b: B): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -10,6 +10,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A, b: B): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -7,6 +7,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -11,6 +11,9 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(t: T): Unit
|
||||
Resulting descriptor: fun <T> foo(t: List<???>): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -11,6 +11,9 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Candidate descriptor: fun <T> foo(t: T): Unit
|
||||
Resulting descriptor: fun <T> foo(t: MutableList<???>): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -11,6 +11,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(a: A, s: String): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar(a: A) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun A.foo(): Unit
|
||||
|
||||
Explicit receiver kind = RECEIVER_ARGUMENT
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = a
|
||||
Receiver argument = a {A}
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar(a: A) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = a
|
||||
This object = a {A}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -5,6 +5,8 @@ fun bar(f: Int.()->Unit) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun Int.invoke(): Unit
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
This object = f
|
||||
Receiver argument = 1
|
||||
This object = f {ExtensionFunction0<Int, Unit>}
|
||||
Receiver argument = 1 {Int}
|
||||
|
||||
@@ -5,6 +5,8 @@ fun bar(f: ()->Unit) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun invoke(): Unit
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = f
|
||||
This object = f {Function0<Unit>}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -9,6 +9,8 @@ trait A {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: val foo: Int.() -> Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = Class{A}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -9,6 +9,8 @@ trait A {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun Int.invoke(): Unit
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
This object = foo
|
||||
Receiver argument = 1
|
||||
This object = foo {ExtensionFunction0<Int, Unit>}
|
||||
Receiver argument = 1 {Int}
|
||||
|
||||
@@ -9,6 +9,8 @@ fun test(a: A) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: val foo: (Int) -> Int
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = a
|
||||
Receiver argument = NO_RECEIVER
|
||||
This object = a {A}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -9,8 +9,10 @@ fun test(a: A) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun invoke(p1: Int): Int
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = foo
|
||||
This object = foo {Function1<Int, Int>}
|
||||
Receiver argument = NO_RECEIVER
|
||||
|
||||
Value arguments mapping:
|
||||
|
||||
@@ -15,6 +15,8 @@ fun <T, R> with(receiver: T, f: T.() -> R) : R = receiver.f()
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun B.foo(): Unit
|
||||
|
||||
Explicit receiver kind = RECEIVER_ARGUMENT
|
||||
This object = A
|
||||
Receiver argument = b
|
||||
This object = AExt{fun A.<anonymous>(): Unit}
|
||||
Receiver argument = b {B}
|
||||
|
||||
+4
-2
@@ -17,6 +17,8 @@ fun <T, R> with(receiver: T, f: T.() -> R) : R = receiver.f()
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun B.foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = A
|
||||
Receiver argument = B
|
||||
This object = AExt{fun A.<anonymous>(): Unit}
|
||||
Receiver argument = BExt{fun B.<anonymous>(): Unit}
|
||||
|
||||
@@ -9,6 +9,8 @@ fun A.bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun A.foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = A
|
||||
Receiver argument = AExt{fun A.bar(): Unit}
|
||||
|
||||
@@ -9,6 +9,8 @@ fun A.bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = A
|
||||
This object = AExt{fun A.bar(): Unit}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -8,6 +8,8 @@ class A {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = Class{A}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -9,6 +9,8 @@ fun bar(f: Foo) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun Int.invoke(): Unit
|
||||
|
||||
Explicit receiver kind = BOTH_RECEIVERS
|
||||
This object = f
|
||||
Receiver argument = 1
|
||||
This object = f {Foo}
|
||||
Receiver argument = 1 {Int}
|
||||
|
||||
@@ -13,6 +13,8 @@ fun <T, R> with(receiver: T, f: T.() -> R) : R = throw Exception()
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun Int.invoke(): Unit
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = f
|
||||
Receiver argument = Int
|
||||
This object = f {Foo}
|
||||
Receiver argument = IntExt{fun Int.<anonymous>(): Unit}
|
||||
|
||||
@@ -8,6 +8,8 @@ fun bar(f: Foo) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun Foo.invoke(): Unit
|
||||
|
||||
Explicit receiver kind = RECEIVER_ARGUMENT
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = f
|
||||
Receiver argument = f {Foo}
|
||||
|
||||
@@ -9,6 +9,8 @@ fun bar(f: Foo) {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun invoke(): Unit
|
||||
|
||||
Explicit receiver kind = THIS_OBJECT
|
||||
This object = f
|
||||
This object = f {Foo}
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -41,6 +41,8 @@ val fail: Nothing get() = throw Exception()
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun String.plus(): Unit
|
||||
|
||||
Explicit receiver kind = RECEIVER_ARGUMENT
|
||||
This object = Title
|
||||
Receiver argument = "Foo"
|
||||
This object = TitleExt{fun Title.<anonymous>(): Unit}
|
||||
Receiver argument = "Foo" {String}
|
||||
|
||||
@@ -7,6 +7,8 @@ fun bar() {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): Unit
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -7,6 +7,8 @@ class A {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: Class{A}::this
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -7,6 +7,8 @@ class A {
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: Class{A}::this
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -7,6 +7,8 @@ fun A.bar() = <caret>this.foo()
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: AExt{fun A.bar(): Unit}::this
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
Receiver argument = NO_RECEIVER
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.jet.JetLiteFixture
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
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
|
||||
|
||||
@@ -38,6 +37,10 @@ import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getParentResolvedCall
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver
|
||||
|
||||
public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
|
||||
override fun createEnvironment(): JetCoreEnvironment = createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY)
|
||||
@@ -63,8 +66,9 @@ public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
|
||||
}
|
||||
|
||||
private fun ReceiverValue.getText() = when (this) {
|
||||
is ExpressionReceiver -> getExpression().getText()
|
||||
is AbstractReceiverValue -> getType().toString()
|
||||
is ExpressionReceiver -> "${getExpression().getText()} {${getType()}}"
|
||||
is ClassReceiver -> "Class{${getType()}}"
|
||||
is ExtensionReceiver -> "${getType()}Ext{${getDeclarationDescriptor().getText()}}"
|
||||
else -> toString()
|
||||
}
|
||||
|
||||
@@ -78,25 +82,38 @@ private fun ArgumentMapping.getText() = when (this) {
|
||||
else -> "ARGUMENT UNMAPPED: "
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.getText(): String = when (this) {
|
||||
is ReceiverParameterDescriptor -> "${getValue().getText()}::this"
|
||||
else -> DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(this)
|
||||
}
|
||||
|
||||
private fun ResolvedCall<*>.renderToText(): String {
|
||||
val result = StringBuilder()
|
||||
fun addLine(line: String) = result.append(line).append("\n")
|
||||
return StringBuilder {
|
||||
appendln("Resolved call:")
|
||||
appendln()
|
||||
|
||||
addLine("Resolved call:\n")
|
||||
addLine("Explicit receiver kind = ${getExplicitReceiverKind()}")
|
||||
addLine("This object = ${getThisObject().getText()}")
|
||||
addLine("Receiver argument = ${getReceiverArgument().getText()}")
|
||||
if (getCandidateDescriptor() != getResultingDescriptor()) {
|
||||
appendln("Candidate descriptor: ${getCandidateDescriptor()!!.getText()}")
|
||||
}
|
||||
appendln("Resulting descriptor: ${getResultingDescriptor()!!.getText()}")
|
||||
appendln()
|
||||
|
||||
val valueArguments = getCall().getAllValueArguments()
|
||||
if (valueArguments.isEmpty()) return result.toString()
|
||||
appendln("Explicit receiver kind = ${getExplicitReceiverKind()}")
|
||||
appendln("This object = ${getThisObject().getText()}")
|
||||
appendln("Receiver argument = ${getReceiverArgument().getText()}")
|
||||
|
||||
addLine("\nValue arguments mapping:\n")
|
||||
val valueArguments = getCall().getAllValueArguments()
|
||||
if (!valueArguments.isEmpty()) {
|
||||
appendln()
|
||||
appendln("Value arguments mapping:")
|
||||
appendln()
|
||||
|
||||
for (valueArgument in valueArguments) {
|
||||
val argumentText = valueArgument.getText()
|
||||
val argumentMappingText = getArgumentMapping(valueArgument).getText()
|
||||
for (valueArgument in valueArguments) {
|
||||
val argumentText = valueArgument.getText()
|
||||
val argumentMappingText = getArgumentMapping(valueArgument).getText()
|
||||
|
||||
addLine("$argumentMappingText $argumentText")
|
||||
}
|
||||
return result.toString()
|
||||
appendln("$argumentMappingText $argumentText")
|
||||
}
|
||||
}
|
||||
}.toString()
|
||||
}
|
||||
@@ -49,6 +49,12 @@ public interface DescriptorRenderer extends Renderer<DeclarationDescriptor> {
|
||||
.setWithDefinedIn(false)
|
||||
.setModifiers().build();
|
||||
|
||||
DescriptorRenderer COMPACT_WITH_SHORT_TYPES = new DescriptorRendererBuilder()
|
||||
.setWithDefinedIn(false)
|
||||
.setModifiers()
|
||||
.setShortNames(true)
|
||||
.setIncludeSynthesizedParameterNames(false).build();
|
||||
|
||||
DescriptorRenderer STARTS_FROM_NAME = new DescriptorRendererBuilder()
|
||||
.setWithDefinedIn(false)
|
||||
.setModifiers()
|
||||
|
||||
Reference in New Issue
Block a user