Tests for diagnostics on this and super are moved and broken into smaller parts

This commit is contained in:
Andrey Breslav
2012-11-01 19:29:06 +04:00
parent a0cd26960a
commit 20906e34ce
11 changed files with 126 additions and 79 deletions
@@ -0,0 +1,12 @@
// FILE: f.kt
class A() {
fun foo() : Unit {
this@A
this<!UNRESOLVED_REFERENCE!>@a<!>
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
@@ -0,0 +1,64 @@
package example;
trait T {
fun foo() {}
}
open class C() {
fun bar() {}
}
class A<E>() : C(), T {
fun test() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
<!AMBIGUOUS_SUPER!>super<!>.foo()
super<T>.foo()
super<C>.bar()
super<T>@A.foo()
super<C>@A.bar()
super<<!NOT_A_SUPERTYPE!>E<!>>.bar()
super<<!NOT_A_SUPERTYPE!>E<!>>@A.bar()
super<<!NOT_A_SUPERTYPE!>Int<!>>.foo()
super<<!SYNTAX!><!>>.foo()
super<<!NOT_A_SUPERTYPE!>() -> Unit<!>>.foo()
super<<!NOT_A_SUPERTYPE!>Unit<!>>.foo()
super<T><!UNRESOLVED_REFERENCE!>@B<!>.foo()
super<C><!UNRESOLVED_REFERENCE!>@B<!>.bar()
}
class B : T {
fun test() {
super<T>.foo();
super<<!NOT_A_SUPERTYPE!>C<!>>.bar()
super<C>@A.bar()
super<T>@A.foo()
super<T>@B.foo()
super<<!NOT_A_SUPERTYPE!>C<!>>@B.foo()
super.foo()
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
}
}
}
trait G<T> {
fun foo() {}
}
class CG : G<Int> {
fun test() {
super<G>.foo() // OK
super<G<!TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER!><Int><!>>.foo() // Warning
super<<!NOT_A_SUPERTYPE!>G<<!UNRESOLVED_REFERENCE!>E<!>><!>>.foo() // Error
super<<!NOT_A_SUPERTYPE!>G<String><!>>.foo() // Error
}
}
// The case when no supertype is resolved
class ERROR<E>() : <!UNRESOLVED_REFERENCE!>UR<!> {
fun test() {
super.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
@@ -0,0 +1,5 @@
class Dup {
fun Dup() : Unit {
this<!AMBIGUOUS_LABEL!>@Dup<!>
}
}
@@ -0,0 +1,6 @@
// No supertype at all
class A1 {
fun test() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.equals(null) // Call to an extension function
}
}
@@ -0,0 +1,5 @@
fun foo() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
}
@@ -0,0 +1,12 @@
fun any(<!UNUSED_PARAMETER!>a<!> : Any) {}
fun notAnExpression() {
any(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) // not an expression
if (<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) {} else {} // not an expression
val <!UNUSED_VARIABLE!>x<!> = <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> // not an expression
when (1) {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> -> 1 // not an expression
else -> {}
}
}
@@ -0,0 +1,17 @@
class A(val a:Int) {
class B() {
fun Char.xx() : Any {
this : Char
val <!UNUSED_VARIABLE!>a<!> = {
Double.() ->
this : Double
this@xx : Char
this@B : B
this@A : A
}
val <!UNUSED_VARIABLE!>b<!> = @a{Double.() -> this@a : Double + this@xx : Char}
val <!UNUSED_VARIABLE!>c<!> = @a{() -> <!NO_THIS!>this@a<!> + this@xx : Char}
return (@a{Double.() -> this@a : Double + this@xx : Char})
}
}
}
@@ -0,0 +1,9 @@
class A(val a:Int) {
class B() {
val x = this@B : B
val y = this@A : A
val z = this : B
val Int.xx : Int get() = this : Int
}
}
@@ -0,0 +1,4 @@
fun foo1() : Unit {
<!NO_THIS!>this<!>
this<!UNRESOLVED_REFERENCE!>@a<!>
}