diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt index 3259aa4d6ce..b40a5e5dab3 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinULambdaExpression.kt @@ -28,7 +28,7 @@ class KotlinULambdaExpression( override val psi: KtLambdaExpression, givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), ULambdaExpression, KotlinUElementWithType { - val functionalInterfaceType: PsiType? + override val functionalInterfaceType: PsiType? get() = getFunctionalInterfaceType() override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt index 822e862c5e2..094fbbf7cfc 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/LocalFunction.kt @@ -27,8 +27,7 @@ private class KotlinLocalFunctionULambdaExpression( override val psi: KtFunction, givenParent: UElement? ): KotlinAbstractUExpression(givenParent), ULambdaExpression { - val functionalInterfaceType: PsiType? - get() = null + override val functionalInterfaceType: PsiType? = null override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) } diff --git a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt index 11beb41d182..3d84c3e97b1 100644 --- a/plugins/uast-kotlin/tests/KotlinUastApiTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastApiTest.kt @@ -80,6 +80,27 @@ class KotlinUastApiTest : AbstractKotlinUastTest() { } } + @Test fun testSAM() { + doTest("SAM") { _, file -> + assertNull(file.findElementByText("{ /* Not SAM */ }").functionalInterfaceType) + + assertEquals("java.lang.Runnable", + file.findElementByText("{/* Variable */}").functionalInterfaceType?.canonicalText) + + assertEquals("java.lang.Runnable", + file.findElementByText("{/* Assignment */}").functionalInterfaceType?.canonicalText) + + assertEquals("java.lang.Runnable", + file.findElementByText("{/* Type Cast */}").functionalInterfaceType?.canonicalText) + + assertEquals("java.lang.Runnable", + file.findElementByText("{/* Argument */}").functionalInterfaceType?.canonicalText) + + assertEquals("java.lang.Runnable", + file.findElementByText("{/* Return */}").functionalInterfaceType?.canonicalText) + } + } + @Test fun testParameterPropertyWithAnnotation() { doTest("ParameterPropertyWithAnnotation") { _, file -> val test1 = file.classes.find { it.name == "Test1" }!!