Merge "Move Composable property annotation to getter" into androidx-master-dev
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallLoweringTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallLoweringTests.kt
index bf3a820..d4c4674 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallLoweringTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallLoweringTests.kt
@@ -179,13 +179,13 @@
"""
import androidx.compose.runtime.*
- @Composable val foo get() = 123
+ val foo @Composable get() = 123
class A {
- @Composable val bar get() = 123
+ val bar @Composable get() = 123
}
- @Composable val A.bam get() = 123
+ val A.bam @Composable get() = 123
@Composable fun Foo() {
}
@@ -260,13 +260,13 @@
fun testPropertyValues(): Unit = ensureSetup {
compose(
"""
- @Composable val foo get() = "123"
+ val foo @Composable get() = "123"
class A {
- @Composable val bar get() = "123"
+ val bar @Composable get() = "123"
}
- @Composable val A.bam get() = "123"
+ val A.bam @Composable get() = "123"
@Composable
fun App() {
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallResolverTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallResolverTests.kt
index e6b6625..ba815cf 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallResolverTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposeCallResolverTests.kt
@@ -34,13 +34,13 @@
"""
import androidx.compose.runtime.*
- @Composable val foo get() = 123
+ val foo @Composable get() = 123
class A {
- @Composable val bar get() = 123
+ val bar @Composable get() = 123
}
- @Composable val A.bam get() = 123
+ val A.bam @Composable get() = 123
@Composable
fun test() {
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
index ef97c5e..fa1abfc 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
@@ -855,12 +855,11 @@
@Test
fun testComposableTopLevelProperty(): Unit = checkApi(
"""
- @Composable val foo: Int get() { return 123 }
+ val foo: Int @Composable get() { return 123 }
""",
"""
public final class TestKt {
public final static getFoo(Landroidx/compose/runtime/Composer;I)I
- public static synthetic getFoo%annotations()V
}
"""
)
@@ -869,14 +868,13 @@
fun testComposableProperty(): Unit = checkApi(
"""
class Foo {
- @Composable val foo: Int get() { return 123 }
+ val foo: Int @Composable get() { return 123 }
}
""",
"""
public final class Foo {
public <init>()V
public final getFoo(Landroidx/compose/runtime/Composer;I)I
- public static synthetic getFoo%annotations()V
public final static I %stable
static <clinit>()V
}
@@ -942,7 +940,7 @@
@Test
fun testCallingProperties(): Unit = checkApi(
"""
- @Composable val bar: Int get() { return 123 }
+ val bar: Int @Composable get() { return 123 }
@Composable fun Example() {
bar
@@ -951,7 +949,6 @@
"""
public final class TestKt {
public final static getBar(Landroidx/compose/runtime/Composer;I)I
- public static synthetic getBar%annotations()V
final static INNERCLASS TestKt%Example%1 null null
public final static Example(Landroidx/compose/runtime/Composer;I)V
}
@@ -1201,8 +1198,7 @@
@Test
fun testDexNaming(): Unit = checkApi(
"""
- @Composable
- val myProperty: () -> Unit get() {
+ val myProperty: () -> Unit @Composable get() {
return { }
}
""",
@@ -1210,7 +1206,6 @@
public final class TestKt {
final static INNERCLASS TestKt%myProperty%1 null null
public final static getMyProperty(Landroidx/compose/runtime/Composer;I)Lkotlin/jvm/functions/Function0;
- public static synthetic getMyProperty%annotations()V
}
final class TestKt%myProperty%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function0 {
<init>()V
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamTransformTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamTransformTests.kt
index 07fa0354..6228e46 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamTransformTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamTransformTests.kt
@@ -55,7 +55,7 @@
@Test
fun testCallingProperties(): Unit = composerParam(
"""
- @Composable val bar: Int get() { return 123 }
+ val bar: Int @Composable get() { return 123 }
@ComposableContract(restartable = false) @Composable fun Example() {
bar
@@ -289,8 +289,7 @@
@Test
fun testDexNaming(): Unit = composerParam(
"""
- @Composable
- val myProperty: () -> Unit get() {
+ val myProperty: () -> Unit @Composable get() {
return { }
}
""",
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
index 30e6dbf..93459df 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/KtxCrossModuleTests.kt
@@ -447,7 +447,7 @@
import androidx.compose.runtime.Composable
class Foo {
- @Composable val value: Int get() = 123
+ val value: Int @Composable get() = 123
}
"""
),
@@ -687,7 +687,7 @@
import androidx.compose.runtime.*
- @Composable val foo: Int get() { return 123 }
+ val foo: Int @Composable get() { return 123 }
"""
),
"Main" to mapOf(
@@ -740,6 +740,35 @@
}
@Test
+ fun testXModuleComposableProperty(): Unit = ensureSetup {
+ compile(
+ mapOf(
+ "library module" to mapOf(
+ "a/Foo.kt" to """
+ package a
+
+ import androidx.compose.runtime.*
+
+ val foo: () -> Unit
+ @Composable get() = {}
+ """
+ ),
+ "Main" to mapOf(
+ "B.kt" to """
+ import a.foo
+ import androidx.compose.runtime.*
+
+ @Composable fun Example() {
+ val bar = foo
+ bar()
+ }
+ """
+ )
+ )
+ )
+ }
+
+ @Test
fun testXModuleCtorComposableParam(): Unit = ensureSetup {
compile(
mapOf(
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableCheckerTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableCheckerTests.kt
index b05df3c..3b124e8 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableCheckerTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableCheckerTests.kt
@@ -140,7 +140,7 @@
"""
import androidx.compose.runtime.*
@Composable fun C(): Int { return 123 }
- @Composable val cProp: Int get() = C()
+ val cProp: Int @Composable get() = C()
"""
)
@@ -157,7 +157,7 @@
import androidx.compose.runtime.*
@Composable fun C(): Int { return 123 }
val ncProp: Int = <!COMPOSABLE_INVOCATION!>C<!>()
- @Composable val <!COMPOSABLE_PROPERTY_BACKING_FIELD!>cProp<!>: Int = <!COMPOSABLE_INVOCATION!>C<!>()
+ @Composable val <!COMPOSABLE_PROPERTY_BACKING_FIELD,DEPRECATED_COMPOSABLE_PROPERTY!>cProp<!>: Int = <!COMPOSABLE_INVOCATION!>C<!>()
"""
)
@@ -868,7 +868,7 @@
"""
import androidx.compose.runtime.*;
- @Composable val foo: Int get() = 123
+ val foo: Int @Composable get() = 123
fun <!COMPOSABLE_EXPECTED!>App<!>() {
<!COMPOSABLE_INVOCATION!>foo<!>
@@ -879,7 +879,7 @@
"""
import androidx.compose.runtime.*;
- @Composable val foo: Int get() = 123
+ val foo: Int @Composable get() = 123
@Composable
fun App() {
@@ -927,10 +927,10 @@
import androidx.compose.runtime.*;
class A {
- @Composable val bar get() = 123
+ val bar @Composable get() = 123
}
- @Composable val A.bam get() = 123
+ val A.bam @Composable get() = 123
@Composable
fun App() {
@@ -966,7 +966,7 @@
@Composable fun Foo() {}
- @Composable val bam: Int get() {
+ val bam: Int @Composable get() {
Foo()
return 123
}
@@ -1003,7 +1003,7 @@
val x = object {
val <!COMPOSABLE_EXPECTED!>a<!> get() =
<!COMPOSABLE_INVOCATION!>remember<!> { mutableStateOf(2) }
- @Composable val c get() = remember { mutableStateOf(4) }
+ val c @Composable get() = remember { mutableStateOf(4) }
@Composable fun bar() { Foo() }
fun <!COMPOSABLE_EXPECTED!>foo<!>() {
<!COMPOSABLE_INVOCATION!>Foo<!>()
@@ -1012,7 +1012,7 @@
class Bar {
val <!COMPOSABLE_EXPECTED!>b<!> get() =
<!COMPOSABLE_INVOCATION!>remember<!> { mutableStateOf(6) }
- @Composable val c get() = remember { mutableStateOf(7) }
+ val c @Composable get() = remember { mutableStateOf(7) }
}
fun <!COMPOSABLE_EXPECTED!>Bam<!>() {
<!COMPOSABLE_INVOCATION!>Foo<!>()
@@ -1036,7 +1036,7 @@
@Composable fun App() {
val x = object {
val <!COMPOSABLE_EXPECTED!>a<!> get() = <!COMPOSABLE_INVOCATION!>remember<!> { mutableStateOf(2) }
- @Composable val c get() = remember { mutableStateOf(4) }
+ val c @Composable get() = remember { mutableStateOf(4) }
fun <!COMPOSABLE_EXPECTED!>foo<!>() {
<!COMPOSABLE_INVOCATION!>Foo<!>()
}
@@ -1044,7 +1044,7 @@
}
class Bar {
val <!COMPOSABLE_EXPECTED!>b<!> get() = <!COMPOSABLE_INVOCATION!>remember<!> { mutableStateOf(6) }
- @Composable val c get() = remember { mutableStateOf(7) }
+ val c @Composable get() = remember { mutableStateOf(7) }
}
fun <!COMPOSABLE_EXPECTED!>Bam<!>() {
<!COMPOSABLE_INVOCATION!>Foo<!>()
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableDeclarationCheckerTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableDeclarationCheckerTests.kt
index c63dffc..4463850 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableDeclarationCheckerTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposableDeclarationCheckerTests.kt
@@ -29,7 +29,10 @@
import androidx.compose.runtime.Composable
@Composable
- val <!COMPOSABLE_PROPERTY_BACKING_FIELD!>foo<!>: Int = 123
+ val <!DEPRECATED_COMPOSABLE_PROPERTY,COMPOSABLE_PROPERTY_BACKING_FIELD!>foo<!>: Int = 123
+
+ val <!COMPOSABLE_PROPERTY_BACKING_FIELD!>bar<!>: Int = 123
+ @Composable get() = field
"""
)
}
@@ -78,7 +81,9 @@
import androidx.compose.runtime.Composable
@Composable
- val bar: Int get() = 123
+ val <!DEPRECATED_COMPOSABLE_PROPERTY!>bar<!>: Int get() = 123
+
+ val foo: Int @Composable get() = 123
"""
)
}
@@ -89,9 +94,67 @@
import androidx.compose.runtime.Composable
@Composable
- var <!COMPOSABLE_VAR!>bam<!>: Int
+ var <!DEPRECATED_COMPOSABLE_PROPERTY, COMPOSABLE_VAR!>bam<!>: Int
get() { return 123 }
set(value) { print(value) }
+
+ var <!COMPOSABLE_VAR!>bam2<!>: Int
+ @Composable get() { return 123 }
+ set(value) { print(value) }
+
+ var <!COMPOSABLE_VAR!>bam3<!>: Int
+ @Composable get() { return 123 }
+ <!WRONG_ANNOTATION_TARGET!>@Composable<!> set(value) { print(value) }
+
+ var <!COMPOSABLE_VAR!>bam4<!>: Int
+ get() { return 123 }
+ <!WRONG_ANNOTATION_TARGET!>@Composable<!> set(value) { print(value) }
+ """
+ )
+ }
+
+ fun testPropertyGetterAllForms() {
+ doTest(
+ """
+ import androidx.compose.runtime.Composable
+
+ @Composable val <!DEPRECATED_COMPOSABLE_PROPERTY!>bar1<!>: Int get() = 123
+ val bar2: Int @Composable get() = 123
+ @get:Composable val bar3: Int get() = 123
+
+ interface Foo {
+ @Composable val <!DEPRECATED_COMPOSABLE_PROPERTY!>bar1<!>: Int get() = 123
+ val bar2: Int @Composable get() = 123
+ @get:Composable val bar3: Int get() = 123
+ }
+ """
+ )
+ }
+
+ fun testMarkedPropInOverrideMarkedGetter() {
+ doTest(
+ """
+ import androidx.compose.runtime.Composable
+ interface A {
+ val foo: Int @Composable get() = 123
+ }
+ class Impl : A {
+ @Composable override val <!DEPRECATED_COMPOSABLE_PROPERTY!>foo<!>: Int get() = 123
+ }
+ """
+ )
+ }
+
+ fun testMarkedGetterInOverrideMarkedProp() {
+ doTest(
+ """
+ import androidx.compose.runtime.Composable
+ interface A {
+ @Composable val <!DEPRECATED_COMPOSABLE_PROPERTY!>foo<!>: Int get() = 123
+ }
+ class Impl : A {
+ override val foo: Int @Composable get() = 123
+ }
"""
)
}
@@ -128,16 +191,31 @@
@Composable
fun composableFunction(param: Boolean): Boolean
@Composable
- val composableProperty: Boolean
+ val <!DEPRECATED_COMPOSABLE_PROPERTY!>composableProperty<!>: Boolean
fun nonComposableFunction(param: Boolean): Boolean
val nonComposableProperty: Boolean
}
object FakeFoo : Foo {
<!CONFLICTING_OVERLOADS!>override fun composableFunction(param: Boolean)<!> = true
- <!CONFLICTING_OVERLOADS!>override val composableProperty: Boolean<!> get() = true
+ <!CONFLICTING_OVERLOADS!>override val composableProperty: Boolean<!> <!CONFLICTING_OVERLOADS!>get()<!> = true
<!CONFLICTING_OVERLOADS!>@Composable override fun nonComposableFunction(param: Boolean)<!> = true
- <!CONFLICTING_OVERLOADS!>@Composable override val nonComposableProperty: Boolean<!> get() = true
+ <!CONFLICTING_OVERLOADS!>@Composable override val <!DEPRECATED_COMPOSABLE_PROPERTY!>nonComposableProperty<!>: Boolean<!> <!CONFLICTING_OVERLOADS!>get()<!> = true
+ }
+
+ interface Bar {
+ @Composable
+ fun composableFunction(param: Boolean): Boolean
+ val composableProperty: Boolean @Composable get()
+ fun nonComposableFunction(param: Boolean): Boolean
+ val nonComposableProperty: Boolean
+ }
+
+ object FakeBar : Bar {
+ <!CONFLICTING_OVERLOADS!>override fun composableFunction(param: Boolean)<!> = true
+ <!CONFLICTING_OVERLOADS!>override val composableProperty: Boolean<!> <!CONFLICTING_OVERLOADS!>get()<!> = true
+ <!CONFLICTING_OVERLOADS!>@Composable override fun nonComposableFunction(param: Boolean)<!> = true
+ <!CONFLICTING_OVERLOADS!>override val nonComposableProperty: Boolean<!> <!CONFLICTING_OVERLOADS!>@Composable get()<!> = true
}
"""
)
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableCallChecker.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableCallChecker.kt
index 37784c8..6bd17a8 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableCallChecker.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableCallChecker.kt
@@ -68,6 +68,8 @@
import org.jetbrains.kotlin.types.upperIfFlexible
import org.jetbrains.kotlin.util.OperatorNameConventions
+internal const val COMPOSABLE_PROPERTIES = true
+
open class ComposableCallChecker :
CallChecker,
AdditionalTypeChecker,
@@ -187,7 +189,11 @@
}
is KtPropertyAccessor -> {
val property = node.property
- if (!property.annotationEntries.hasComposableAnnotation(bindingContext)) {
+ val isComposable = node
+ .annotationEntries.hasComposableAnnotation(bindingContext)
+ val propertyIsComposable = property
+ .annotationEntries.hasComposableAnnotation(bindingContext)
+ if (!(isComposable || COMPOSABLE_PROPERTIES && propertyIsComposable)) {
illegalCall(context, reportOn, property.nameIdentifier ?: property)
}
return
@@ -329,19 +335,32 @@
return when (candidateDescriptor) {
is ValueParameterDescriptor -> false
is LocalVariableDescriptor -> false
- is PropertyDescriptor -> candidateDescriptor.hasComposableAnnotation()
- is PropertyGetterDescriptor ->
- candidateDescriptor.correspondingProperty.hasComposableAnnotation()
+ is PropertyDescriptor -> {
+ val isGetter = valueArguments.isEmpty()
+ val getter = candidateDescriptor.getter
+ if (isGetter && getter != null) {
+ getter.hasComposableAnnotation() ||
+ (COMPOSABLE_PROPERTIES && candidateDescriptor.hasComposableAnnotation())
+ } else {
+ false
+ }
+ }
+ is PropertyGetterDescriptor -> candidateDescriptor.hasComposableAnnotation() || (
+ COMPOSABLE_PROPERTIES && candidateDescriptor.correspondingProperty
+ .hasComposableAnnotation()
+ )
else -> candidateDescriptor.hasComposableAnnotation()
}
}
internal fun CallableDescriptor.isMarkedAsComposable(): Boolean {
return when (this) {
- is PropertyGetterDescriptor -> correspondingProperty.hasComposableAnnotation()
+ is PropertyGetterDescriptor -> hasComposableAnnotation() || (
+ COMPOSABLE_PROPERTIES && correspondingProperty.hasComposableAnnotation()
+ )
is ValueParameterDescriptor -> type.hasComposableAnnotation()
is LocalVariableDescriptor -> type.hasComposableAnnotation()
- is PropertyDescriptor -> hasComposableAnnotation()
+ is PropertyDescriptor -> COMPOSABLE_PROPERTIES && hasComposableAnnotation()
else -> hasComposableAnnotation()
}
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableDeclarationChecker.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableDeclarationChecker.kt
index 8e592b6..bf9bce7 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableDeclarationChecker.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposableDeclarationChecker.kt
@@ -26,6 +26,7 @@
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
+import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.platform.TargetPlatform
@@ -33,6 +34,7 @@
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtProperty
+import org.jetbrains.kotlin.psi.KtPropertyAccessor
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
import org.jetbrains.kotlin.types.KotlinType
@@ -53,8 +55,15 @@
context: DeclarationCheckerContext
) {
when {
- declaration is KtProperty &&
+ COMPOSABLE_PROPERTIES &&
+ declaration is KtProperty &&
descriptor is PropertyDescriptor -> checkProperty(declaration, descriptor, context)
+ declaration is KtPropertyAccessor &&
+ descriptor is PropertyAccessorDescriptor -> checkPropertyAccessor(
+ declaration,
+ descriptor,
+ context
+ )
declaration is KtFunction &&
descriptor is FunctionDescriptor -> checkFunction(declaration, descriptor, context)
}
@@ -112,9 +121,58 @@
context: DeclarationCheckerContext
) {
val hasComposableAnnotation = descriptor.hasComposableAnnotation()
+ val thisIsComposable = hasComposableAnnotation || descriptor
+ .getter
+ ?.hasComposableAnnotation() == true
if (descriptor.overriddenDescriptors.isNotEmpty()) {
val override = descriptor.overriddenDescriptors.first()
- if (override.hasComposableAnnotation() != hasComposableAnnotation) {
+ val overrideIsComposable = override.hasComposableAnnotation() ||
+ override.getter?.hasComposableAnnotation() == true
+ if (overrideIsComposable != thisIsComposable) {
+ context.trace.report(
+ ComposeErrors.CONFLICTING_OVERLOADS.on(
+ declaration,
+ listOf(descriptor, override)
+ )
+ )
+ }
+ }
+ if (hasComposableAnnotation) {
+ context.trace.report(
+ ComposeErrors.DEPRECATED_COMPOSABLE_PROPERTY.on(
+ declaration.nameIdentifier ?: declaration
+ )
+ )
+ }
+ if (!hasComposableAnnotation) return
+ val initializer = declaration.initializer
+ val name = declaration.nameIdentifier
+ if (initializer != null && name != null) {
+ context.trace.report(COMPOSABLE_PROPERTY_BACKING_FIELD.on(name))
+ }
+ if (descriptor.isVar && name != null) {
+ context.trace.report(COMPOSABLE_VAR.on(name))
+ }
+ }
+
+ private fun checkPropertyAccessor(
+ declaration: KtPropertyAccessor,
+ descriptor: PropertyAccessorDescriptor,
+ context: DeclarationCheckerContext
+ ) {
+ val propertyDescriptor = descriptor.correspondingProperty
+ val propertyPsi = declaration.parent as? KtProperty ?: return
+ val name = propertyPsi.nameIdentifier
+ val initializer = propertyPsi.initializer
+ val hasComposableAnnotation = descriptor.hasComposableAnnotation()
+ val propertyHasComposableAnnotation = COMPOSABLE_PROPERTIES && propertyDescriptor
+ .hasComposableAnnotation()
+ val thisComposable = hasComposableAnnotation || propertyHasComposableAnnotation
+ if (descriptor.overriddenDescriptors.isNotEmpty()) {
+ val override = descriptor.overriddenDescriptors.first()
+ val overrideComposable = override.hasComposableAnnotation() || override
+ .correspondingProperty.hasComposableAnnotation()
+ if (overrideComposable != thisComposable) {
context.trace.report(
ComposeErrors.CONFLICTING_OVERLOADS.on(
declaration,
@@ -124,12 +182,10 @@
}
}
if (!hasComposableAnnotation) return
- val initializer = declaration.initializer
- val name = declaration.nameIdentifier
if (initializer != null && name != null) {
context.trace.report(COMPOSABLE_PROPERTY_BACKING_FIELD.on(name))
}
- if (descriptor.isVar && name != null) {
+ if (propertyDescriptor.isVar && name != null) {
context.trace.report(COMPOSABLE_VAR.on(name))
}
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrorMessages.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrorMessages.kt
index 2d62be3..e0e887a 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrorMessages.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrorMessages.kt
@@ -90,5 +90,10 @@
RENDER_TYPE_WITH_ANNOTATIONS,
RENDER_TYPE_WITH_ANNOTATIONS
)
+ MAP.put(
+ ComposeErrors.DEPRECATED_COMPOSABLE_PROPERTY,
+ "@Composable properties should be declared with the @Composable annotation " +
+ "on the getter, and not the property itself."
+ )
}
}
\ No newline at end of file
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrors.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrors.kt
index b416082..8ef2b83 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrors.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/ComposeErrors.kt
@@ -85,6 +85,10 @@
)
@JvmField
+ var DEPRECATED_COMPOSABLE_PROPERTY: DiagnosticFactory0<PsiElement> =
+ DiagnosticFactory0.create(Severity.WARNING)
+
+ @JvmField
val ILLEGAL_ASSIGN_TO_UNIONTYPE =
DiagnosticFactory2.create<KtExpression, Collection<KotlinType>, Collection<KotlinType>>(
Severity.ERROR
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
index d9cdd91..e4c97a5 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerParamTransformer.kt
@@ -356,7 +356,16 @@
).also { fn ->
newDescriptor.bind(fn)
if (this is IrSimpleFunction) {
- fn.correspondingPropertySymbol = correspondingPropertySymbol
+ val propertySymbol = correspondingPropertySymbol
+ if (propertySymbol != null) {
+ fn.correspondingPropertySymbol = propertySymbol
+ if (propertySymbol.owner.getter == this) {
+ propertySymbol.owner.getter = fn
+ }
+ if (propertySymbol.owner.setter == this) {
+ propertySymbol.owner.setter = this
+ }
+ }
}
fn.parent = parent
fn.typeParameters = this.typeParameters.map {
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoColors.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoColors.kt
index 4f908ce..5bb3529 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoColors.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoColors.kt
@@ -36,7 +36,6 @@
var light: Colors by mutableStateOf(lightColors())
var dark: Colors by mutableStateOf(darkColors())
- @Composable
val colors
- get() = if (isSystemInDarkTheme()) dark else light
+ @Composable get() = if (isSystemInDarkTheme()) dark else light
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
index 918997d..2020679 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
@@ -179,9 +179,8 @@
}
private object ThemingSnippet11 {
- @Composable
val Colors.snackbarAction: Color
- get() = if (isLight) Red300 else Red700
+ @Composable get() = if (isLight) Red300 else Red700
}
@Composable private fun ThemingSnippet12() {
diff --git a/compose/material/material/api/current.txt b/compose/material/material/api/current.txt
index a589728..e7608b9 100644
--- a/compose/material/material/api/current.txt
+++ b/compose/material/material/api/current.txt
@@ -14,13 +14,13 @@
public final class BackdropScaffoldConstants {
method public float getDefaultFrontLayerElevation-D9Ej5fM();
- method public long getDefaultFrontLayerScrimColor-0d7_KjU();
- method public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
+ method @androidx.compose.runtime.Composable public long getDefaultFrontLayerScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
method public float getDefaultHeaderHeight-D9Ej5fM();
method public float getDefaultPeekHeight-D9Ej5fM();
property public final float DefaultFrontLayerElevation;
- property public final long DefaultFrontLayerScrimColor;
- property public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
+ property @androidx.compose.runtime.Composable public final long DefaultFrontLayerScrimColor;
+ property @androidx.compose.runtime.Composable public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
property public final float DefaultHeaderHeight;
property public final float DefaultPeekHeight;
field public static final androidx.compose.material.BackdropScaffoldConstants INSTANCE;
@@ -141,7 +141,7 @@
method public float getDefaultIconSpacing-D9Ej5fM();
method public float getDefaultMinHeight-D9Ej5fM();
method public float getDefaultMinWidth-D9Ej5fM();
- method public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
+ method @androidx.compose.runtime.Composable public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
method public androidx.compose.foundation.layout.PaddingValues getDefaultTextContentPadding();
method public float getOutlinedBorderSize-D9Ej5fM();
property public final androidx.compose.foundation.layout.PaddingValues DefaultContentPadding;
@@ -151,7 +151,7 @@
property public final float DefaultMinWidth;
property public final androidx.compose.foundation.layout.PaddingValues DefaultTextContentPadding;
property public final float OutlinedBorderSize;
- property public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
+ property @androidx.compose.runtime.Composable public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
field public static final androidx.compose.material.ButtonConstants INSTANCE;
field public static final float OutlinedBorderOpacity = 0.12f;
}
@@ -224,12 +224,12 @@
}
public final class ContentAlpha {
- method public float getDisabled();
- method public float getHigh();
- method public float getMedium();
- property public final float disabled;
- property public final float high;
- property public final float medium;
+ method @androidx.compose.runtime.Composable public float getDisabled();
+ method @androidx.compose.runtime.Composable public float getHigh();
+ method @androidx.compose.runtime.Composable public float getMedium();
+ property @androidx.compose.runtime.Composable public final float disabled;
+ property @androidx.compose.runtime.Composable public final float high;
+ property @androidx.compose.runtime.Composable public final float medium;
field public static final androidx.compose.material.ContentAlpha INSTANCE;
}
@@ -272,9 +272,9 @@
public final class DrawerConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long defaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long defaultScrimColor;
field public static final androidx.compose.material.DrawerConstants INSTANCE;
field public static final float ScrimDefaultOpacity = 0.32f;
}
@@ -335,12 +335,12 @@
}
@Deprecated public interface EmphasisLevels {
- method @Deprecated public androidx.compose.material.Emphasis getDisabled();
- method @Deprecated public androidx.compose.material.Emphasis getHigh();
- method @Deprecated public androidx.compose.material.Emphasis getMedium();
- property public abstract androidx.compose.material.Emphasis disabled;
- property public abstract androidx.compose.material.Emphasis high;
- property public abstract androidx.compose.material.Emphasis medium;
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getDisabled();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getHigh();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getMedium();
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis disabled;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis high;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis medium;
}
@kotlin.RequiresOptIn(message="This material API is experimental and is likely to change or to be removed in" + " the future.") public @interface ExperimentalMaterialApi {
@@ -395,12 +395,12 @@
}
public final class MaterialTheme {
- method public androidx.compose.material.Colors getColors();
- method public androidx.compose.material.Shapes getShapes();
- method public androidx.compose.material.Typography getTypography();
- property public final androidx.compose.material.Colors colors;
- property public final androidx.compose.material.Shapes shapes;
- property public final androidx.compose.material.Typography typography;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Colors getColors();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Shapes getShapes();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Typography getTypography();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Colors colors;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Shapes shapes;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Typography typography;
field public static final androidx.compose.material.MaterialTheme INSTANCE;
}
@@ -415,9 +415,9 @@
public final class ModalBottomSheetConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long DefaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long DefaultScrimColor;
field public static final androidx.compose.material.ModalBottomSheetConstants INSTANCE;
}
@@ -536,10 +536,10 @@
}
public final class SnackbarConstants {
- method public long getDefaultActionPrimaryColor-0d7_KjU();
- method public long getDefaultBackgroundColor-0d7_KjU();
- property public final long defaultActionPrimaryColor;
- property public final long defaultBackgroundColor;
+ method @androidx.compose.runtime.Composable public long getDefaultActionPrimaryColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultBackgroundColor-0d7_KjU();
+ property @androidx.compose.runtime.Composable public final long defaultActionPrimaryColor;
+ property @androidx.compose.runtime.Composable public final long defaultBackgroundColor;
field public static final androidx.compose.material.SnackbarConstants INSTANCE;
}
diff --git a/compose/material/material/api/public_plus_experimental_current.txt b/compose/material/material/api/public_plus_experimental_current.txt
index a589728..e7608b9 100644
--- a/compose/material/material/api/public_plus_experimental_current.txt
+++ b/compose/material/material/api/public_plus_experimental_current.txt
@@ -14,13 +14,13 @@
public final class BackdropScaffoldConstants {
method public float getDefaultFrontLayerElevation-D9Ej5fM();
- method public long getDefaultFrontLayerScrimColor-0d7_KjU();
- method public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
+ method @androidx.compose.runtime.Composable public long getDefaultFrontLayerScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
method public float getDefaultHeaderHeight-D9Ej5fM();
method public float getDefaultPeekHeight-D9Ej5fM();
property public final float DefaultFrontLayerElevation;
- property public final long DefaultFrontLayerScrimColor;
- property public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
+ property @androidx.compose.runtime.Composable public final long DefaultFrontLayerScrimColor;
+ property @androidx.compose.runtime.Composable public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
property public final float DefaultHeaderHeight;
property public final float DefaultPeekHeight;
field public static final androidx.compose.material.BackdropScaffoldConstants INSTANCE;
@@ -141,7 +141,7 @@
method public float getDefaultIconSpacing-D9Ej5fM();
method public float getDefaultMinHeight-D9Ej5fM();
method public float getDefaultMinWidth-D9Ej5fM();
- method public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
+ method @androidx.compose.runtime.Composable public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
method public androidx.compose.foundation.layout.PaddingValues getDefaultTextContentPadding();
method public float getOutlinedBorderSize-D9Ej5fM();
property public final androidx.compose.foundation.layout.PaddingValues DefaultContentPadding;
@@ -151,7 +151,7 @@
property public final float DefaultMinWidth;
property public final androidx.compose.foundation.layout.PaddingValues DefaultTextContentPadding;
property public final float OutlinedBorderSize;
- property public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
+ property @androidx.compose.runtime.Composable public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
field public static final androidx.compose.material.ButtonConstants INSTANCE;
field public static final float OutlinedBorderOpacity = 0.12f;
}
@@ -224,12 +224,12 @@
}
public final class ContentAlpha {
- method public float getDisabled();
- method public float getHigh();
- method public float getMedium();
- property public final float disabled;
- property public final float high;
- property public final float medium;
+ method @androidx.compose.runtime.Composable public float getDisabled();
+ method @androidx.compose.runtime.Composable public float getHigh();
+ method @androidx.compose.runtime.Composable public float getMedium();
+ property @androidx.compose.runtime.Composable public final float disabled;
+ property @androidx.compose.runtime.Composable public final float high;
+ property @androidx.compose.runtime.Composable public final float medium;
field public static final androidx.compose.material.ContentAlpha INSTANCE;
}
@@ -272,9 +272,9 @@
public final class DrawerConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long defaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long defaultScrimColor;
field public static final androidx.compose.material.DrawerConstants INSTANCE;
field public static final float ScrimDefaultOpacity = 0.32f;
}
@@ -335,12 +335,12 @@
}
@Deprecated public interface EmphasisLevels {
- method @Deprecated public androidx.compose.material.Emphasis getDisabled();
- method @Deprecated public androidx.compose.material.Emphasis getHigh();
- method @Deprecated public androidx.compose.material.Emphasis getMedium();
- property public abstract androidx.compose.material.Emphasis disabled;
- property public abstract androidx.compose.material.Emphasis high;
- property public abstract androidx.compose.material.Emphasis medium;
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getDisabled();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getHigh();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getMedium();
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis disabled;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis high;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis medium;
}
@kotlin.RequiresOptIn(message="This material API is experimental and is likely to change or to be removed in" + " the future.") public @interface ExperimentalMaterialApi {
@@ -395,12 +395,12 @@
}
public final class MaterialTheme {
- method public androidx.compose.material.Colors getColors();
- method public androidx.compose.material.Shapes getShapes();
- method public androidx.compose.material.Typography getTypography();
- property public final androidx.compose.material.Colors colors;
- property public final androidx.compose.material.Shapes shapes;
- property public final androidx.compose.material.Typography typography;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Colors getColors();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Shapes getShapes();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Typography getTypography();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Colors colors;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Shapes shapes;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Typography typography;
field public static final androidx.compose.material.MaterialTheme INSTANCE;
}
@@ -415,9 +415,9 @@
public final class ModalBottomSheetConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long DefaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long DefaultScrimColor;
field public static final androidx.compose.material.ModalBottomSheetConstants INSTANCE;
}
@@ -536,10 +536,10 @@
}
public final class SnackbarConstants {
- method public long getDefaultActionPrimaryColor-0d7_KjU();
- method public long getDefaultBackgroundColor-0d7_KjU();
- property public final long defaultActionPrimaryColor;
- property public final long defaultBackgroundColor;
+ method @androidx.compose.runtime.Composable public long getDefaultActionPrimaryColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultBackgroundColor-0d7_KjU();
+ property @androidx.compose.runtime.Composable public final long defaultActionPrimaryColor;
+ property @androidx.compose.runtime.Composable public final long defaultBackgroundColor;
field public static final androidx.compose.material.SnackbarConstants INSTANCE;
}
diff --git a/compose/material/material/api/restricted_current.txt b/compose/material/material/api/restricted_current.txt
index a589728..e7608b9 100644
--- a/compose/material/material/api/restricted_current.txt
+++ b/compose/material/material/api/restricted_current.txt
@@ -14,13 +14,13 @@
public final class BackdropScaffoldConstants {
method public float getDefaultFrontLayerElevation-D9Ej5fM();
- method public long getDefaultFrontLayerScrimColor-0d7_KjU();
- method public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
+ method @androidx.compose.runtime.Composable public long getDefaultFrontLayerScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public androidx.compose.ui.graphics.Shape getDefaultFrontLayerShape();
method public float getDefaultHeaderHeight-D9Ej5fM();
method public float getDefaultPeekHeight-D9Ej5fM();
property public final float DefaultFrontLayerElevation;
- property public final long DefaultFrontLayerScrimColor;
- property public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
+ property @androidx.compose.runtime.Composable public final long DefaultFrontLayerScrimColor;
+ property @androidx.compose.runtime.Composable public final androidx.compose.ui.graphics.Shape DefaultFrontLayerShape;
property public final float DefaultHeaderHeight;
property public final float DefaultPeekHeight;
field public static final androidx.compose.material.BackdropScaffoldConstants INSTANCE;
@@ -141,7 +141,7 @@
method public float getDefaultIconSpacing-D9Ej5fM();
method public float getDefaultMinHeight-D9Ej5fM();
method public float getDefaultMinWidth-D9Ej5fM();
- method public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
+ method @androidx.compose.runtime.Composable public androidx.compose.foundation.BorderStroke getDefaultOutlinedBorder();
method public androidx.compose.foundation.layout.PaddingValues getDefaultTextContentPadding();
method public float getOutlinedBorderSize-D9Ej5fM();
property public final androidx.compose.foundation.layout.PaddingValues DefaultContentPadding;
@@ -151,7 +151,7 @@
property public final float DefaultMinWidth;
property public final androidx.compose.foundation.layout.PaddingValues DefaultTextContentPadding;
property public final float OutlinedBorderSize;
- property public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
+ property @androidx.compose.runtime.Composable public final androidx.compose.foundation.BorderStroke defaultOutlinedBorder;
field public static final androidx.compose.material.ButtonConstants INSTANCE;
field public static final float OutlinedBorderOpacity = 0.12f;
}
@@ -224,12 +224,12 @@
}
public final class ContentAlpha {
- method public float getDisabled();
- method public float getHigh();
- method public float getMedium();
- property public final float disabled;
- property public final float high;
- property public final float medium;
+ method @androidx.compose.runtime.Composable public float getDisabled();
+ method @androidx.compose.runtime.Composable public float getHigh();
+ method @androidx.compose.runtime.Composable public float getMedium();
+ property @androidx.compose.runtime.Composable public final float disabled;
+ property @androidx.compose.runtime.Composable public final float high;
+ property @androidx.compose.runtime.Composable public final float medium;
field public static final androidx.compose.material.ContentAlpha INSTANCE;
}
@@ -272,9 +272,9 @@
public final class DrawerConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long defaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long defaultScrimColor;
field public static final androidx.compose.material.DrawerConstants INSTANCE;
field public static final float ScrimDefaultOpacity = 0.32f;
}
@@ -335,12 +335,12 @@
}
@Deprecated public interface EmphasisLevels {
- method @Deprecated public androidx.compose.material.Emphasis getDisabled();
- method @Deprecated public androidx.compose.material.Emphasis getHigh();
- method @Deprecated public androidx.compose.material.Emphasis getMedium();
- property public abstract androidx.compose.material.Emphasis disabled;
- property public abstract androidx.compose.material.Emphasis high;
- property public abstract androidx.compose.material.Emphasis medium;
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getDisabled();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getHigh();
+ method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material.Emphasis getMedium();
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis disabled;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis high;
+ property @androidx.compose.runtime.Composable public abstract androidx.compose.material.Emphasis medium;
}
@kotlin.RequiresOptIn(message="This material API is experimental and is likely to change or to be removed in" + " the future.") public @interface ExperimentalMaterialApi {
@@ -395,12 +395,12 @@
}
public final class MaterialTheme {
- method public androidx.compose.material.Colors getColors();
- method public androidx.compose.material.Shapes getShapes();
- method public androidx.compose.material.Typography getTypography();
- property public final androidx.compose.material.Colors colors;
- property public final androidx.compose.material.Shapes shapes;
- property public final androidx.compose.material.Typography typography;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Colors getColors();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Shapes getShapes();
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public androidx.compose.material.Typography getTypography();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Colors colors;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Shapes shapes;
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final androidx.compose.material.Typography typography;
field public static final androidx.compose.material.MaterialTheme INSTANCE;
}
@@ -415,9 +415,9 @@
public final class ModalBottomSheetConstants {
method public float getDefaultElevation-D9Ej5fM();
- method public long getDefaultScrimColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultScrimColor-0d7_KjU();
property public final float DefaultElevation;
- property public final long DefaultScrimColor;
+ property @androidx.compose.runtime.Composable public final long DefaultScrimColor;
field public static final androidx.compose.material.ModalBottomSheetConstants INSTANCE;
}
@@ -536,10 +536,10 @@
}
public final class SnackbarConstants {
- method public long getDefaultActionPrimaryColor-0d7_KjU();
- method public long getDefaultBackgroundColor-0d7_KjU();
- property public final long defaultActionPrimaryColor;
- property public final long defaultBackgroundColor;
+ method @androidx.compose.runtime.Composable public long getDefaultActionPrimaryColor-0d7_KjU();
+ method @androidx.compose.runtime.Composable public long getDefaultBackgroundColor-0d7_KjU();
+ property @androidx.compose.runtime.Composable public final long defaultActionPrimaryColor;
+ property @androidx.compose.runtime.Composable public final long defaultBackgroundColor;
field public static final androidx.compose.material.SnackbarConstants INSTANCE;
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
index 4d4bad92..8fef88c 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
@@ -476,8 +476,8 @@
/**
* The default shape of the front layer.
*/
- @Composable
val DefaultFrontLayerShape: Shape
+ @Composable
get() = MaterialTheme.shapes.large
.copy(topLeft = CornerSize(16.dp), topRight = CornerSize(16.dp))
@@ -489,9 +489,8 @@
/**
* The default color of the scrim applied to the front layer.
*/
- @Composable
val DefaultFrontLayerScrimColor: Color
- get() = MaterialTheme.colors.surface.copy(alpha = 0.60f)
+ @Composable get() = MaterialTheme.colors.surface.copy(alpha = 0.60f)
}
private val AnimationSlideOffset = 20.dp
\ No newline at end of file
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
index cdeff5d..3ab1eb9 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
@@ -464,8 +464,8 @@
/**
* The default disabled content color used by all types of [Button]s
*/
- @Composable
val defaultOutlinedBorder: BorderStroke
+ @Composable
get() = BorderStroke(
OutlinedBorderSize, MaterialTheme.colors.onSurface.copy(alpha = OutlinedBorderOpacity)
)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
index f4e8a3b..1796da7 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
@@ -31,8 +31,8 @@
* A high level of content alpha, used to represent high emphasis text such as input text in a
* selected [TextField].
*/
- @Composable
val high: Float
+ @Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.high,
lowContrastAlpha = LowContrastContentAlpha.high
@@ -42,8 +42,8 @@
* A medium level of content alpha, used to represent medium emphasis text such as
* placeholder text in a [TextField].
*/
- @Composable
val medium: Float
+ @Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.medium,
lowContrastAlpha = LowContrastContentAlpha.medium
@@ -53,8 +53,8 @@
* A low level of content alpha used to represent disabled components, such as text in a
* disabled [Button].
*/
- @Composable
val disabled: Float
+ @Composable
get() = contentAlpha(
highContrastAlpha = HighContrastContentAlpha.disabled,
lowContrastAlpha = LowContrastContentAlpha.disabled
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
index 5cb78fb..6966244 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
@@ -537,8 +537,8 @@
*/
val DefaultElevation = 16.dp
- @Composable
val defaultScrimColor: Color
+ @Composable
get() = MaterialTheme.colors.onSurface.copy(alpha = ScrimDefaultOpacity)
/**
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Emphasis.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Emphasis.kt
index 307565a..e92850d 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Emphasis.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Emphasis.kt
@@ -80,18 +80,15 @@
/**
* Emphasis used to express high emphasis, such as for selected text fields.
*/
- @Composable
- val high: Emphasis
+ val high: Emphasis @Composable get
/**
* Emphasis used to express medium emphasis, such as for placeholder text in a text field.
*/
- @Composable
- val medium: Emphasis
+ val medium: Emphasis @Composable get
/**
* Emphasis used to express disabled state, such as for a disabled button.
*/
- @Composable
- val disabled: Emphasis
+ val disabled: Emphasis @Composable get
}
/**
@@ -148,24 +145,24 @@
}
}
- @Composable
override val high: Emphasis
+ @Composable
get() = AlphaEmphasis(
lightTheme = MaterialTheme.colors.isLight,
highContrastAlpha = HighContrastAlphaLevels.high,
reducedContrastAlpha = ReducedContrastAlphaLevels.high
)
- @Composable
override val medium: Emphasis
+ @Composable
get() = AlphaEmphasis(
lightTheme = MaterialTheme.colors.isLight,
highContrastAlpha = HighContrastAlphaLevels.medium,
reducedContrastAlpha = ReducedContrastAlphaLevels.medium
)
- @Composable
override val disabled: Emphasis
+ @Composable
get() = AlphaEmphasis(
lightTheme = MaterialTheme.colors.isLight,
highContrastAlpha = HighContrastAlphaLevels.disabled,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
index 0a1c321..8615164 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
@@ -94,9 +94,9 @@
*
* @sample androidx.compose.material.samples.ThemeColorSample
*/
- @Composable
- @ComposableContract(readonly = true)
val colors: Colors
+ @Composable
+ @ComposableContract(readonly = true)
get() = AmbientColors.current
/**
@@ -104,17 +104,17 @@
*
* @sample androidx.compose.material.samples.ThemeTextStyleSample
*/
- @Composable
- @ComposableContract(readonly = true)
val typography: Typography
+ @Composable
+ @ComposableContract(readonly = true)
get() = AmbientTypography.current
/**
* Retrieves the current [Shapes] at the call site's position in the hierarchy.
*/
- @Composable
- @ComposableContract(readonly = true)
val shapes: Shapes
+ @Composable
+ @ComposableContract(readonly = true)
get() = AmbientShapes.current
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
index 6e3b519..0605c16 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
@@ -332,7 +332,7 @@
/**
* The default scrim color used by [ModalBottomSheetLayout].
*/
- @Composable
val DefaultScrimColor: Color
+ @Composable
get() = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
index 41a9958..c539ad8 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
@@ -189,8 +189,8 @@
/**
* Default background color of the [Snackbar]
*/
- @Composable
val defaultBackgroundColor: Color
+ @Composable
get() =
MaterialTheme.colors.onSurface
.copy(alpha = SnackbarOverlayAlpha)
@@ -210,8 +210,8 @@
* [MaterialTheme.colors] to attempt to reduce the contrast, and when in a dark theme this
* function uses [Colors.primaryVariant].
*/
- @Composable
val defaultActionPrimaryColor: Color
+ @Composable
get() {
val colors = MaterialTheme.colors
return if (colors.isLight) {
diff --git a/compose/runtime/runtime/api/current.txt b/compose/runtime/runtime/api/current.txt
index 61b92204..bb71a06 100644
--- a/compose/runtime/runtime/api/current.txt
+++ b/compose/runtime/runtime/api/current.txt
@@ -24,8 +24,8 @@
}
@androidx.compose.runtime.Stable public abstract sealed class Ambient<T> {
- method public final inline T! getCurrent();
- property public final inline T! current;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! getCurrent();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! current;
}
public final class AmbientKt {
@@ -61,10 +61,10 @@
method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
method public abstract boolean preventCapture() default false;
method public abstract boolean readonly() default false;
method public abstract boolean restartable() default true;
@@ -129,7 +129,7 @@
}
public final class ComposerKt {
- method public static androidx.compose.runtime.Composer<?> getCurrentComposer();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.Composer<?> getCurrentComposer();
}
public interface Composition {
@@ -168,7 +168,7 @@
public final class EffectsKt {
method @androidx.compose.runtime.Composable public static androidx.compose.runtime.CompositionReference compositionReference();
- method public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
+ method @androidx.compose.runtime.Composable public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
method @androidx.compose.runtime.Composable public static void onActive(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static inline void onCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static <V1> void onCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
diff --git a/compose/runtime/runtime/api/public_plus_experimental_current.txt b/compose/runtime/runtime/api/public_plus_experimental_current.txt
index 61b92204..bb71a06 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_current.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_current.txt
@@ -24,8 +24,8 @@
}
@androidx.compose.runtime.Stable public abstract sealed class Ambient<T> {
- method public final inline T! getCurrent();
- property public final inline T! current;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! getCurrent();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! current;
}
public final class AmbientKt {
@@ -61,10 +61,10 @@
method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
method public abstract boolean preventCapture() default false;
method public abstract boolean readonly() default false;
method public abstract boolean restartable() default true;
@@ -129,7 +129,7 @@
}
public final class ComposerKt {
- method public static androidx.compose.runtime.Composer<?> getCurrentComposer();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.Composer<?> getCurrentComposer();
}
public interface Composition {
@@ -168,7 +168,7 @@
public final class EffectsKt {
method @androidx.compose.runtime.Composable public static androidx.compose.runtime.CompositionReference compositionReference();
- method public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
+ method @androidx.compose.runtime.Composable public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
method @androidx.compose.runtime.Composable public static void onActive(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static inline void onCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static <V1> void onCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
diff --git a/compose/runtime/runtime/api/restricted_current.txt b/compose/runtime/runtime/api/restricted_current.txt
index a649fe2..d12bc46 100644
--- a/compose/runtime/runtime/api/restricted_current.txt
+++ b/compose/runtime/runtime/api/restricted_current.txt
@@ -24,8 +24,8 @@
}
@androidx.compose.runtime.Stable public abstract sealed class Ambient<T> {
- method public final inline T! getCurrent();
- property public final inline T! current;
+ method @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! getCurrent();
+ property @androidx.compose.runtime.Composable @androidx.compose.runtime.ComposableContract(readonly=true) public final inline T! current;
}
public final class AmbientKt {
@@ -61,10 +61,10 @@
method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Composable {
}
- @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
+ @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ComposableContract {
method public abstract boolean preventCapture() default false;
method public abstract boolean readonly() default false;
method public abstract boolean restartable() default true;
@@ -137,7 +137,7 @@
}
public final class ComposerKt {
- method public static androidx.compose.runtime.Composer<?> getCurrentComposer();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.Composer<?> getCurrentComposer();
field @kotlin.PublishedApi internal static final androidx.compose.runtime.OpaqueKey ambientMap;
field @kotlin.PublishedApi internal static final int ambientMapKey = 202; // 0xca
field @kotlin.PublishedApi internal static final androidx.compose.runtime.OpaqueKey invocation;
@@ -194,7 +194,7 @@
public final class EffectsKt {
method @androidx.compose.runtime.Composable public static androidx.compose.runtime.CompositionReference compositionReference();
- method public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
+ method @androidx.compose.runtime.Composable public static kotlin.jvm.functions.Function0<kotlin.Unit> getInvalidate();
method @androidx.compose.runtime.Composable public static void onActive(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static inline void onCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
method @androidx.compose.runtime.Composable public static <V1> void onCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Ambient.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Ambient.kt
index 9bfa638..d01c5d3 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Ambient.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Ambient.kt
@@ -69,9 +69,10 @@
* @sample androidx.compose.runtime.samples.consumeAmbient
*/
@OptIn(ComposeCompilerApi::class)
- @ComposableContract(readonly = true)
- @Composable
- inline val current: T get() = currentComposer.consume(this)
+ inline val current: T
+ @ComposableContract(readonly = true)
+ @Composable
+ get() = currentComposer.consume(this)
}
/**
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composable.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composable.kt
index de94b47..f2375f85 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composable.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composable.kt
@@ -50,8 +50,14 @@
// foo: (@Composable () -> Unit) -> Unit
AnnotationTarget.TYPE_PARAMETER,
- // composable property declarations
+ // (DEPRECATED) composable property declarations
// @Composable val foo: Int get() { ... }
- AnnotationTarget.PROPERTY
+ AnnotationTarget.PROPERTY,
+
+ // composable property getters and setters
+ // val foo: Int @Composable get() { ... }
+ // var bar: Int
+ // @Composable get() { ... }
+ AnnotationTarget.PROPERTY_GETTER
)
annotation class Composable
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ComposableContract.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ComposableContract.kt
index 4a820a8..213e507 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ComposableContract.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ComposableContract.kt
@@ -45,7 +45,8 @@
@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.FUNCTION,
- AnnotationTarget.PROPERTY,
+ AnnotationTarget.PROPERTY, // (DEPRECATED)
+ AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.TYPE
)
annotation class ComposableContract(
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
index 206e8f4..85cf3e9 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composer.kt
@@ -2798,8 +2798,7 @@
private fun Boolean.asInt() = if (this) 1 else 0
private fun Int.asBool() = this != 0
-@Composable
-val currentComposer: Composer<*> get() {
+val currentComposer: Composer<*> @Composable get() {
throw NotImplementedError("Implemented as an intrinsic")
}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
index ea257ff..5f2a2b37 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
@@ -197,8 +197,7 @@
* An Effect to get the nearest invalidation lambda to the current point of composition. This can be used to
* trigger an invalidation on the composition locally to cause a recompose.
*/
-@Composable
-val invalidate: () -> Unit get() {
+val invalidate: () -> Unit @Composable get() {
val scope = currentComposer.currentRecomposeScope ?: error("no recompose scope found")
scope.used = true
return { scope.invalidate() }