UAST: override getFunctionalInterfaceType + test
This commit is contained in:
committed by
Nikolay Krasko
parent
8eddb10870
commit
92c23aa0ed
+1
-1
@@ -28,7 +28,7 @@ class KotlinULambdaExpression(
|
|||||||
override val psi: KtLambdaExpression,
|
override val psi: KtLambdaExpression,
|
||||||
givenParent: UElement?
|
givenParent: UElement?
|
||||||
) : KotlinAbstractUExpression(givenParent), ULambdaExpression, KotlinUElementWithType {
|
) : KotlinAbstractUExpression(givenParent), ULambdaExpression, KotlinUElementWithType {
|
||||||
val functionalInterfaceType: PsiType?
|
override val functionalInterfaceType: PsiType?
|
||||||
get() = getFunctionalInterfaceType()
|
get() = getFunctionalInterfaceType()
|
||||||
|
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ private class KotlinLocalFunctionULambdaExpression(
|
|||||||
override val psi: KtFunction,
|
override val psi: KtFunction,
|
||||||
givenParent: UElement?
|
givenParent: UElement?
|
||||||
): KotlinAbstractUExpression(givenParent), ULambdaExpression {
|
): KotlinAbstractUExpression(givenParent), ULambdaExpression {
|
||||||
val functionalInterfaceType: PsiType?
|
override val functionalInterfaceType: PsiType? = null
|
||||||
get() = null
|
|
||||||
|
|
||||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,27 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun testSAM() {
|
||||||
|
doTest("SAM") { _, file ->
|
||||||
|
assertNull(file.findElementByText<ULambdaExpression>("{ /* Not SAM */ }").functionalInterfaceType)
|
||||||
|
|
||||||
|
assertEquals("java.lang.Runnable",
|
||||||
|
file.findElementByText<ULambdaExpression>("{/* Variable */}").functionalInterfaceType?.canonicalText)
|
||||||
|
|
||||||
|
assertEquals("java.lang.Runnable",
|
||||||
|
file.findElementByText<ULambdaExpression>("{/* Assignment */}").functionalInterfaceType?.canonicalText)
|
||||||
|
|
||||||
|
assertEquals("java.lang.Runnable",
|
||||||
|
file.findElementByText<ULambdaExpression>("{/* Type Cast */}").functionalInterfaceType?.canonicalText)
|
||||||
|
|
||||||
|
assertEquals("java.lang.Runnable",
|
||||||
|
file.findElementByText<ULambdaExpression>("{/* Argument */}").functionalInterfaceType?.canonicalText)
|
||||||
|
|
||||||
|
assertEquals("java.lang.Runnable",
|
||||||
|
file.findElementByText<ULambdaExpression>("{/* Return */}").functionalInterfaceType?.canonicalText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun testParameterPropertyWithAnnotation() {
|
@Test fun testParameterPropertyWithAnnotation() {
|
||||||
doTest("ParameterPropertyWithAnnotation") { _, file ->
|
doTest("ParameterPropertyWithAnnotation") { _, file ->
|
||||||
val test1 = file.classes.find { it.name == "Test1" }!!
|
val test1 = file.classes.find { it.name == "Test1" }!!
|
||||||
|
|||||||
Reference in New Issue
Block a user