-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve Fir2IrLazyProperty before creating backing field
The Compose compiler plugin IR lowering transformers (a part of IrGenerationExtension) access IrProperty. When the IrProperty is Fir2IrLazyProperty, the access to Fir2IrLazyProperty creates its backing field. Without the lazy resolution of the property, it has an exception. This commit conducts the lazy resolution to avoid the exception. ^KT-67972
- Loading branch information
Showing
13 changed files
with
878 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
plugins/compose/compiler-hosted/testData/codegen/lazyPropertyBackingField.ir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
MODULE_FRAGMENT | ||
FILE fqName:home fileName:main.kt | ||
FUN name:Home visibility:public modality:FINAL <> ($composer:androidx.compose.runtime.Composer?, $changed:kotlin.Int) returnType:kotlin.Unit | ||
annotations: | ||
Composable | ||
VALUE_PARAMETER name:$composer index:0 type:androidx.compose.runtime.Composer? [assignable] | ||
VALUE_PARAMETER name:$changed index:1 type:kotlin.Int | ||
BLOCK_BODY | ||
BLOCK type=kotlin.Unit origin=null | ||
SET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' 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 | ||
$this: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' type=androidx.compose.runtime.Composer? origin=null | ||
key: CONST Int type=kotlin.Int value=289538687 | ||
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 | ||
composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' type=androidx.compose.runtime.Composer? origin=null | ||
sourceInformation: CONST String type=kotlin.String value="C(Home)57@262L139:main.kt#1wrmn" | ||
WHEN type=kotlin.Unit origin=IF | ||
BRANCH | ||
if: WHEN type=kotlin.Boolean origin=OROR | ||
BRANCH | ||
if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null | ||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=null | ||
arg0: GET_VAR '$changed: kotlin.Int declared in home.Home' type=kotlin.Int origin=null | ||
arg1: CONST Int type=kotlin.Int value=0 | ||
then: CONST Boolean type=kotlin.Boolean value=true | ||
BRANCH | ||
if: CONST Boolean type=kotlin.Boolean value=true | ||
then: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null | ||
$this: CALL 'public abstract fun <get-skipping> (): kotlin.Boolean declared in androidx.compose.runtime.Composer' type=kotlin.Boolean origin=null | ||
$this: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' type=androidx.compose.runtime.Composer? origin=null | ||
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 | ||
key: CONST Int type=kotlin.Int value=289538687 | ||
dirty1: GET_VAR '$changed: kotlin.Int declared in home.Home' type=kotlin.Int origin=null | ||
dirty2: CONST Int type=kotlin.Int value=-1 | ||
info: CONST String type=kotlin.String value="home.Home (main.kt:56)" | ||
CALL 'public final fun Column (content: @[ExtensionFunctionType] kotlin.Function3<compose.ui.ColumnScope, androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit>, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int): kotlin.Unit [inline] declared in compose.ui' type=kotlin.Unit origin=null | ||
content: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function3<compose.ui.ColumnScope, androidx.compose.runtime.Composer, kotlin.Int, kotlin.Unit> origin=LAMBDA | ||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:compose.ui.ColumnScope, $composer:androidx.compose.runtime.Composer?, $changed:kotlin.Int) returnType:kotlin.Unit | ||
annotations: | ||
Composable | ||
$receiver: VALUE_PARAMETER name:$this$Column type:compose.ui.ColumnScope | ||
VALUE_PARAMETER name:$composer index:0 type:androidx.compose.runtime.Composer? [assignable] | ||
VALUE_PARAMETER name:$changed index:1 type:kotlin.Int | ||
BLOCK_BODY | ||
BLOCK type=kotlin.Unit origin=null | ||
CALL 'public final fun sourceInformationMarkerStart (composer: androidx.compose.runtime.Composer, key: kotlin.Int, sourceInformation: kotlin.String): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null | ||
composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home.<anonymous>' type=androidx.compose.runtime.Composer? origin=null | ||
key: CONST Int type=kotlin.Int value=735130274 | ||
sourceInformation: CONST String type=kotlin.String value="C58@304L28,59@341L54:main.kt#1wrmn" | ||
COMPOSITE type=kotlin.Unit origin=null | ||
VAR name:dominantColorState type:util.DominantColorState [val] | ||
CALL 'public final fun rememberDominantColorState (defaultColor: compose.ui.Color?, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int, $default: kotlin.Int): util.DominantColorState declared in util.DominantColorStateKt' type=util.DominantColorState origin=null | ||
defaultColor: COMPOSITE type=kotlin.Nothing? origin=DEFAULT_VALUE | ||
CONST Null type=kotlin.Nothing? value=null | ||
$composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home.<anonymous>' type=androidx.compose.runtime.Composer? origin=null | ||
$changed: CONST Int type=kotlin.Int value=0 | ||
$default: CONST Int type=kotlin.Int value=1 | ||
CALL 'public final fun DynamicThemePrimaryColorsFromImage (dominantColorState: util.DominantColorState?, $composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int, $default: kotlin.Int): kotlin.Unit declared in util.DominantColorStateKt' type=kotlin.Unit origin=null | ||
dominantColorState: GET_VAR 'val dominantColorState: util.DominantColorState [val] declared in home.Home.<anonymous>' type=util.DominantColorState origin=null | ||
$composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home.<anonymous>' type=androidx.compose.runtime.Composer? origin=null | ||
$changed: CONST Int type=kotlin.Int value=0 | ||
$default: CONST Int type=kotlin.Int value=0 | ||
CALL 'public final fun sourceInformationMarkerEnd (composer: androidx.compose.runtime.Composer): kotlin.Unit declared in androidx.compose.runtime' type=kotlin.Unit origin=null | ||
composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home.<anonymous>' type=androidx.compose.runtime.Composer? origin=null | ||
$composer: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' type=androidx.compose.runtime.Composer? origin=null | ||
$changed: CONST Int type=kotlin.Int value=0 | ||
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 | ||
$this: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' 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_0 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 | ||
$this: GET_VAR '$composer: androidx.compose.runtime.Composer? [assignable] declared in home.Home' 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 | ||
arg0: GET_VAR 'val tmp_0: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Home' type=androidx.compose.runtime.ScopeUpdateScope? origin=null | ||
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 | ||
$this: GET_VAR 'val tmp_0: androidx.compose.runtime.ScopeUpdateScope? [val] declared in home.Home' type=androidx.compose.runtime.ScopeUpdateScope? origin=null | ||
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 <> ($composer:androidx.compose.runtime.Composer?, $force:kotlin.Int) returnType:kotlin.Unit | ||
VALUE_PARAMETER name:$composer index:0 type:androidx.compose.runtime.Composer? | ||
VALUE_PARAMETER 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.Home' | ||
CALL 'public final fun Home ($composer: androidx.compose.runtime.Composer?, $changed: kotlin.Int): kotlin.Unit declared in home' type=kotlin.Unit origin=null | ||
$composer: GET_VAR '$composer: androidx.compose.runtime.Composer? declared in home.Home.<anonymous>' type=androidx.compose.runtime.Composer? origin=null | ||
$changed: CALL 'internal final fun updateChangedFlags (flags: kotlin.Int): kotlin.Int declared in androidx.compose.runtime' type=kotlin.Int origin=null | ||
flags: CALL 'public final fun or (other: kotlin.Int): kotlin.Int [infix] declared in kotlin.Int' type=kotlin.Int origin=null | ||
$this: GET_VAR '$changed: kotlin.Int declared in home.Home' type=kotlin.Int origin=null | ||
other: CONST Int type=kotlin.Int value=1 |
62 changes: 62 additions & 0 deletions
62
plugins/compose/compiler-hosted/testData/codegen/lazyPropertyBackingField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// DUMP_IR | ||
|
||
// MODULE: lib | ||
// MODULE_KIND: LibraryBinary | ||
// FILE: compose/ui/foo.kt | ||
package compose.ui | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
class Color(val r: Int, val g: Int, val b:Int) | ||
|
||
interface ColumnScope { | ||
} | ||
|
||
@Composable | ||
inline fun Column(content: @Composable ColumnScope.() -> Unit) { | ||
} | ||
|
||
// MODULE: main(lib) | ||
// FILE: util/DominantColorState.kt | ||
package util | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.setValue | ||
import compose.ui.Color | ||
|
||
@Composable | ||
fun rememberDominantColorState(defaultColor: Color = Color(0, 0, 0)): DominantColorState = remember { | ||
DominantColorState(defaultColor) | ||
} | ||
|
||
@Composable | ||
fun DynamicThemePrimaryColorsFromImage( | ||
dominantColorState: DominantColorState = rememberDominantColorState() | ||
) { | ||
} | ||
|
||
@Stable | ||
class DominantColorState(private val defaultColor: Color) { | ||
var color by mutableStateOf(defaultColor) | ||
private set | ||
} | ||
|
||
// FILE: main.kt | ||
package home | ||
|
||
import androidx.compose.runtime.Composable | ||
import compose.ui.Column | ||
import util.DynamicThemePrimaryColorsFromImage | ||
import util.rememberDominantColorState | ||
|
||
@Composable | ||
fun Home() { | ||
Column { | ||
val dominantColorState = rememberDominantColorState() | ||
DynamicThemePrimaryColorsFromImage(dominantColorState) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
plugins/compose/compiler-hosted/testData/codegen/lazyPropertyBackingField.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public final class home/MainKt { | ||
// source: 'main.kt' | ||
private final static method Home$lambda$1(p0: int, p1: androidx.compose.runtime.Composer, p2: int): kotlin.Unit | ||
public final static method Home(p0: androidx.compose.runtime.Composer, p1: int): void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.