Change String argument of property delegate method to PropertyMetadata

This commit is contained in:
Natalia.Ukhorskaya
2013-04-25 18:41:35 +04:00
parent 6e2584d0de
commit b9e5227b58
63 changed files with 174 additions and 83 deletions
+11
View File
@@ -64,3 +64,14 @@ public open class Throwable(message : String? = null, cause: Throwable? = null)
public fun getCause() : Throwable? public fun getCause() : Throwable?
public fun printStackTrace() : Unit 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
@@ -43,6 +43,7 @@ import org.jetbrains.jet.lang.types.DeferredType;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.List; import java.util.List;
@@ -136,9 +137,11 @@ public class DelegatedPropertyUtils {
List<JetExpression> arguments = Lists.newArrayList(); List<JetExpression> arguments = Lists.newArrayList();
arguments.add(createExpression(project, hasThis ? "this" : "null")); 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) { if (!isGet) {
JetReferenceExpression fakeArgument = createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace, JetReferenceExpression fakeArgument = (JetReferenceExpression) createFakeExpressionOfType(context.expressionTypingServices.getProject(), trace,
"fakeArgument" + arguments.size(), "fakeArgument" + arguments.size(),
propertyDescriptor.getType()); propertyDescriptor.getType());
arguments.add(fakeArgument); arguments.add(fakeArgument);
@@ -786,6 +786,16 @@ public class KotlinBuiltIns {
return getBuiltInTypeByClassName("Annotation"); return getBuiltInTypeByClassName("Annotation");
} }
@NotNull
public ClassDescriptor getPropertyMetadata() {
return getBuiltInClassByName("PropertyMetadata");
}
@NotNull
public ClassDescriptor getPropertyMetadataImpl() {
return getBuiltInClassByName("PropertyMetadataImpl");
}
@NotNull @NotNull
public JetType getFunctionType( public JetType getFunctionType(
@NotNull List<AnnotationDescriptor> annotations, @NotNull List<AnnotationDescriptor> annotations,
+9
View File
@@ -1356,6 +1356,15 @@ public trait Progression</*0*/ N : jet.Any> : jet.Iterable<N> {
public abstract override /*1*/ /*fake_override*/ fun iterator(): jet.Iterator<N> public abstract override /*1*/ /*fake_override*/ fun iterator(): jet.Iterator<N>
} }
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</*0*/ in T : jet.Comparable<T>> { public trait Range</*0*/ in T : jet.Comparable<T>> {
public abstract val end: T public abstract val end: T
public abstract val start: T public abstract val start: T
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
class B { class B {
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: Any?, p: String): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
class AImpl { class AImpl {
@@ -1,10 +1,10 @@
class Delegate { class Delegate {
var inner = Derived() var inner = Derived()
fun get(t: Any?, p: String): Derived { fun get(t: Any?, p: PropertyMetadata): Derived {
inner = Derived(inner.a + "-get") inner = Derived(inner.a + "-get")
return inner 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 { class A {
@@ -1,5 +1,5 @@
class Delegate { 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() val prop: Int by Delegate()
@@ -3,8 +3,8 @@ class A {
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
} }
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
class A { class A {
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
fun foo() = Delegate() fun foo() = Delegate()
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
val p = Delegate() val p = Delegate()
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: A, p: String): Int = 1 fun get(t: A, p: PropertyMetadata): Int = 1
} }
val A.prop: Int by Delegate() val A.prop: Int by Delegate()
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: F.A, p: String): Int = 1 fun get(t: F.A, p: PropertyMetadata): Int = 1
} }
class F { class F {
@@ -1,6 +1,6 @@
class Delegate<T>(var inner: T) { class Delegate<T>(var inner: T) {
fun get(t: Any?, p: String): T = inner fun get(t: Any?, p: PropertyMetadata): T = inner
fun set(t: Any?, p: String, i: T) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: T) { inner = i }
} }
class A { class A {
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
} }
fun Delegate.get(t: Any?, p: String): Int = 1 fun Delegate.get(t: Any?, p: PropertyMetadata): Int = 1
class A { class A {
val prop: Int by Delegate() val prop: Int by Delegate()
@@ -2,7 +2,7 @@ class Delegate {
} }
class A { 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() val prop: Int by Delegate()
} }
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: Any?, p: String): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
class A { class A {
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
class A { class A {
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: Any?, p: String): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
trait A { trait A {
@@ -1,6 +1,6 @@
class Delegate<T>(var inner: T) { class Delegate<T>(var inner: T) {
fun get(t: Any?, p: String): T = inner fun get(t: Any?, p: PropertyMetadata): T = inner
fun set(t: Any?, p: String, i: T) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: T) { inner = i }
} }
class A { class A {
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
class A { class A {
@@ -1,9 +1,9 @@
class Delegate { class Delegate {
var inner = 1 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 { class A {
var prop: Int by Delegate() var prop: Int by Delegate()
@@ -1,10 +1,10 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
} }
class A { 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() var prop: Int by Delegate()
} }
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: Any?, p: String): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
val prop: Int by Delegate() val prop: Int by Delegate()
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
var prop: Int by Delegate() var prop: Int by Delegate()
@@ -1,5 +1,5 @@
class Delegate<T>(val f: (T) -> Int) { class Delegate<T>(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<A> { t -> t.foo() } val p = Delegate<A> { t -> t.foo() }
@@ -1,5 +1,5 @@
class Delegate { class Delegate {
fun get(t: Any?, p: String): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
class A { class A {
@@ -1,7 +1,7 @@
class Delegate { class Delegate {
var inner = 1 var inner = 1
fun get(t: Any?, p: String): Int = inner fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: String, i: Int) { inner = i } fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
} }
class A { class A {
@@ -1,5 +1,5 @@
class Delegate { 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() val prop: Int by Delegate()
@@ -1,7 +1,7 @@
val a: Int by Delegate() val a: Int by Delegate()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -1,7 +1,7 @@
val a by Delegate() val a by Delegate()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -3,7 +3,7 @@ abstract class A {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -5,7 +5,7 @@ class B {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -11,7 +11,7 @@ fun foo() {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -11,7 +11,7 @@ fun foo() {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return "" return ""
} }
@@ -1,7 +1,7 @@
val a: Int by A(1) val a: Int by A(1)
class A<T: Any>(i: T) { class A<T: Any>(i: T) {
fun get(t: Any?, p: String): T { fun get(t: Any?, p: PropertyMetadata): T {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
throw Exception() throw Exception()
} }
@@ -4,7 +4,7 @@ class Derived: Base()
val a: Base by A() val a: Base by A()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived() return Derived()
} }
@@ -3,7 +3,7 @@ trait T {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -7,7 +7,7 @@ class D {
val cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!> val cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!>
class IncorrectThis<T> { class IncorrectThis<T> {
fun get<R>(t: Any?, p: String): Int { fun get<R>(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -5,7 +5,7 @@ class Local {
} }
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -1,7 +1,7 @@
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!> var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -3,7 +3,7 @@ class B {
} }
class Delegate<T: Any>(val init: T) { class Delegate<T: Any>(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 t.equals(p) // to avoid UNUSED_PARAMETER warning
throw Exception() throw Exception()
} }
@@ -1,7 +1,7 @@
<!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>public val a<!> by Delegate() <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>public val a<!> by Delegate()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -6,7 +6,7 @@ val c by <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>d<!>
val d by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>c<!> val d by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>c<!>
class Delegate(i: Int) { 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -2,7 +2,7 @@ val a: Int by Delegate()
<!ACCESSOR_FOR_DELEGATED_PROPERTY!>get() = 1<!> <!ACCESSOR_FOR_DELEGATED_PROPERTY!>get() = 1<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -3,12 +3,12 @@ var a: Int by Delegate()
<!ACCESSOR_FOR_DELEGATED_PROPERTY!>set(i) {}<!> <!ACCESSOR_FOR_DELEGATED_PROPERTY!>set(i) {}<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) || i.equals(null) // to avoid UNUSED_PARAMETER warning
} }
} }
@@ -7,11 +7,11 @@ var cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class A class A
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null) i.equals(null)
} }
@@ -4,12 +4,12 @@ class Derived: Base()
var a: Derived by A() var a: Derived by A()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived() 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null) // to avoid UNUSED_PARAMETER warning i.equals(null) // to avoid UNUSED_PARAMETER warning
} }
@@ -5,7 +5,7 @@ class A {
} }
class Delegate(i: Int) { 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -5,11 +5,11 @@ class A {
var aTopLevel: Int by Delegate() var aTopLevel: Int by Delegate()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
a.equals(null) a.equals(null)
} }
@@ -5,11 +5,11 @@ class A {
var aTopLevel: Int by Delegate() var aTopLevel: Int by Delegate()
class Delegate { class Delegate {
fun get(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: String): Int { fun get(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: PropertyMetadata): Int {
p.equals(null) // to avoid UNUSED_PARAMETER warning p.equals(null) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
fun set(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: String, a: Int) { fun set(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: PropertyMetadata, a: Int) {
p.equals(a) // to avoid UNUSED_PARAMETER warning p.equals(a) // to avoid UNUSED_PARAMETER warning
} }
} }
@@ -5,11 +5,11 @@ class A {
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!> var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate { class Delegate {
fun get(<!UNUSED_PARAMETER!>t<!>: Nothing, p: String): Int { fun get(<!UNUSED_PARAMETER!>t<!>: Nothing, p: PropertyMetadata): Int {
p.equals(null) // to avoid UNUSED_PARAMETER warning p.equals(null) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
fun set(<!UNUSED_PARAMETER!>t<!>: Nothing, p: String, a: Int) { fun set(<!UNUSED_PARAMETER!>t<!>: Nothing, p: PropertyMetadata, a: Int) {
p.equals(a) // to avoid UNUSED_PARAMETER warning p.equals(a) // to avoid UNUSED_PARAMETER warning
} }
} }
@@ -3,12 +3,12 @@ class A {
} }
class Delegate { class Delegate {
fun get(t: Int, p: String): Int { fun get(t: Int, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
fun get(t: String, p: String): Int { fun get(t: String, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -1,7 +1,7 @@
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>Delegate()<!> val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>Delegate()<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return "" return ""
} }
@@ -13,7 +13,7 @@ class C {
val cTopLevel: Int by Delegate<Nothing?>() val cTopLevel: Int by Delegate<Nothing?>()
class Delegate<T> { class Delegate<T> {
fun get(t: T, p: String): Int { fun get(t: T, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -5,11 +5,11 @@ class A {
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!> var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null) i.equals(null)
} }
@@ -7,7 +7,7 @@ val bTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class A class A
class Delegate { class Delegate {
fun get(t: A, p: String): Int { fun get(t: A, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 return 1
} }
@@ -5,7 +5,7 @@ class A {
val aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!> val aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return a return a
} }
@@ -5,12 +5,12 @@ class A {
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!> var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
c.equals(a) c.equals(a)
} }
@@ -1,12 +1,12 @@
var b: Int by Delegate() var b: Int by Delegate()
class 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1 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 t.equals(p) // to avoid UNUSED_PARAMETER warning
return i return i
} }
+25
View File
@@ -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();
}
+33
View File
@@ -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;
}
}