Default method in interface test
diff --git a/plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/ComposeCrossModuleTests.kt b/plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/ComposeCrossModuleTests.kt index 83b15fe..d095550 100644 --- a/plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/ComposeCrossModuleTests.kt +++ b/plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/ComposeCrossModuleTests.kt
@@ -22,8 +22,6 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder -import org.junit.runner.RunWith -import org.junit.runners.Parameterized import kotlin.test.assertFalse class ComposeCrossModuleTests : AbstractCodegenTest() { @@ -1267,7 +1265,10 @@ } """ ) - ) + ), + validate = { + println(it) + } ) } @@ -1453,21 +1454,12 @@ "lib" to mapOf( "lib.kt" to """ import androidx.compose.runtime.Composable - - interface AssetScope { + + interface SettingsCard { + val cardTitle: String + @Composable - fun GraphicAsset(asset: Int, modifier: Int = 0): Int - } - - - class DefaultAssetScope : AssetScope { - @Composable - override fun GraphicAsset(asset: Int, modifier: Int) = asset - } - - @Composable - fun SomeView(visualAsset: @Composable AssetScope.() -> Unit = {}) { - DefaultAssetScope().visualAsset() + fun CardContents(modifier: Int = 0) { } } """ ), @@ -1475,21 +1467,20 @@ "main.kt" to """ import androidx.compose.runtime.Composable - // in code - data class Graphic(val res: Int) - - @Composable - fun Test() { - val asset = Graphic(0) - SomeView( - visualAsset = { - GraphicAsset(asset = asset.res) - } - ) + class Card(override val cardTitle: String) : SettingsCard { + @Composable + override fun CardContents(modifier: Int) { + println(modifier) + } + } + + @Composable fun Test(card: Card) { + card.CardContents() } """ ) - ) + ), + dumpClasses = true ) }
diff --git a/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.ir.txt b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.ir.txt new file mode 100644 index 0000000..34194af --- /dev/null +++ b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.ir.txt
@@ -0,0 +1,276 @@ +MODULE_FRAGMENT + FILE fqName:home fileName:module_main_defaultInterface.kt + CLASS CLASS name:Card modality:FINAL visibility:public superTypes:[test.SettingsCard] + annotations: + StabilityInferred(parameters = 1) + thisReceiver: VALUE_PARAMETER INSTANCE_RECEIVER kind:DispatchReceiver name:<this> type:home.Card + PROPERTY name:cardTitle visibility:public modality:OPEN [val] + overridden: + public abstract cardTitle: kotlin.String [val] declared in test.SettingsCard + FIELD PROPERTY_BACKING_FIELD name:cardTitle type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 'cardTitle: kotlin.String declared in home.Card.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name:<get-cardTitle> visibility:public modality:OPEN returnType:kotlin.String + VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:home.Card + correspondingProperty: PROPERTY name:cardTitle visibility:public modality:OPEN [val] + overridden: + public abstract fun <get-cardTitle> (): kotlin.String declared in test.SettingsCard + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun <get-cardTitle> (): kotlin.String declared in home.Card' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:cardTitle type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR '<this>: home.Card declared in home.Card.<get-cardTitle>' type=home.Card origin=null + PROPERTY name:$stable visibility:public modality:FINAL [val] + FIELD name:$stable type:kotlin.Int visibility:public [final,static] + annotations: + JvmField + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN GENERATED[androidx.compose.compiler.plugins.kotlin.lower.ComposeCompilerKey] name:home_Card$stableprop_getter visibility:public modality:FINAL returnType:kotlin.Int + correspondingProperty: PROPERTY name:$stable visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun home_Card$stableprop_getter (): kotlin.Int declared in home.Card' + GET_FIELD 'FIELD name:$stable type:kotlin.Int visibility:public [final,static] declared in home.Card' type=kotlin.Int origin=null + CONSTRUCTOR visibility:public returnType:home.Card [primary] + VALUE_PARAMETER kind:Regular name:cardTitle index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Card modality:FINAL visibility:public superTypes:[test.SettingsCard]' type=kotlin.Unit + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN returnType:kotlin.Boolean [fake_override,operator] + VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any + VALUE_PARAMETER kind:Regular name:other index:1 type:kotlin.Any? + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in test.SettingsCard + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN returnType:kotlin.Int [fake_override] + VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in test.SettingsCard + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN returnType:kotlin.String [fake_override] + VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:kotlin.Any + overridden: + public open fun toString (): kotlin.String [fake_override] declared in test.SettingsCard + FUN name:CardContents visibility:public modality:OPEN returnType:kotlin.Unit + VALUE_PARAMETER kind:DispatchReceiver name:<this> index:0 type:home.Card + VALUE_PARAMETER kind:Regular name:modifier index:1 type:androidx.compose.ui.Modifier? + VALUE_PARAMETER kind:Regular name:$composer index:2 type:androidx.compose.runtime.Composer? [assignable] + VALUE_PARAMETER kind:Regular name:$changed index:3 type:kotlin.Int + VALUE_PARAMETER MASK_FOR_DEFAULT_FUNCTION kind:Regular name:$default index:4 type:kotlin.Int + annotations: + Composable + ComposableTarget(applier = "androidx.compose.ui.UiComposable") + overridden: + public open fun CardContents (modifier: androidx.compose.ui.Modifier?, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int, $default: kotlin.Int): kotlin.Unit declared in test.SettingsCard + BLOCK_BODY + BLOCK type=kotlin.Unit origin=null + SET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=kotlin.Unit origin=null + CALL 'public abstract fun startRestartGroup (key: kotlin.Int): androidx.compose.runtime.Composer declared in androidx.compose.runtime.Composer' type=androidx.compose.runtime.Composer origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + ARG key: CONST Int type=kotlin.Int value=655568489 + CALL 'public final fun sourceInformation (composer: androidx.compose.runtime.Composer, sourceInformation: kotlin.String): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + ARG composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + ARG sourceInformation: CONST String type=kotlin.String value="C(CardContents)N(modifier)28@339L13:module_main_defaultInterface.kt#1wrmn" + VAR name:$dirty type:kotlin.Int [val] + GET_VAR '$changed: kotlin.Int declared in home.Card.CardContents' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR '$changed: kotlin.Int declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=6 + ARG arg1: CONST Int type=kotlin.Int value=0 + then: SET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Unit origin=null + CALL 'public final fun or (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG other: WHEN type=kotlin.Int origin=IF + BRANCH + if: CALL 'public abstract fun changed (value: kotlin.Any?): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + ARG value: GET_VAR 'modifier: androidx.compose.ui.Modifier? declared in home.Card.CardContents' type=androidx.compose.ui.Modifier? origin=null + then: CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Int type=kotlin.Int value=2 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public abstract fun shouldExecute (parametersChanged: kotlin.Boolean, flags: kotlin.Int): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + ARG parametersChanged: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null + ARG <this>: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=3 + ARG arg1: CONST Int type=kotlin.Int value=2 + ARG flags: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun isTraceInProgress (): kotlin.Boolean declared in androidx.compose.runtime' type=kotlin.Boolean origin=null + then: CALL 'public final fun traceEventStart (key: kotlin.Int, dirty1: kotlin.Int, dirty2: kotlin.Int, info: kotlin.String): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + ARG key: CONST Int type=kotlin.Int value=655568489 + ARG dirty1: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG dirty2: CONST Int type=kotlin.Int value=-1 + ARG info: CONST String type=kotlin.String value="home.Card.CardContents (module_main_defaultInterface.kt:27)" + CALL 'public final fun Box (modifier: androidx.compose.ui.Modifier, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int): kotlin.Unit declared in androidx.compose.foundation.layout' type=kotlin.Unit origin=null + ARG modifier: GET_VAR 'modifier: androidx.compose.ui.Modifier? declared in home.Card.CardContents' type=androidx.compose.ui.Modifier origin=null + ARG $composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + ARG $changed: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: CONST Int type=kotlin.Int value=14 + ARG other: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Card.CardContents' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun isTraceInProgress (): kotlin.Boolean declared in androidx.compose.runtime' type=kotlin.Boolean origin=null + then: CALL 'public final fun traceEventEnd (): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun skipToGroupEnd (): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:home.Card [val] + GET_VAR '<this>: home.Card declared in home.Card.CardContents' type=home.Card origin=null + BLOCK type=kotlin.Unit origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:androidx.compose.runtime.ScopeUpdateScope? [val] + CALL 'public abstract fun endRestartGroup (): androidx.compose.runtime.ScopeUpdateScope? declared in androidx.compose.runtime.Composer' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Card.CardContents' type=androidx.compose.runtime.Composer? origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: GET_VAR 'val tmp_1: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Card.CardContents' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG arg1: CONST Null type=kotlin.Any? value=null + then: CONST Null type=kotlin.Any? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun updateScope (block: kotlin.Function2<androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in androidx.compose.runtime.ScopeUpdateScope' type=kotlin.Unit origin=null + ARG <this>: GET_VAR 'val tmp_1: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Card.CardContents' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG block: FUN_EXPR type=kotlin.Function2<androidx.compose.runtime.Composer?, kotlin.Int, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL returnType:kotlin.Unit + VALUE_PARAMETER kind:Regular name:$composer index:0 type:androidx.compose.runtime.Composer? + VALUE_PARAMETER kind:Regular name:$force index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun <anonymous> ($composer: androidx.compose.runtime.Composer?, $force: kotlin.Int): kotlin.Unit declared in home.Card.CardContents' + CALL 'public open fun CardContents (modifier: androidx.compose.ui.Modifier?, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int, $default: kotlin.Int): kotlin.Unit declared in home.Card' type=kotlin.Unit origin=null + ARG <this>: GET_VAR 'val tmp_0: home.Card [val] declared in home.Card.CardContents' type=home.Card origin=null + ARG modifier: GET_VAR 'modifier: androidx.compose.ui.Modifier? declared in home.Card.CardContents' type=androidx.compose.ui.Modifier? origin=null + ARG $composer: GET_VAR '$composer: androidx.compose.runtime.Composer? declared in home.Card.CardContents.<anonymous>' type=androidx.compose.runtime.Composer? origin=null + ARG $changed: CALL 'internal final fun updateChangedFlags (flags: kotlin.Int): kotlin.Int declared in androidx.compose.runtime' type=kotlin.Int origin=null + ARG flags: CALL 'public final fun or (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR '$changed: kotlin.Int declared in home.Card.CardContents' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=1 + ARG $default: GET_VAR '$default: kotlin.Int declared in home.Card.CardContents' type=kotlin.Int origin=null + FUN name:Test visibility:public modality:FINAL returnType:kotlin.Unit + VALUE_PARAMETER kind:Regular name:card index:0 type:test.SettingsCard + VALUE_PARAMETER kind:Regular name:$composer index:1 type:androidx.compose.runtime.Composer? [assignable] + VALUE_PARAMETER kind:Regular name:$changed index:2 type:kotlin.Int + annotations: + Composable + BLOCK_BODY + BLOCK type=kotlin.Unit origin=null + SET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=kotlin.Unit origin=null + CALL 'public abstract fun startRestartGroup (key: kotlin.Int): androidx.compose.runtime.Composer declared in androidx.compose.runtime.Composer' type=androidx.compose.runtime.Composer origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG key: CONST Int type=kotlin.Int value=145735469 + CALL 'public final fun sourceInformation (composer: androidx.compose.runtime.Composer, sourceInformation: kotlin.String): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + ARG composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG sourceInformation: CONST String type=kotlin.String value="C(Test)N(card)33@414L14:module_main_defaultInterface.kt#1wrmn" + VAR name:$dirty type:kotlin.Int [val] + GET_VAR '$changed: kotlin.Int declared in home.Test' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR '$changed: kotlin.Int declared in home.Test' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=6 + ARG arg1: CONST Int type=kotlin.Int value=0 + then: SET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Unit origin=null + CALL 'public final fun or (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Int origin=null + ARG other: WHEN type=kotlin.Int origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR '$changed: kotlin.Int declared in home.Test' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=8 + ARG arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public abstract fun changed (value: kotlin.Any?): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG value: GET_VAR 'card: test.SettingsCard declared in home.Test' type=test.SettingsCard origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun changedInstance (value: kotlin.Any?): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG value: GET_VAR 'card: test.SettingsCard declared in home.Test' type=test.SettingsCard origin=null + then: CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Int type=kotlin.Int value=2 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public abstract fun shouldExecute (parametersChanged: kotlin.Boolean, flags: kotlin.Int): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG parametersChanged: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null + ARG <this>: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=3 + ARG arg1: CONST Int type=kotlin.Int value=2 + ARG flags: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun isTraceInProgress (): kotlin.Boolean declared in androidx.compose.runtime' type=kotlin.Boolean origin=null + then: CALL 'public final fun traceEventStart (key: kotlin.Int, dirty1: kotlin.Int, dirty2: kotlin.Int, info: kotlin.String): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + ARG key: CONST Int type=kotlin.Int value=145735469 + ARG dirty1: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Int origin=null + ARG dirty2: CONST Int type=kotlin.Int value=-1 + ARG info: CONST String type=kotlin.String value="home.Test (module_main_defaultInterface.kt:32)" + CALL 'public open fun CardContents (modifier: androidx.compose.ui.Modifier?, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int, $default: kotlin.Int): kotlin.Unit declared in test.SettingsCard' type=kotlin.Unit origin=null + ARG <this>: GET_VAR 'card: test.SettingsCard declared in home.Test' type=test.SettingsCard origin=null + ARG modifier: COMPOSITE type=kotlin.Nothing? origin=DEFAULT_VALUE + CONST Null type=kotlin.Nothing? value=null + ARG $composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + ARG $changed: CALL 'public final fun and (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: CONST Int type=kotlin.Int value=112 + ARG other: CALL 'public final fun shl (bitCount: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR 'val $dirty: kotlin.Int [val] declared in home.Test' type=kotlin.Int origin=null + ARG bitCount: CONST Int type=kotlin.Int value=3 + ARG $default: CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun isTraceInProgress (): kotlin.Boolean declared in androidx.compose.runtime' type=kotlin.Boolean origin=null + then: CALL 'public final fun traceEventEnd (): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun skipToGroupEnd (): kotlin.Unit declared in androidx.compose.runtime.Composer' type=kotlin.Unit origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:androidx.compose.runtime.ScopeUpdateScope? [val] + CALL 'public abstract fun endRestartGroup (): androidx.compose.runtime.ScopeUpdateScope? declared in androidx.compose.runtime.Composer' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG <this>: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Test' type=androidx.compose.runtime.Composer? origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null + ARG arg0: GET_VAR 'val tmp_2: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Test' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG arg1: CONST Null type=kotlin.Any? value=null + then: CONST Null type=kotlin.Any? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public abstract fun updateScope (block: kotlin.Function2<androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in androidx.compose.runtime.ScopeUpdateScope' type=kotlin.Unit origin=null + ARG <this>: GET_VAR 'val tmp_2: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Test' type=androidx.compose.runtime.ScopeUpdateScope? origin=null + ARG block: FUN_EXPR type=kotlin.Function2<androidx.compose.runtime.Composer?, kotlin.Int, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL returnType:kotlin.Unit + VALUE_PARAMETER kind:Regular name:$composer index:0 type:androidx.compose.runtime.Composer? + VALUE_PARAMETER kind:Regular name:$force index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun <anonymous> ($composer: androidx.compose.runtime.Composer?, $force: kotlin.Int): kotlin.Unit declared in home.Test' + CALL 'public final fun Test (card: test.SettingsCard, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int): kotlin.Unit declared in home' type=kotlin.Unit origin=null + ARG card: GET_VAR 'card: test.SettingsCard declared in home.Test' type=test.SettingsCard origin=null + ARG $composer: GET_VAR '$composer: androidx.compose.runtime.Composer? declared in home.Test.<anonymous>' type=androidx.compose.runtime.Composer? origin=null + ARG $changed: CALL 'internal final fun updateChangedFlags (flags: kotlin.Int): kotlin.Int declared in androidx.compose.runtime' type=kotlin.Int origin=null + ARG flags: CALL 'public final fun or (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null + ARG <this>: GET_VAR '$changed: kotlin.Int declared in home.Test' type=kotlin.Int origin=null + ARG other: CONST Int type=kotlin.Int value=1
diff --git a/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.kt b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.kt new file mode 100644 index 0000000..5ed3cd5 --- /dev/null +++ b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.kt
@@ -0,0 +1,35 @@ +// DUMP_IR + +// MODULE: lib +// MODULE_KIND: LibraryBinary +// FILE: SettingsCard.kt +package test + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier + +interface SettingsCard { + val cardTitle: String + + @Composable + fun CardContents(modifier: Modifier = Modifier) { } +} + +// MODULE: main(lib) +package home + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.foundation.layout.Box +import test.SettingsCard + +class Card(override val cardTitle: String) : SettingsCard { + @Composable + override fun CardContents(modifier: Modifier) { + Box(modifier) + } +} + +@Composable fun Test(card: SettingsCard) { + card.CardContents() +}
diff --git a/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.txt b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.txt new file mode 100644 index 0000000..9961fee --- /dev/null +++ b/plugins/compose/compiler-hosted/testData/codegen/defaultInterface.txt
@@ -0,0 +1,16 @@ +public final class home/Card { + // source: 'module_main_defaultInterface.kt' + public final static field $stable: int + private final field cardTitle: java.lang.String + static method <clinit>(): void + public method <init>(p0: java.lang.String): void + private final static method CardContents$lambda$0(p0: home.Card, p1: androidx.compose.ui.Modifier, p2: int, p3: int, p4: androidx.compose.runtime.Composer, p5: int): kotlin.Unit + public method CardContents(p0: androidx.compose.ui.Modifier, p1: androidx.compose.runtime.Composer, p2: int, p3: int): void + public method getCardTitle(): java.lang.String +} + +public final class home/Module_main_defaultInterfaceKt { + // source: 'module_main_defaultInterface.kt' + private final static method Test$lambda$0(p0: test.SettingsCard, p1: int, p2: androidx.compose.runtime.Composer, p3: int): kotlin.Unit + public final static method Test(p0: test.SettingsCard, p1: androidx.compose.runtime.Composer, p2: int): void +}
diff --git a/plugins/compose/compiler-hosted/tests-gen/androidx/compose/compiler/plugins/kotlin/CompilerFacilityTestForComposeCompilerPluginGenerated.java b/plugins/compose/compiler-hosted/tests-gen/androidx/compose/compiler/plugins/kotlin/CompilerFacilityTestForComposeCompilerPluginGenerated.java index 76c0f5f..9fc84a8 100644 --- a/plugins/compose/compiler-hosted/tests-gen/androidx/compose/compiler/plugins/kotlin/CompilerFacilityTestForComposeCompilerPluginGenerated.java +++ b/plugins/compose/compiler-hosted/tests-gen/androidx/compose/compiler/plugins/kotlin/CompilerFacilityTestForComposeCompilerPluginGenerated.java
@@ -64,6 +64,12 @@ } @Test + @TestMetadata("defaultInterface.kt") + public void testDefaultInterface() { + run("defaultInterface.kt"); + } + + @Test @TestMetadata("funInterface.kt") public void testFunInterface() { run("funInterface.kt");