diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index b065ab24d87..dccfb3fd3b0 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -64,3 +64,14 @@ public open class Throwable(message : String? = null, cause: Throwable? = null) public fun getCause() : Throwable? public fun printStackTrace() : Unit } + +public trait PropertyMetadata { + public val name: String +} + +/* + * In front-end we need to resolve call PropertyMetadataImpl() in getter of delegated property + * to be able generate it in back-end using ExpressionCodegen.invokeFunction + */ +public class PropertyMetadataImpl(public override val name: String): PropertyMetadata + diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DelegatedPropertyUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DelegatedPropertyUtils.java index a8d2a38149d..2e38bbfcc0c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DelegatedPropertyUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/DelegatedPropertyUtils.java @@ -43,6 +43,7 @@ import org.jetbrains.jet.lang.types.DeferredType; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; +import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import java.util.List; @@ -136,9 +137,11 @@ public class DelegatedPropertyUtils { List arguments = Lists.newArrayList(); arguments.add(createExpression(project, hasThis ? "this" : "null")); - arguments.add(createExpression(project, "\"" + propertyDescriptor.getName().getName() + "\"")); + + arguments.add(createExpression(project, KotlinBuiltIns.getInstance().getPropertyMetadataImpl().getName().getName() + "(\"" + propertyDescriptor.getName().getName() + "\")")); + if (!isGet) { - JetReferenceExpression fakeArgument = createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace, + JetReferenceExpression fakeArgument = (JetReferenceExpression) createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace, "fakeArgument" + arguments.size(), propertyDescriptor.getType()); arguments.add(fakeArgument); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java index 2a82cfb938a..3057b763e8f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java @@ -786,6 +786,16 @@ public class KotlinBuiltIns { return getBuiltInTypeByClassName("Annotation"); } + @NotNull + public ClassDescriptor getPropertyMetadata() { + return getBuiltInClassByName("PropertyMetadata"); + } + + @NotNull + public ClassDescriptor getPropertyMetadataImpl() { + return getBuiltInClassByName("PropertyMetadataImpl"); + } + @NotNull public JetType getFunctionType( @NotNull List annotations, diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 2d95480ecb6..49213867dbf 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -1356,6 +1356,15 @@ public trait Progression : jet.Iterable { public abstract override /*1*/ /*fake_override*/ fun iterator(): jet.Iterator } +public trait PropertyMetadata { + public abstract val name: jet.String +} + +public final class PropertyMetadataImpl : jet.PropertyMetadata { + public constructor PropertyMetadataImpl(/*0*/ name: jet.String) + public open override /*1*/ val name: jet.String +} + public trait Range> { public abstract val end: T public abstract val start: T diff --git a/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt b/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt index d72c0a71362..c8859bd20db 100644 --- a/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt +++ b/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } class B { diff --git a/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt b/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt index 0430109a3fb..1e304fc609f 100644 --- a/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt +++ b/compiler/testData/codegen/box/delegatedProperty/castGetReturnType.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String): Int = 1 + fun get(t: Any?, p: PropertyMetadata): Int = 1 } class AImpl { diff --git a/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt b/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt index 18d4b2b65be..91ba84a3821 100644 --- a/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt +++ b/compiler/testData/codegen/box/delegatedProperty/castSetParameter.kt @@ -1,10 +1,10 @@ class Delegate { var inner = Derived() - fun get(t: Any?, p: String): Derived { + fun get(t: Any?, p: PropertyMetadata): Derived { inner = Derived(inner.a + "-get") return inner } - fun set(t: Any?, p: String, i: Base) { inner = Derived(inner.a + "-" + i.a + "-set") } + fun set(t: Any?, p: PropertyMetadata, i: Base) { inner = Derived(inner.a + "-" + i.a + "-set") } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt b/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt index e9bca328ca1..abb9cd6bd09 100644 --- a/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt +++ b/compiler/testData/codegen/box/delegatedProperty/defaultArgs.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String, s: String = ""): Int = 1 + fun get(t: Any?, p: PropertyMetadata, s: String = ""): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt index bf2b4d460d9..aa13f9cb5e0 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateAsInnerClass.kt @@ -3,8 +3,8 @@ class A { class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } } diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt index a8fde26abd4..1329f708dfe 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByOtherProperty.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt index 4f833a2599d..e8bc1bbe992 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelFun.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } fun foo() = Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt index 64a31724924..e0103969899 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateByTopLevelProperty.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } val p = Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt b/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt index 241e2c73701..754912349a7 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateForExtProperty.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: A, p: String): Int = 1 + fun get(t: A, p: PropertyMetadata): Int = 1 } val A.prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt index 8b4d864e750..40c82203866 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: F.A, p: String): Int = 1 + fun get(t: F.A, p: PropertyMetadata): Int = 1 } class F { diff --git a/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt b/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt index df58a8786d9..4f2043751a1 100644 --- a/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt +++ b/compiler/testData/codegen/box/delegatedProperty/genericDelegate.kt @@ -1,6 +1,6 @@ class Delegate(var inner: T) { - fun get(t: Any?, p: String): T = inner - fun set(t: Any?, p: String, i: T) { inner = i } + fun get(t: Any?, p: PropertyMetadata): T = inner + fun set(t: Any?, p: PropertyMetadata, i: T) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt index 5ba6fc6591f..fee5e1d7fbc 100644 --- a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt @@ -1,7 +1,7 @@ class Delegate { } -fun Delegate.get(t: Any?, p: String): Int = 1 +fun Delegate.get(t: Any?, p: PropertyMetadata): Int = 1 class A { val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt index 54cc48c953e..e0434b14155 100644 --- a/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/getAsExtensionFunInClass.kt @@ -2,7 +2,7 @@ class Delegate { } class A { - fun Delegate.get(t: Any?, p: String): Int = 1 + fun Delegate.get(t: Any?, p: PropertyMetadata): Int = 1 val prop: Int by Delegate() } diff --git a/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt b/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt index 49bfbf61299..52931d2061e 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inClassVal.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String): Int = 1 + fun get(t: Any?, p: PropertyMetadata): Int = 1 } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt b/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt index 8c5821c93b9..a9a12550217 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inClassVar.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inTrait.kt b/compiler/testData/codegen/box/delegatedProperty/inTrait.kt index 8e937d7e8ee..f9802ba1e3f 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inTrait.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inTrait.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String): Int = 1 + fun get(t: Any?, p: PropertyMetadata): Int = 1 } trait A { diff --git a/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt b/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt index 6c3ceebd1d2..fff6188290a 100644 --- a/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt +++ b/compiler/testData/codegen/box/delegatedProperty/inferredPropertyType.kt @@ -1,6 +1,6 @@ class Delegate(var inner: T) { - fun get(t: Any?, p: String): T = inner - fun set(t: Any?, p: String, i: T) { inner = i } + fun get(t: Any?, p: PropertyMetadata): T = inner + fun set(t: Any?, p: PropertyMetadata, i: T) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/privateVar.kt b/compiler/testData/codegen/box/delegatedProperty/privateVar.kt index 24e8ca00bae..9de3bf20066 100644 --- a/compiler/testData/codegen/box/delegatedProperty/privateVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/privateVar.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt index ab565dec7b3..fa6432c9922 100644 --- a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt +++ b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFun.kt @@ -1,9 +1,9 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner + fun get(t: Any?, p: PropertyMetadata): Int = inner } -fun Delegate.set(t: Any?, p: String, i: Int) { inner = i } +fun Delegate.set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } class A { var prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt index c0d9ab404df..bfd4100178a 100644 --- a/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/setAsExtensionFunInClass.kt @@ -1,10 +1,10 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner + fun get(t: Any?, p: PropertyMetadata): Int = inner } class A { - fun Delegate.set(t: Any?, p: String, i: Int) { inner = i } + fun Delegate.set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } var prop: Int by Delegate() } diff --git a/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt b/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt index 88a8977d8d1..6a8edfcb330 100644 --- a/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt +++ b/compiler/testData/codegen/box/delegatedProperty/topLevelVal.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String): Int = 1 + fun get(t: Any?, p: PropertyMetadata): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt b/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt index c8b16f8c8f2..1fcc7116867 100644 --- a/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt +++ b/compiler/testData/codegen/box/delegatedProperty/topLevelVar.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } var prop: Int by Delegate() diff --git a/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt b/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt index a59c4f03fbe..6eca6c0a38f 100644 --- a/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt +++ b/compiler/testData/codegen/box/delegatedProperty/twoPropByOneDelegete.kt @@ -1,5 +1,5 @@ class Delegate(val f: (T) -> Int) { - fun get(t: T, p: String): Int = f(t) + fun get(t: T, p: PropertyMetadata): Int = f(t) } val p = Delegate { t -> t.foo() } diff --git a/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt index f69c505ff95..2bb28dadbd8 100644 --- a/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/valInInnerClass.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, p: String): Int = 1 + fun get(t: Any?, p: PropertyMetadata): Int = 1 } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt b/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt index ea06f24afe1..698a00b6665 100644 --- a/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/varInInnerClass.kt @@ -1,7 +1,7 @@ class Delegate { var inner = 1 - fun get(t: Any?, p: String): Int = inner - fun set(t: Any?, p: String, i: Int) { inner = i } + fun get(t: Any?, p: PropertyMetadata): Int = inner + fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i } } class A { diff --git a/compiler/testData/codegen/box/delegatedProperty/vararg.kt b/compiler/testData/codegen/box/delegatedProperty/vararg.kt index c2a62d7729a..9eecf777daa 100644 --- a/compiler/testData/codegen/box/delegatedProperty/vararg.kt +++ b/compiler/testData/codegen/box/delegatedProperty/vararg.kt @@ -1,5 +1,5 @@ class Delegate { - fun get(t: Any?, vararg p: String): Int = 1 + fun get(t: Any?, vararg p: PropertyMetadata): Int = 1 } val prop: Int by Delegate() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt index 5c232f5ff8e..c4a8ceb461a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt @@ -1,7 +1,7 @@ val a: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt index 0d75a736a8f..876c6a2b393 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt @@ -1,7 +1,7 @@ val a by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt index bde9b008ffb..55f972067fb 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt @@ -3,7 +3,7 @@ abstract class A { } class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt b/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt index 59ef1fe52fb..45a8e7a63a3 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt @@ -5,7 +5,7 @@ class B { } class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt index c083c4a26ee..6c509dfb99a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt @@ -11,7 +11,7 @@ fun foo() { } class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt index cbff38ae8ce..487c9246821 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt @@ -11,7 +11,7 @@ fun foo() { } class Delegate { - fun get(t: Any?, p: String): String { + fun get(t: Any?, p: PropertyMetadata): String { t.equals(p) // to avoid UNUSED_PARAMETER warning return "" } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt index aa6cc48fec2..187ca3eb68a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt @@ -1,7 +1,7 @@ val a: Int by A(1) class A(i: T) { - fun get(t: Any?, p: String): T { + fun get(t: Any?, p: PropertyMetadata): T { t.equals(p) // to avoid UNUSED_PARAMETER warning throw Exception() } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt b/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt index 5decc059c4a..93b071a60b9 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt @@ -4,7 +4,7 @@ class Derived: Base() val a: Base by A() class A { - fun get(t: Any?, p: String): Derived { + fun get(t: Any?, p: PropertyMetadata): Derived { t.equals(p) // to avoid UNUSED_PARAMETER warning return Derived() } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt index 976d5794a38..cf0d84e4168 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt @@ -3,7 +3,7 @@ trait T { } class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt index 13db3588361..98b0efe3e83 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt @@ -7,7 +7,7 @@ class D { val cTopLevel: Int by IncorrectThis() class IncorrectThis { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt b/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt index 0b7ab901835..2091e93b649 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt @@ -5,7 +5,7 @@ class Local { } class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt index df9a5dec7a8..fb0eadce7e4 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt @@ -1,7 +1,7 @@ var a: Int by A() class A { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt index 0cac6de9ae3..ce3cca3e744 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt @@ -3,7 +3,7 @@ class B { } class Delegate(val init: T) { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning throw Exception() } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt index 06f82b0fdfb..b29e03bb054 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt @@ -1,7 +1,7 @@ public val a by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt index 94643d045ee..2f95a3a9bf7 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt @@ -6,7 +6,7 @@ val c by d val d by c class Delegate(i: Int) { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt index 874f6787458..2d4a883ffb7 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt @@ -2,7 +2,7 @@ val a: Int by Delegate() get() = 1 class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt index d0a18373881..0fd4a41b87f 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt @@ -3,12 +3,12 @@ var a: Int by Delegate() set(i) {} class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: String, i: Int) { + fun set(t: Any?, p: PropertyMetadata, i: Int) { t.equals(p) || i.equals(null) // to avoid UNUSED_PARAMETER warning } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt index 50fed3e252c..458eb6d0d4e 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt @@ -7,11 +7,11 @@ var cTopLevel: Int by Delegate() class A class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: A, p: String, i: Int) { + fun set(t: A, p: PropertyMetadata, i: Int) { t.equals(p) // to avoid UNUSED_PARAMETER warning i.equals(null) } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt b/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt index 0511b2cd9de..3d2d00e3242 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt @@ -4,12 +4,12 @@ class Derived: Base() var a: Derived by A() class A { - fun get(t: Any?, p: String): Derived { + fun get(t: Any?, p: PropertyMetadata): Derived { t.equals(p) // to avoid UNUSED_PARAMETER warning return Derived() } - fun set(t: Any?, p: String, i: Base) { + fun set(t: Any?, p: PropertyMetadata, i: Base) { t.equals(p) // to avoid UNUSED_PARAMETER warning i.equals(null) // to avoid UNUSED_PARAMETER warning } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt index c8744d12581..9486d767a16 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt @@ -5,7 +5,7 @@ class A { } class Delegate(i: Int) { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt index 1b6ca1f9cdd..d56376db4f0 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt @@ -5,11 +5,11 @@ class A { var aTopLevel: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: String, a: Int) { + fun set(t: Any?, p: PropertyMetadata, a: Int) { t.equals(p) // to avoid UNUSED_PARAMETER warning a.equals(null) } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt index 3891f75b49a..d23ddca1a74 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt @@ -5,11 +5,11 @@ class A { var aTopLevel: Int by Delegate() class Delegate { - fun get(t: Nothing?, p: String): Int { + fun get(t: Nothing?, p: PropertyMetadata): Int { p.equals(null) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Nothing?, p: String, a: Int) { + fun set(t: Nothing?, p: PropertyMetadata, a: Int) { p.equals(a) // to avoid UNUSED_PARAMETER warning } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt index 67b40d3d771..6ef3066c6fd 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt @@ -5,11 +5,11 @@ class A { var aTopLevel: Int by Delegate() class Delegate { - fun get(t: Nothing, p: String): Int { + fun get(t: Nothing, p: PropertyMetadata): Int { p.equals(null) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Nothing, p: String, a: Int) { + fun set(t: Nothing, p: PropertyMetadata, a: Int) { p.equals(a) // to avoid UNUSED_PARAMETER warning } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.kt b/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.kt index b5e27c3463c..750633291b7 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.kt @@ -3,12 +3,12 @@ class A { } class Delegate { - fun get(t: Int, p: String): Int { + fun get(t: Int, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun get(t: String, p: String): Int { + fun get(t: String, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt index 420148ba427..4fcbbc24737 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt @@ -1,7 +1,7 @@ val c: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): String { + fun get(t: Any?, p: PropertyMetadata): String { t.equals(p) // to avoid UNUSED_PARAMETER warning return "" } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.kt index 753f43b294d..0f782fe4613 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.kt @@ -13,7 +13,7 @@ class C { val cTopLevel: Int by Delegate() class Delegate { - fun get(t: T, p: String): Int { + fun get(t: T, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt index 6a16abc95c5..0928ba015b8 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt @@ -5,11 +5,11 @@ class A { var aTopLevel: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: String, i: String) { + fun set(t: Any?, p: PropertyMetadata, i: String) { t.equals(p) // to avoid UNUSED_PARAMETER warning i.equals(null) } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt index e63fe6b452e..69062bb195c 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt @@ -7,7 +7,7 @@ val bTopLevel: Int by Delegate() class A class Delegate { - fun get(t: A, p: String): Int { + fun get(t: A, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt index 0d62ed1565b..520af500155 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt @@ -5,7 +5,7 @@ class A { val aTopLevel: Int by Delegate() class Delegate { - fun get(t: Any?, p: String, a: Int): Int { + fun get(t: Any?, p: PropertyMetadata, a: Int): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return a } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt index 69c8226e6ef..2f013451201 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt @@ -5,12 +5,12 @@ class A { var aTopLevel: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: String, a: Int, c: Int) { + fun set(t: Any?, p: PropertyMetadata, a: Int, c: Int) { t.equals(p) // to avoid UNUSED_PARAMETER warning c.equals(a) } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt index 15322a45b0f..0238a1c5560 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt @@ -1,12 +1,12 @@ var b: Int by Delegate() class Delegate { - fun get(t: Any?, p: String): Int { + fun get(t: Any?, p: PropertyMetadata): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: String, i: Int): Int { + fun set(t: Any?, p: PropertyMetadata, i: Int): Int { t.equals(p) // to avoid UNUSED_PARAMETER warning return i } diff --git a/runtime/src/jet/PropertyMetadata.java b/runtime/src/jet/PropertyMetadata.java new file mode 100644 index 00000000000..2ea69106c09 --- /dev/null +++ b/runtime/src/jet/PropertyMetadata.java @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2013 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 jet; + +import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; + +@AssertInvisibleInResolver +public interface PropertyMetadata { + + public String getName(); +} diff --git a/runtime/src/jet/PropertyMetadataImpl.java b/runtime/src/jet/PropertyMetadataImpl.java new file mode 100644 index 00000000000..245f5131f87 --- /dev/null +++ b/runtime/src/jet/PropertyMetadataImpl.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2013 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 jet; + +import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver; + +@AssertInvisibleInResolver +public class PropertyMetadataImpl implements PropertyMetadata { + private final String name; + + public PropertyMetadataImpl(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } +}