From 7b3b157707939d16a9772aa45c008edb2bfba4a1 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 20 Nov 2015 16:37:47 +0300 Subject: [PATCH] Remove PropertyMetadata from project and bytecode, migrate code to KProperty --- .../kotlin/codegen/MemberCodegen.java | 10 ++++---- .../kotlin/codegen/PropertyCodegen.java | 14 ++++++----- .../src/org/jetbrains/kotlin/container/Dsl.kt | 10 +++++--- .../kotlin/resolve/jvm/AsmTypes.java | 2 +- ...recatedGetSetPropertyDelegateConvention.kt | 10 ++++---- ...ecatedGetSetPropertyDelegateConvention.txt | 8 +++--- .../specialNames/propertyMetadataCache.kt | 8 +++--- .../specialNames/propertyMetadataCache.txt | 4 +-- .../jetbrains/kotlin/tests/di/injection.kt | 2 +- .../kotlin/builtins/ReflectionTypes.kt | 5 ++-- .../renderer/DescriptorRendererOptionsImpl.kt | 25 +++++-------------- .../src/kotlin/PropertyMetadataImpl.kt | 16 ++++++++++++ .../org/jetbrains/kotlin/storage/storage.kt | 6 +++-- idea/testData/inspections/cleanup/cleanup.kt | 5 ++-- .../autoImports/delegateExtensionBoth.test | 8 +++--- .../autoImports/delegateExtensionGet.test | 6 +++-- .../autoImports/delegateExtensionSet.test | 8 +++--- .../deprecatedDelegatesGetSetExtension.kt | 4 ++- ...eprecatedDelegatesGetSetExtension.kt.after | 4 ++- .../deprecatedDelegatesGetSetMember.kt | 6 +++-- .../deprecatedDelegatesGetSetMember.kt.after | 6 +++-- .../js/ast/metadata/MetadataProperty.kt | 6 +++-- 22 files changed, 99 insertions(+), 74 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index f054b59f966..4474946e2b7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -484,13 +484,13 @@ public abstract class MemberCodegen Unit): StorageComponentContainer { val c = StorageComponentContainer(id) c.init() @@ -24,11 +26,11 @@ public fun createContainer(id: String, init: StorageComponentContainer.() -> Uni } public inline fun StorageComponentContainer.useImpl() { - registerSingleton(javaClass()) + registerSingleton(T::class.java) } public inline fun ComponentProvider.get(): T { - return getService(javaClass()) + return getService(T::class.java) } @Suppress("UNCHECKED_CAST") @@ -40,6 +42,6 @@ public fun StorageComponentContainer.useInstance(instance: Any) { registerInstance(instance) } -inline operator fun ComponentProvider.getValue(thisRef: Any?, desc: PropertyMetadata): T { - return getService(javaClass()) +inline operator fun ComponentProvider.getValue(thisRef: Any?, desc: KProperty<*>): T { + return getService(T::class.java) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index f2e46e210fa..4f44b25234d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -31,7 +31,6 @@ public class AsmTypes { public static final Type JAVA_CLASS_TYPE = getType(Class.class); public static final Type UNIT_TYPE = Type.getObjectType("kotlin/Unit"); - public static final Type PROPERTY_METADATA_TYPE = Type.getObjectType("kotlin/PropertyMetadata"); public static final Type LAMBDA = Type.getObjectType("kotlin/jvm/internal/Lambda"); public static final Type FUNCTION_REFERENCE = Type.getObjectType("kotlin/jvm/internal/FunctionReference"); @@ -59,6 +58,7 @@ public class AsmTypes { public static final Type K_FUNCTION = reflect("KFunction"); + public static final Type K_PROPERTY_TYPE = reflect("KProperty"); public static final Type K_PROPERTY0_TYPE = reflect("KProperty0"); public static final Type K_PROPERTY1_TYPE = reflect("KProperty1"); public static final Type K_PROPERTY2_TYPE = reflect("KProperty2"); diff --git a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt index af3c117da9d..8e2d976c51d 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt +++ b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt @@ -25,11 +25,11 @@ class CustomDelegate3 { operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {} } -operator fun OkDelegate.get(thisRef: Any?, prop: PropertyMetadata): Int = 4 -operator fun OkDelegate.set(thisRef: Any?, prop: PropertyMetadata, value: Int) {} +operator fun OkDelegate.get(thisRef: Any?, prop: KProperty<*>): Int = 4 +operator fun OkDelegate.set(thisRef: Any?, prop: KProperty<*>, value: Int) {} -operator fun CustomDelegate3.getValue(thisRef: Any?, prop: PropertyMetadata): Int = 4 -operator fun CustomDelegate3.setValue(thisRef: Any?, prop: PropertyMetadata, value: Int) {} +operator fun CustomDelegate3.getValue(thisRef: Any?, prop: KProperty<*>): Int = 4 +operator fun CustomDelegate3.setValue(thisRef: Any?, prop: KProperty<*>, value: Int) {} class Example { @@ -50,4 +50,4 @@ class Example { fun requireString(s: String) {} fun requireInt(n: Int) {} -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.txt b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.txt index f63e4eeef54..3b00c151055 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.txt +++ b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.txt @@ -1,9 +1,9 @@ package -public operator fun OkDelegate.get(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.PropertyMetadata): kotlin.Int -public operator fun CustomDelegate3.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.PropertyMetadata): kotlin.Int -public operator fun OkDelegate.set(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.PropertyMetadata, /*2*/ value: kotlin.Int): kotlin.Unit -public operator fun CustomDelegate3.setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.PropertyMetadata, /*2*/ value: kotlin.Int): kotlin.Unit +public operator fun OkDelegate.get(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.Int +public operator fun CustomDelegate3.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.Int +public operator fun OkDelegate.set(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>, /*2*/ value: kotlin.Int): kotlin.Unit +public operator fun CustomDelegate3.setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>, /*2*/ value: kotlin.Int): kotlin.Unit public final class CustomDelegate { public constructor CustomDelegate() diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.kt index 0f3bf488777..5665a113107 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.kt @@ -1,11 +1,13 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KProperty operator fun Any.getValue(x: Any?, y: Any): Any = null!! class C { val x by 1 - val `$$delegatedProperties`: Array = null!! + val `$$delegatedProperties`: Array> = null!! } val x by 1 -val `$$delegatedProperties`: Array = null!! \ No newline at end of file +val `$$delegatedProperties`: Array> = null!! diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.txt index f126aedfa6e..93ef9448f6a 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/propertyMetadataCache.txt @@ -1,12 +1,12 @@ package -public val `$$delegatedProperties`: kotlin.Array +public val `$$delegatedProperties`: kotlin.Array> public val x: kotlin.Any public operator fun kotlin.Any.getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any): kotlin.Any public final class C { public constructor C() - public final val `$$delegatedProperties`: kotlin.Array + public final val `$$delegatedProperties`: kotlin.Array> public final val x: kotlin.Any public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt b/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt index 70340bbef40..dbfc43fb8ef 100644 --- a/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt +++ b/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt @@ -44,4 +44,4 @@ class ContainerForTests(container: StorageComponentContainer) { val typeResolver: TypeResolver by container val fakeCallResolver: FakeCallResolver by container val expressionTypingServices: ExpressionTypingServices by container -} \ No newline at end of file +} diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 7de395bf7d2..7ec3c9bc36b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies import org.jetbrains.kotlin.types.* import java.util.* +import kotlin.reflect.KProperty val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect") @@ -43,7 +44,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { } private object ClassLookup { - operator fun getValue(types: ReflectionTypes, property: PropertyMetadata): ClassDescriptor { + operator fun getValue(types: ReflectionTypes, property: KProperty<*>): ClassDescriptor { return types.find(property.name.capitalize()) } } @@ -75,7 +76,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { ): KotlinType { val arguments = KotlinBuiltIns.getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType) - val classDescriptor = getKFunction(arguments.size() - 1 /* return type */) + val classDescriptor = getKFunction(arguments.size - 1 /* return type */) if (ErrorUtils.isError(classDescriptor)) { return classDescriptor.defaultType diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index 0d4235cfcc9..36a38e6ee68 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -19,12 +19,10 @@ package org.jetbrains.kotlin.renderer import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.types.KotlinType import java.lang.reflect.Modifier +import kotlin.jvm.internal.PropertyReference1Impl import kotlin.properties.Delegates import kotlin.properties.ObservableProperty import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KParameter -import kotlin.reflect.KProperty -import kotlin.reflect.KType internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { public var isLocked: Boolean = false @@ -43,22 +41,11 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { if (field.modifiers.and(Modifier.STATIC) != 0) continue field.isAccessible = true val property = field.get(this) as? ObservableProperty<*> ?: continue - val value = property.getValue(this, object : KProperty, PropertyMetadata { - override val parameters: List - get() = error("Should not be called") - override val returnType: KType - get() = error("Should not be called") - override val getter: KProperty.Getter - get() = error("Should not be called") - override val annotations: List - get() = error("Should not be called") - - override fun call(vararg args: Any?): Any? = error("Should not be called") - - override fun callBy(args: Map): Any? = error("Should not be called") - - override val name = "" /* not used */ - }) + assert(!field.name.startsWith("is")) { "Fields named is* are not supported here yet" } + val value = property.getValue( + this, + PropertyReference1Impl(DescriptorRendererOptionsImpl::class, field.name, "get" + field.name.capitalize()) + ) field.set(copy, copy.property(value as Any)) } diff --git a/core/runtime.jvm/src/kotlin/PropertyMetadataImpl.kt b/core/runtime.jvm/src/kotlin/PropertyMetadataImpl.kt index e5e35f183fe..fef5173a511 100644 --- a/core/runtime.jvm/src/kotlin/PropertyMetadataImpl.kt +++ b/core/runtime.jvm/src/kotlin/PropertyMetadataImpl.kt @@ -14,6 +14,22 @@ * limitations under the License. */ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package kotlin @Deprecated("Please use KProperty instead.") diff --git a/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt b/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt index e7b26b1179a..c211164493f 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/storage/storage.kt @@ -16,6 +16,8 @@ package org.jetbrains.kotlin.storage +import kotlin.reflect.KProperty + public interface MemoizedFunctionToNotNull : Function1 { public fun isComputed(key: P): Boolean } @@ -32,6 +34,6 @@ public interface NullableLazyValue : Function0 { public fun isComputed(): Boolean } -public operator fun NotNullLazyValue.getValue(_this: Any?, p: PropertyMetadata): T = invoke() +public operator fun NotNullLazyValue.getValue(_this: Any?, p: KProperty<*>): T = invoke() -public operator fun NullableLazyValue.getValue(_this: Any?, p: PropertyMetadata): T? = invoke() +public operator fun NullableLazyValue.getValue(_this: Any?, p: KProperty<*>): T? = invoke() diff --git a/idea/testData/inspections/cleanup/cleanup.kt b/idea/testData/inspections/cleanup/cleanup.kt index 201b3b2f8ac..62591c17ab1 100644 --- a/idea/testData/inspections/cleanup/cleanup.kt +++ b/idea/testData/inspections/cleanup/cleanup.kt @@ -1,6 +1,7 @@ import pack.oldFun1 import pack.oldFun2 // should not be removed for non-deprecated overload used import pack.oldFun3 +import kotlin.reflect.KProperty class A private() @@ -40,8 +41,8 @@ annotation class Fancy(val param: Int) @Fancy(i) class D class CustomDelegate { - operator fun get(thisRef: Any?, prop: PropertyMetadata): String = "" - operator fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {} + operator fun get(thisRef: Any?, prop: KProperty<*>): String = "" + operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {} } class B { diff --git a/idea/testData/quickfix/autoImports/delegateExtensionBoth.test b/idea/testData/quickfix/autoImports/delegateExtensionBoth.test index 57798f91f3e..cd4cabbd351 100644 --- a/idea/testData/quickfix/autoImports/delegateExtensionBoth.test +++ b/idea/testData/quickfix/autoImports/delegateExtensionBoth.test @@ -15,12 +15,14 @@ class BigTest { // FILE: second.kt package some +import kotlin.reflect.KProperty + class DelegateImpl { val value: T = null!! } -public fun DelegateImpl.getValue(thisRef: Any?, property: PropertyMetadata): T = value -public fun DelegateImpl.setValue(thisRef: Any, propertyMetadata: PropertyMetadata, t: T) {} +public fun DelegateImpl.getValue(thisRef: Any?, property: KProperty<*>): T = value +public fun DelegateImpl.setValue(thisRef: Any, property: KProperty<*>, t: T) {} @@ -38,5 +40,3 @@ import some.setValue class BigTest { var a by DelegateImpl() } - - diff --git a/idea/testData/quickfix/autoImports/delegateExtensionGet.test b/idea/testData/quickfix/autoImports/delegateExtensionGet.test index c5b31802465..76c78eb46c6 100644 --- a/idea/testData/quickfix/autoImports/delegateExtensionGet.test +++ b/idea/testData/quickfix/autoImports/delegateExtensionGet.test @@ -15,11 +15,13 @@ class BigTest { // FILE: second.kt package some +import kotlin.reflect.KProperty + class DelegateImpl { val value: T = null!! } -public fun DelegateImpl.getValue(thisRef: Any?, property: PropertyMetadata): T = value +public fun DelegateImpl.getValue(thisRef: Any?, property: KProperty<*>): T = value @@ -34,4 +36,4 @@ import some.getValue class BigTest { val a by DelegateImpl() -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/autoImports/delegateExtensionSet.test b/idea/testData/quickfix/autoImports/delegateExtensionSet.test index cc3cb1e2c6a..1d83d5ba9f8 100644 --- a/idea/testData/quickfix/autoImports/delegateExtensionSet.test +++ b/idea/testData/quickfix/autoImports/delegateExtensionSet.test @@ -15,12 +15,14 @@ class BigTest { // FILE: second.kt package some +import kotlin.reflect.KProperty + class DelegateImpl { val value: T = null!! } -operator fun DelegateImpl.getValue(thisRef: Any?, property: PropertyMetadata): T = value -operator fun DelegateImpl.setValue(thisRef: Any, propertyMetadata: PropertyMetadata, t: T) {} +operator fun DelegateImpl.getValue(thisRef: Any?, property: KProperty<*>): T = value +operator fun DelegateImpl.setValue(thisRef: Any, property: KProperty<*>, t: T) {} @@ -37,5 +39,3 @@ import some.setValue class BigTest { var a by DelegateImpl() } - - diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt index 8f6d1073dfb..a3437560425 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt @@ -1,7 +1,9 @@ // "Rename to 'getValue'" "true" +import kotlin.reflect.KProperty + class CustomDelegate -operator fun CustomDelegate.get(thisRef: Any?, prop: PropertyMetadata): String = "" +operator fun CustomDelegate.get(thisRef: Any?, prop: KProperty<*>): String = "" class Example { val a: String by CustomDelegate() diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt.after b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt.after index bc2d89e7442..b0e39ad01f5 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt.after +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt.after @@ -1,7 +1,9 @@ // "Rename to 'getValue'" "true" +import kotlin.reflect.KProperty + class CustomDelegate -operator fun CustomDelegate.getValue(thisRef: Any?, prop: PropertyMetadata): String = "" +operator fun CustomDelegate.getValue(thisRef: Any?, prop: KProperty<*>): String = "" class Example { val a: String by CustomDelegate() diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt index 737c9d7c871..c760615fea2 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt @@ -1,9 +1,11 @@ // "Rename to 'setValue'" "true" // ERROR: 'get' method convention on type 'CustomDelegate' is deprecated. Rename to 'getValue' +import kotlin.reflect.KProperty + class CustomDelegate { - operator fun get(thisRef: Any?, prop: PropertyMetadata): String = "" - operator fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {} + operator fun get(thisRef: Any?, prop: KProperty<*>): String = "" + operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {} } class Example { diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after index 485ed7e9dbf..ca309314bd4 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt.after @@ -1,9 +1,11 @@ // "Rename to 'setValue'" "true" // ERROR: 'get' method convention on type 'CustomDelegate' is deprecated. Rename to 'getValue' +import kotlin.reflect.KProperty + class CustomDelegate { - operator fun get(thisRef: Any?, prop: PropertyMetadata): String = "" - operator fun setValue(thisRef: Any?, prop: PropertyMetadata, value: String) {} + operator fun get(thisRef: Any?, prop: KProperty<*>): String = "" + operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {} } class Example { diff --git a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/metadata/MetadataProperty.kt b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/metadata/MetadataProperty.kt index 21414e1d7a3..51bee2888e4 100644 --- a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/metadata/MetadataProperty.kt +++ b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/metadata/MetadataProperty.kt @@ -16,13 +16,15 @@ package com.google.dart.compiler.backend.js.ast.metadata +import kotlin.reflect.KProperty + internal class MetadataProperty(val default: R) { - operator fun getValue(thisRef: T, desc: PropertyMetadata): R { + operator fun getValue(thisRef: T, desc: KProperty<*>): R { if (!thisRef.hasData(desc.name)) return default return thisRef.getData(desc.name) } - operator fun setValue(thisRef: T, desc: PropertyMetadata, value: R) { + operator fun setValue(thisRef: T, desc: KProperty<*>, value: R) { thisRef.setData(desc.name, value) } }