Uast: implicit returns for lambda expressions (KT-32370)

This commit is contained in:
Nicolay Mitropolsky
2019-07-02 21:24:42 +03:00
parent 631a09e541
commit f85ebe7f43
25 changed files with 332 additions and 86 deletions
@@ -199,6 +199,10 @@ fun doConvertParent(element: UElement, parent: PsiElement?): UElement? {
}).expressions.single()
}
if (result is KotlinULambdaExpression.Body && element is UExpression && result.implicitReturn?.returnExpression == element) {
return result.implicitReturn!!
}
return result
}
@@ -195,6 +195,10 @@ fun doConvertParent(element: UElement, parent: PsiElement?): UElement? {
}).expressions.single()
}
if (result is KotlinULambdaExpression.Body && element is UExpression && result.implicitReturn?.returnExpression == element) {
return result.implicitReturn!!
}
return result
}
@@ -376,7 +376,15 @@ internal object KotlinConverter {
is KtContinueExpression -> expr<UContinueExpression>(build(::KotlinUContinueExpression))
is KtReturnExpression -> expr<UReturnExpression>(build(::KotlinUReturnExpression))
is KtThrowExpression -> expr<UThrowExpression>(build(::KotlinUThrowExpression))
is KtBlockExpression -> expr<UBlockExpression>(build(::KotlinUBlockExpression))
is KtBlockExpression -> expr<UBlockExpression> {
if (expression.parent is KtFunctionLiteral
&& expression.parent.parent is KtLambdaExpression
&& givenParent !is KotlinULambdaExpression
) {
KotlinULambdaExpression(expression.parent.parent as KtLambdaExpression, givenParent).body
} else
KotlinUBlockExpression(expression, givenParent)
}
is KtConstantExpression -> expr<ULiteralExpression>(build(::KotlinULiteralExpression))
is KtTryExpression -> expr<UTryExpression>(build(::KotlinUTryExpression))
is KtArrayAccessExpression -> expr<UArrayAccessExpression>(build(::KotlinUArrayAccessExpression))
@@ -333,7 +333,15 @@ internal object KotlinConverter {
is KtContinueExpression -> expr<UContinueExpression>(build(::KotlinUContinueExpression))
is KtReturnExpression -> expr<UReturnExpression>(build(::KotlinUReturnExpression))
is KtThrowExpression -> expr<UThrowExpression>(build(::KotlinUThrowExpression))
is KtBlockExpression -> expr<UBlockExpression>(build(::KotlinUBlockExpression))
is KtBlockExpression -> expr<UBlockExpression> {
if (expression.parent is KtFunctionLiteral
&& expression.parent.parent is KtLambdaExpression
&& givenParent !is KotlinULambdaExpression
) {
KotlinULambdaExpression(expression.parent.parent as KtLambdaExpression, givenParent).body
} else
KotlinUBlockExpression(expression, givenParent)
}
is KtConstantExpression -> expr<ULiteralExpression>(build(::KotlinULiteralExpression))
is KtTryExpression -> expr<UTryExpression>(build(::KotlinUTryExpression))
is KtArrayAccessExpression -> expr<UArrayAccessExpression>(build(::KotlinUArrayAccessExpression))
@@ -335,7 +335,15 @@ internal object KotlinConverter {
is KtContinueExpression -> expr<UContinueExpression>(build(::KotlinUContinueExpression))
is KtReturnExpression -> expr<UReturnExpression>(build(::KotlinUReturnExpression))
is KtThrowExpression -> expr<UThrowExpression>(build(::KotlinUThrowExpression))
is KtBlockExpression -> expr<UBlockExpression>(build(::KotlinUBlockExpression))
is KtBlockExpression -> expr<UBlockExpression> {
if (expression.parent is KtFunctionLiteral
&& expression.parent.parent is KtLambdaExpression
&& givenParent !is KotlinULambdaExpression
) {
KotlinULambdaExpression(expression.parent.parent as KtLambdaExpression, givenParent).body
} else
KotlinUBlockExpression(expression, givenParent)
}
is KtConstantExpression -> expr<ULiteralExpression>(build(::KotlinULiteralExpression))
is KtTryExpression -> expr<UTryExpression>(build(::KotlinUTryExpression))
is KtArrayAccessExpression -> expr<UArrayAccessExpression>(build(::KotlinUArrayAccessExpression))
@@ -110,6 +110,7 @@ abstract class AbstractKotlinUVariable(givenParent: UElement?) : KotlinAbstractU
is KtNameReferenceExpression -> sourcePsi.getReferencedNameElement()
is KtBinaryExpression, is KtCallExpression -> null // e.g. `foo("Lorem ipsum") ?: foo("dolor sit amet")`
is KtDestructuringDeclaration -> sourcePsi.valOrVarKeyword
is KtLambdaExpression -> sourcePsi.functionLiteral.lBrace
else -> sourcePsi
} ?: return null
return KotlinUIdentifier(nameIdentifier, identifierSourcePsi, this)
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.psi.KtAnonymousInitializer
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.uast.*
class KotlinUBlockExpression(
open class KotlinUBlockExpression(
override val sourcePsi: KtBlockExpression,
givenParent: UElement?
) : KotlinAbstractUExpression(givenParent), UBlockExpression, KotlinUElementWithType {
@@ -17,12 +17,12 @@
package org.jetbrains.uast.kotlin
import com.intellij.psi.PsiType
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.uast.UBlockExpression
import org.jetbrains.uast.UElement
import org.jetbrains.uast.ULambdaExpression
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsResultOfLambda
import org.jetbrains.uast.*
import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter
import org.jetbrains.uast.withMargin
class KotlinULambdaExpression(
override val sourcePsi: KtLambdaExpression,
@@ -31,8 +31,32 @@ class KotlinULambdaExpression(
override val functionalInterfaceType: PsiType?
get() = getFunctionalInterfaceType()
override val body by lz { KotlinConverter.convertOrEmpty(sourcePsi.bodyExpression, this) }
override val body by lz {
sourcePsi.bodyExpression?.let { Body(it, this) } ?: UastEmptyExpression(this)
}
class Body(bodyExpression: KtBlockExpression, parent: KotlinULambdaExpression) : KotlinUBlockExpression(bodyExpression, parent) {
override val expressions: List<UExpression> by lz expressions@{
val statements = sourcePsi.statements
if (statements.isEmpty()) return@expressions emptyList<UExpression>()
ArrayList<UExpression>(statements.size).also { result ->
statements.subList(0, statements.size - 1).mapTo(result) { KotlinConverter.convertOrEmpty(it, this) }
result.add(implicitReturn ?: KotlinConverter.convertOrEmpty(statements.last(), this))
}
}
val implicitReturn: KotlinUImplicitReturnExpression? by lz {
val lastExpression = sourcePsi.statements.lastOrNull() ?: return@lz null
if (!lastExpression.isUsedAsResultOfLambda(lastExpression.analyze())) return@lz null
KotlinUImplicitReturnExpression(this).apply {
returnExpression = KotlinConverter.convertOrEmpty(lastExpression, this)
}
}
}
override val valueParameters by lz {
sourcePsi.valueParameters.mapIndexed { i, p ->
KotlinUParameter(UastKotlinPsiParameter.create(p, sourcePsi, this, i), sourcePsi, this)
+14 -12
View File
@@ -24,12 +24,13 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null)
ULambdaExpression
UBlockExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
UIdentifier (Identifier (MyColor))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
ULiteralExpression (value = 18)
ULiteralExpression (value = 2)
ULiteralExpression (value = 3)
UReturnExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
UIdentifier (Identifier (MyColor))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
ULiteralExpression (value = 18)
ULiteralExpression (value = 2)
ULiteralExpression (value = 3)
UField (name = lambda)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
@@ -37,12 +38,13 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null)
ULambdaExpression
UBlockExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
UIdentifier (Identifier (MyColor))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
ULiteralExpression (value = 1)
ULiteralExpression (value = 2)
ULiteralExpression (value = 3)
UReturnExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
UIdentifier (Identifier (MyColor))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor)
ULiteralExpression (value = 1)
ULiteralExpression (value = 2)
ULiteralExpression (value = 3)
UField (name = nonLazy)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3))
+2 -2
View File
@@ -10,8 +10,8 @@ public final class MyColor {
public final class Some {
@org.jetbrains.annotations.NotNull private final var delegate$delegate: kotlin.Lazy
@org.jetbrains.annotations.NotNull private final var lambda: kotlin.Lazy<MyColor> = lazy({
<init>(1, 2, 3)
@org.jetbrains.annotations.NotNull private final var lambda: kotlin.Lazy<MyColor> = lazy({
return <init>(1, 2, 3)
})
@org.jetbrains.annotations.NotNull private final var nonLazy: MyColor = <init>(1, 2, 3)
public final fun getDelegate() : MyColor = UastEmptyExpression
+20 -18
View File
@@ -20,37 +20,39 @@ UFile (package = ) [public final class MyColor {...]
UField (name = delegate$delegate) [@org.jetbrains.annotations.NotNull private final var delegate$delegate: kotlin.Lazy]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [lazy({ ...})] = external lazy({
<init>(18, 2, 3)
return <init>(18, 2, 3)
})(Undetermined)
UIdentifier (Identifier (lazy)) [UIdentifier (Identifier (lazy))]
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null) [lazy] = external lazy({
<init>(18, 2, 3)
return <init>(18, 2, 3)
})(Undetermined)
ULambdaExpression [{ ...}] = Undetermined
UBlockExpression [{...}] = external <init>(18, 2, 3)(18, 2, 3)
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(18, 2, 3)] = external <init>(18, 2, 3)(18, 2, 3)
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(18, 2, 3)(18, 2, 3)
ULiteralExpression (value = 18) [18] = 18
ULiteralExpression (value = 2) [2] = 2
ULiteralExpression (value = 3) [3] = 3
UBlockExpression [{...}] = Nothing
UReturnExpression [return <init>(18, 2, 3)] = Nothing
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(18, 2, 3)] = external <init>(18, 2, 3)(18, 2, 3)
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(18, 2, 3)(18, 2, 3)
ULiteralExpression (value = 18) [18] = 18
ULiteralExpression (value = 2) [2] = 2
ULiteralExpression (value = 3) [3] = 3
UField (name = lambda) [@org.jetbrains.annotations.NotNull private final var lambda: kotlin.Lazy<MyColor> = lazy({ ...})]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [lazy({ ...})] = external lazy({
<init>(1, 2, 3)
return <init>(1, 2, 3)
})(Undetermined)
UIdentifier (Identifier (lazy)) [UIdentifier (Identifier (lazy))]
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null) [lazy] = external lazy({
<init>(1, 2, 3)
return <init>(1, 2, 3)
})(Undetermined)
ULambdaExpression [{ ...}] = Undetermined
UBlockExpression [{...}] = external <init>(1, 2, 3)(1, 2, 3)
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(1, 2, 3)] = external <init>(1, 2, 3)(1, 2, 3)
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
ULiteralExpression (value = 1) [1] = 1
ULiteralExpression (value = 2) [2] = 2
ULiteralExpression (value = 3) [3] = 3
UBlockExpression [{...}] = Nothing
UReturnExpression [return <init>(1, 2, 3)] = Nothing
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(1, 2, 3)] = external <init>(1, 2, 3)(1, 2, 3)
UIdentifier (Identifier (MyColor)) [UIdentifier (Identifier (MyColor))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = MyColor) [<init>] = external <init>(1, 2, 3)(1, 2, 3)
ULiteralExpression (value = 1) [1] = 1
ULiteralExpression (value = 2) [2] = 2
ULiteralExpression (value = 3) [3] = 3
UField (name = nonLazy) [@org.jetbrains.annotations.NotNull private final var nonLazy: MyColor = <init>(1, 2, 3)]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 3)) [<init>(1, 2, 3)] = external <init>(1, 2, 3)(1, 2, 3)
+43
View File
@@ -0,0 +1,43 @@
package org.jetbrains.uast.kotlin
fun foo() {
val lam1 = { a: Int ->
val b = 1
a + b
}
val lam2 = { a: Int ->
val c = 1
if (a > 0)
a + c
else
a - c
}
val lam3 = lbd@{ a: Int ->
val d = 1
return@lbd a + d
}
val lam4 = fun(a: Int): String {
if (a < 5) return "5"
if (a > 0)
return "1"
else
return "2"
}
bar {
if (it > 5) return
val b = 1
it + b
}
}
private inline fun bar(lmbd: (Int) -> Int) {
lmbd(1)
}
+96
View File
@@ -0,0 +1,96 @@
UFile (package = org.jetbrains.uast.kotlin)
UClass (name = LambdaReturnKt)
UAnnotationMethod (name = foo)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = lam1)
ULambdaExpression
UParameter (name = a)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = b)
ULiteralExpression (value = 1)
UReturnExpression
UBinaryExpression (operator = +)
USimpleNameReferenceExpression (identifier = a)
USimpleNameReferenceExpression (identifier = b)
UDeclarationsExpression
ULocalVariable (name = lam2)
ULambdaExpression
UParameter (name = a)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = c)
ULiteralExpression (value = 1)
UReturnExpression
UIfExpression
UBinaryExpression (operator = >)
USimpleNameReferenceExpression (identifier = a)
ULiteralExpression (value = 0)
UBinaryExpression (operator = +)
USimpleNameReferenceExpression (identifier = a)
USimpleNameReferenceExpression (identifier = c)
UBinaryExpression (operator = -)
USimpleNameReferenceExpression (identifier = a)
USimpleNameReferenceExpression (identifier = c)
UDeclarationsExpression
ULocalVariable (name = lam3)
ULabeledExpression (label = lbd)
ULambdaExpression
UParameter (name = a)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UDeclarationsExpression
ULocalVariable (name = d)
ULiteralExpression (value = 1)
UReturnExpression
UBinaryExpression (operator = +)
USimpleNameReferenceExpression (identifier = a)
USimpleNameReferenceExpression (identifier = d)
UDeclarationsExpression
ULocalVariable (name = lam4)
ULambdaExpression
UParameter (name = a)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UIfExpression
UBinaryExpression (operator = <)
USimpleNameReferenceExpression (identifier = a)
ULiteralExpression (value = 5)
UReturnExpression
ULiteralExpression (value = "5")
UIfExpression
UBinaryExpression (operator = >)
USimpleNameReferenceExpression (identifier = a)
ULiteralExpression (value = 0)
UReturnExpression
ULiteralExpression (value = "1")
UReturnExpression
ULiteralExpression (value = "2")
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (bar))
USimpleNameReferenceExpression (identifier = bar, resolvesTo = null)
ULambdaExpression
UBlockExpression
UIfExpression
UBinaryExpression (operator = >)
USimpleNameReferenceExpression (identifier = it)
ULiteralExpression (value = 5)
UReturnExpression
UDeclarationsExpression
ULocalVariable (name = b)
ULiteralExpression (value = 1)
UReturnExpression
UBinaryExpression (operator = +)
USimpleNameReferenceExpression (identifier = it)
USimpleNameReferenceExpression (identifier = b)
UAnnotationMethod (name = bar)
UParameter (name = lmbd)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
UIdentifier (Identifier (lmbd))
USimpleNameReferenceExpression (identifier = invoke, resolvesTo = null)
ULiteralExpression (value = 1)
+33
View File
@@ -0,0 +1,33 @@
package org.jetbrains.uast.kotlin
public final class LambdaReturnKt {
public static final fun foo() : void {
var lam1: kotlin.jvm.functions.Function1<? super java.lang.Integer,? extends java.lang.Integer> = { @org.jetbrains.annotations.NotNull var a: int ->
var b: int = 1
return a + b
}
var lam2: kotlin.jvm.functions.Function1<? super java.lang.Integer,? extends java.lang.Integer> = { @org.jetbrains.annotations.NotNull var a: int ->
var c: int = 1
return if (a > 0) a + c else a - c
}
var lam3: kotlin.jvm.functions.Function1<? super java.lang.Integer,? extends java.lang.Integer> = lbd@ { @org.jetbrains.annotations.NotNull var a: int ->
var d: int = 1
return a + d
}
var lam4: kotlin.jvm.functions.Function1<? super java.lang.Integer,? extends java.lang.String> = fun (@org.jetbrains.annotations.NotNull var a: int) {
if (a < 5) return "5"
if (a > 0) return "1" else return "2"
}
bar({
if (it > 5) return
var b: int = 1
return it + b
})
}
private static final fun bar(@org.jetbrains.annotations.NotNull lmbd: kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer>) : void {
invoke(1)
}
}
+6 -5
View File
@@ -14,11 +14,12 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = filter, resolvesTo = null)
ULambdaExpression
UBlockExpression
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = it)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isEmpty))
USimpleNameReferenceExpression (identifier = isEmpty, resolvesTo = null)
UReturnExpression
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = it)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isEmpty))
USimpleNameReferenceExpression (identifier = isEmpty, resolvesTo = null)
UAnnotationMethod (name = doSelectItem)
UParameter (name = selectItemFunction)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
+1 -1
View File
@@ -3,7 +3,7 @@ import java.util.stream.Stream
public final class LambdasKt {
public static final fun foo() : void {
Stream.empty().filter({
it.isEmpty()
return it.isEmpty()
})
}
public static final fun doSelectItem(@org.jetbrains.annotations.NotNull selectItemFunction: kotlin.jvm.functions.Function0<kotlin.Unit>) : void {
+8 -5
View File
@@ -7,7 +7,8 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null)
ULambdaExpression
UBlockExpression
ULiteralExpression (value = "/sdcard")
UReturnExpression
ULiteralExpression (value = "/sdcard")
UField (name = annotatedDelegate$delegate)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UAnnotation (fqName = kotlin.Suppress)
@@ -16,9 +17,10 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null)
ULambdaExpression
UBlockExpression
UBinaryExpression (operator = +)
ULiteralExpression (value = 1)
ULiteralExpression (value = 1)
UReturnExpression
UBinaryExpression (operator = +)
ULiteralExpression (value = 1)
ULiteralExpression (value = 1)
UAnnotationMethod (name = getSdCardPath)
UAnnotationMethod (name = localPropertyTest)
UBlockExpression
@@ -29,5 +31,6 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = lazy, resolvesTo = null)
ULambdaExpression
UBlockExpression
ULiteralExpression (value = "/sdcard")
UReturnExpression
ULiteralExpression (value = "/sdcard")
UAnnotationMethod (name = getAnnotatedDelegate)
+6 -5
View File
@@ -52,11 +52,12 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = map, resolvesTo = null)
ULambdaExpression
UBlockExpression
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = it)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (toString))
USimpleNameReferenceExpression (identifier = toString, resolvesTo = null)
UReturnExpression
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = it)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (toString))
USimpleNameReferenceExpression (identifier = toString, resolvesTo = null)
UDeclarationsExpression
ULocalVariable (name = lls)
UDeclarationsExpression
+1 -1
View File
@@ -13,7 +13,7 @@ public final class TypeReferencesKt {
}
var tl: java.util.List<? extends T> = listOf(at)
var tsl: java.util.List<? extends java.lang.String> = tl.map({
it.toString()
return it.toString()
})
var lls: java.util.List<? extends java.util.List<? extends java.lang.String>>
var llsAliased: java.util.List<? extends java.util.List<? extends java.lang.String>>
+1 -1
View File
@@ -22,7 +22,7 @@ UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifie
ULocalVariable (name = tsl) -> UQualifiedReferenceExpression -> null: null
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = tl) -> LightVariableBuilder:tl: tl
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) -> USimpleNameReferenceExpression (identifier = map) -> PsiMethod:map: map
UBlockExpression -> UQualifiedReferenceExpression -> null: null
UReturnExpression -> UQualifiedReferenceExpression -> null: null
UQualifiedReferenceExpression -> USimpleNameReferenceExpression (identifier = it) -> null: null
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) -> USimpleNameReferenceExpression (identifier = toString) -> null: null
UTypeReferenceExpression (name = java.util.List<? extends java.util.List<? extends java.lang.String>>) -> USimpleNameReferenceExpression (identifier = List) -> PsiClass:List: List
@@ -25,15 +25,16 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = java)
ULambdaExpression
UBlockExpression
UObjectLiteralExpression
UClass (name = null)
UAnnotationMethod (name = onError)
UParameter (name = throwable)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UThrowExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
UIdentifier (Identifier (UnsupportedOperationException))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
ULiteralExpression (value = "")
UAnnotationMethod (name = Model$1$1)
UReturnExpression
UObjectLiteralExpression
UClass (name = null)
UAnnotationMethod (name = onError)
UParameter (name = throwable)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UThrowExpression
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1))
UIdentifier (Identifier (UnsupportedOperationException))
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException)
ULiteralExpression (value = "")
UAnnotationMethod (name = Model$1$1)
@@ -9,7 +9,7 @@ public final class Model {
public fun Model() {
{
crashMe(Callback.java, {
anonymous object : Callback {
return anonymous object : Callback {
override fun onError(throwable: Throwable) {
throw UnsupportedOperationException("")
}
@@ -23,17 +23,18 @@ UFile (package = ) [public abstract interface Callback {...]
UQualifiedReferenceExpression [Callback.java] : PsiType:Class<Callback>
UClassLiteralExpression [Callback] : PsiType:KClass<Callback>
USimpleNameReferenceExpression (identifier = java) [java] : PsiType:Class<Callback>
ULambdaExpression [{ ...}] : PsiType:<ErrorType>
ULambdaExpression [{ ...}] : PsiType:Function0<? extends Callback>
UBlockExpression [{...}]
UObjectLiteralExpression [anonymous object : Callback {... }] : PsiType:Callback
UClass (name = null) [final class null : Callback {...}]
UAnnotationMethod (name = onError) [public fun onError(@org.jetbrains.annotations.NotNull throwable: java.lang.Throwable) : void {...}]
UParameter (name = throwable) [@org.jetbrains.annotations.NotNull var throwable: java.lang.Throwable]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UBlockExpression [{...}] : PsiType:Void
UThrowExpression [throw <init>("")] : PsiType:Void
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) [<init>("")] : PsiType:UnsupportedOperationException
UIdentifier (Identifier (UnsupportedOperationException)) [UIdentifier (Identifier (UnsupportedOperationException))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
ULiteralExpression (value = "") [""] : PsiType:String
UAnnotationMethod (name = Model$1$1) [fun Model$1$1() = UastEmptyExpression]
UReturnExpression [return anonymous object : Callback {... }]
UObjectLiteralExpression [anonymous object : Callback {... }] : PsiType:Callback
UClass (name = null) [final class null : Callback {...}]
UAnnotationMethod (name = onError) [public fun onError(@org.jetbrains.annotations.NotNull throwable: java.lang.Throwable) : void {...}]
UParameter (name = throwable) [@org.jetbrains.annotations.NotNull var throwable: java.lang.Throwable]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UBlockExpression [{...}] : PsiType:Void
UThrowExpression [throw <init>("")] : PsiType:Void
UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) [<init>("")] : PsiType:UnsupportedOperationException
UIdentifier (Identifier (UnsupportedOperationException)) [UIdentifier (Identifier (UnsupportedOperationException))]
USimpleNameReferenceExpression (identifier = <init>, resolvesTo = UnsupportedOperationException) [<init>] : PsiType:UnsupportedOperationException
ULiteralExpression (value = "") [""] : PsiType:String
UAnnotationMethod (name = Model$1$1) [fun Model$1$1() = UastEmptyExpression]
@@ -99,6 +99,9 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
@Test
fun testConstructorDelegate() = doTest("ConstructorDelegate")
@Test
fun testLambdaReturn() = doTest("LambdaReturn")
}
fun withForceUInjectionHostValue(call: () -> Unit) {
@@ -93,4 +93,7 @@ class SimpleKotlinRenderLogTest : AbstractKotlinRenderLogTest() {
@Test
fun testConstructorDelegate() = doTest("ConstructorDelegate")
@Test
fun testLambdaReturn() = doTest("LambdaReturn")
}