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
@@ -1,42 +0,0 @@
// FILE: f.kt
class Dup {
fun Dup() : Unit {
this<!AMBIGUOUS_LABEL!>@Dup<!>
}
}
class A() {
fun foo() : Unit {
this@A
this<!UNRESOLVED_REFERENCE!>@a<!>
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
fun foo1() : Unit {
<!NO_THIS!>this<!>
this<!UNRESOLVED_REFERENCE!>@a<!>
}
// FILE: f.kt
package closures
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
fun Char.xx() : Any {
this : Char
val <!UNUSED_VARIABLE!>a<!> = {Double.() -> this : Double + this@xx : Char}
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,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()
}
@@ -1,17 +1,5 @@
package example;
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
<!NO_ELSE_IN_WHEN!>when<!> (1) {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> -> 1 // not an expression
}
}
trait T {
fun foo() {}
}
@@ -54,12 +42,6 @@ class A<E>() : C(), T {
}
}
fun foo() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
}
trait G<T> {
fun foo() {}
}
@@ -79,11 +61,4 @@ class ERROR<E>() : <!UNRESOLVED_REFERENCE!>UR<!> {
fun test() {
super.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
// No supertype at all
class A1 {
fun test() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.equals(null)
}
}
}
@@ -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<!>
}