K2: Set special function kind to function param with receiver
`StubBasedFirTypeDeserializer` handles function parameter with a receiver with a special exception, which sets it as `ExtensionFunctionType`, but skips setting special function kinds for it even when the function parameter type is a special function kind. This drops `Composable` annotation from a lambda expression if the function parameter taking the lambda expression as an argument has a receiver, which causes a severe CodeGen error for Compose app on K2 Android Studio. ^KT-66526 Fixed
This commit is contained in:
+6
@@ -56,4 +56,10 @@ public class FirIdeNormalAnalysisSourceModuleFirPluginPrototypeMultiModuleCompil
|
|||||||
public void testComposableFunctionMultiModules2() {
|
public void testComposableFunctionMultiModules2() {
|
||||||
runTest("analysis/analysis-api/testData/components/compilerFacility/firPluginPrototypeMultiModule/composableFunctionMultiModules2.kt");
|
runTest("analysis/analysis-api/testData/components/compilerFacility/firPluginPrototypeMultiModule/composableFunctionMultiModules2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("composableInlineFunctionExpressionParameter.kt")
|
||||||
|
public void testComposableInlineFunctionExpressionParameter() {
|
||||||
|
runTest("analysis/analysis-api/testData/components/compilerFacility/firPluginPrototypeMultiModule/composableInlineFunctionExpressionParameter.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
MODULE_FRAGMENT
|
||||||
|
FILE fqName:<root> fileName:main.kt
|
||||||
|
FUN name:AuthorAndReadTime visibility:public modality:FINAL <> (b:p2.B) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:b index:0 type:p2.B
|
||||||
|
BLOCK_BODY
|
||||||
|
CALL 'public final fun Row (a: p2.A, content: @[MyComposable] @[ExtensionFunctionType] kotlin.Function1<p3.RowScope, kotlin.Unit>): kotlin.Unit [inline] declared in p3' type=kotlin.Unit origin=null
|
||||||
|
a: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in p2.A' type=p2.A origin=null
|
||||||
|
content: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<p3.RowScope, kotlin.Unit> origin=LAMBDA
|
||||||
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:p3.RowScope) returnType:kotlin.Unit
|
||||||
|
annotations:
|
||||||
|
MyComposable
|
||||||
|
$receiver: VALUE_PARAMETER name:$this$Row type:p3.RowScope
|
||||||
|
BLOCK_BODY
|
||||||
|
CALL 'public final fun callB (): kotlin.Unit declared in p2.B' type=kotlin.Unit origin=null
|
||||||
|
$this: GET_VAR 'b: p2.B declared in <root>.AuthorAndReadTime' type=p2.B origin=null
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
// WITH_FIR_TEST_COMPILER_PLUGIN
|
||||||
|
// DUMP_IR
|
||||||
|
|
||||||
|
// MODULE: lib
|
||||||
|
// MODULE_KIND: LibraryBinary
|
||||||
|
// FILE: p2/foo.kt
|
||||||
|
package p2
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun callA() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B {
|
||||||
|
fun callB() {}
|
||||||
|
}
|
||||||
|
// MODULE: lib2(lib)
|
||||||
|
// MODULE_KIND: LibraryBinary
|
||||||
|
// FILE: p3/bar.kt
|
||||||
|
package p3
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.plugin.MyComposable
|
||||||
|
import p2.A
|
||||||
|
|
||||||
|
interface RowScope
|
||||||
|
|
||||||
|
inline fun Row(a: A, content: @MyComposable RowScope.() -> Unit) {
|
||||||
|
a.callA()
|
||||||
|
}
|
||||||
|
// MODULE: main(lib, lib2)
|
||||||
|
// FILE: main.kt
|
||||||
|
import org.jetbrains.kotlin.fir.plugin.MyComposable
|
||||||
|
import p2.A
|
||||||
|
import p2.B
|
||||||
|
import p3.Row
|
||||||
|
|
||||||
|
fun AuthorAndReadTime(b: B) {
|
||||||
|
Row(A()) {
|
||||||
|
b.callB()
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
public final class MainKt {
|
||||||
|
// source: 'main.kt'
|
||||||
|
public final static method AuthorAndReadTime(p0: p2.B): void
|
||||||
|
}
|
||||||
+5
-1
@@ -231,7 +231,11 @@ internal class StubBasedFirTypeDeserializer(
|
|||||||
constructor,
|
constructor,
|
||||||
arguments,
|
arguments,
|
||||||
isNullable = isNullable,
|
isNullable = isNullable,
|
||||||
if (typeElement is KtFunctionType && typeElement.receiver != null) ConeAttributes.WithExtensionFunctionType else attributes
|
if (typeElement is KtFunctionType && typeElement.receiver != null) {
|
||||||
|
ConeAttributes.WithExtensionFunctionType.add(attributes)
|
||||||
|
} else {
|
||||||
|
attributes
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user