Add diagnostics for get/set methods of property delegate

This commit is contained in:
Natalia.Ukhorskaya
2013-04-16 15:41:25 +04:00
parent c58d4fd6d2
commit a9b4a342e7
24 changed files with 410 additions and 7 deletions
@@ -0,0 +1,18 @@
trait A {
val prop: Int
}
class AImpl: A {
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>prop<!> by Delegate()
}
fun foo() {
AImpl().prop
}
class Delegate {
fun get(t: Any?, p: String): String {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return ""
}
}
@@ -0,0 +1,9 @@
val a: Int by A(1)
class A<T: Any>(i: T) {
fun get(t: Any?, p: String): T {
t.equals(p) // to avoid UNUSED_PARAMETER warning
throw Exception()
}
}
@@ -0,0 +1,13 @@
open class Base
class Derived: Base()
val a: Base by A()
class A {
fun get(t: Any?, p: String): Derived {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived()
}
}
@@ -0,0 +1,14 @@
class A
class D {
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!>
}
val cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!>
class IncorrectThis<T> {
fun get<R>(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -0,0 +1,3 @@
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!>
class A
@@ -0,0 +1,8 @@
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!>
class A {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -0,0 +1,18 @@
class D {
var c: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
var cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class A
class Delegate {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: A, p: String, i: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null)
}
}
@@ -0,0 +1,17 @@
open class Base
class Derived: Base()
var a: Derived by A()
class A {
fun get(t: Any?, p: String): Derived {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived()
}
fun set(t: Any?, p: String, i: Base) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null) // to avoid UNUSED_PARAMETER warning
}
}
@@ -0,0 +1,16 @@
class A {
var a: Int by Delegate()
}
var aTopLevel: Int by Delegate()
class Delegate {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: String, a: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
a.equals(null)
}
}
@@ -0,0 +1,15 @@
class A {
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
var aTopLevel: Int by Delegate()
class Delegate {
fun get(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: String): Int {
p.equals(null) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(<!UNUSED_PARAMETER!>t<!>: Nothing?, p: String, a: Int) {
p.equals(a) // to avoid UNUSED_PARAMETER warning
}
}
@@ -0,0 +1,15 @@
class A {
var a: 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 {
fun get(<!UNUSED_PARAMETER!>t<!>: Nothing, p: String): Int {
p.equals(null) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(<!UNUSED_PARAMETER!>t<!>: Nothing, p: String, a: Int) {
p.equals(a) // to avoid UNUSED_PARAMETER warning
}
}
@@ -0,0 +1,15 @@
class A {
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
class Delegate {
fun get(t: Int, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun get(t: String, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -0,0 +1,8 @@
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: String): String {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return ""
}
}
@@ -0,0 +1,20 @@
class A
class B {
val b: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate<A>()<!>
}
val bTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate<A>()<!>
class C {
val c: Int by Delegate<C>()
}
val cTopLevel: Int by Delegate<Nothing?>()
class Delegate<T> {
fun get(t: T, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -0,0 +1,16 @@
class A {
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: String, i: String) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null)
}
}
@@ -0,0 +1,15 @@
class B {
val b: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
val bTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class A
class Delegate {
fun get(t: A, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -0,0 +1,12 @@
class A {
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
val aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: String, a: Int): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return a
}
}
@@ -0,0 +1,17 @@
class A {
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: String, a: Int, c: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
c.equals(a)
}
}
@@ -0,0 +1,13 @@
var b: Int by Delegate()
class Delegate {
fun get(t: Any?, p: String): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: String, i: Int): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return i
}
}