Test fixes for 'New diagnostic error for ambiguous object expression type'

This commit is contained in:
Mikhael Bogdanov
2013-02-19 14:36:50 +04:00
parent 1662c5cb75
commit 029b2d9770
7 changed files with 88 additions and 56 deletions
@@ -1,9 +1,15 @@
fun <T : Any> T?.iterator() = object {
trait MyIterator<T> {
fun hasNext() : Boolean
fun next() : T
}
fun <T : Any> T?.iterator() = object : MyIterator<T> {
var hasNext = this@iterator != null
private set
fun hasNext() = hasNext
override fun hasNext() = hasNext
fun next() : T {
override fun next() : T {
if (hasNext) {
hasNext = false
return this@iterator!!
@@ -6,12 +6,19 @@ inline fun <T> java.util.Enumeration<T>.iterator() = object: Iterator<T> {
override fun next() = nextElement()
}
fun <T : Any> T?.iterator() = object {
trait MyIterator<T> {
fun hasNext() : Boolean
fun next() : T
}
fun <T : Any> T?.iterator() = object : MyIterator<T> {
var hasNext = this@iterator != null
private set
fun hasNext() = hasNext
override fun hasNext() = hasNext
fun next() : T {
override fun next() : T {
if (hasNext) {
hasNext = false
return this@iterator!!
@@ -26,3 +33,4 @@ fun main(args : Array<String>) {
System.out.println(x)
}
}
@@ -1,22 +1,27 @@
// JET-81 Assertion fails when processing self-referring anonymous objects
val y = object {
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>y<!>;
}
class Test {
private val y = object {
val a = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM, UNINITIALIZED_VARIABLE!>y<!>;
}
val z = y.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>;
val z = y.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>;
}
object A {
val x = A
}
val a = object {
{
<!UNINITIALIZED_VARIABLE, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> 1
class Test2 {
private val a = object {
{
<!UNINITIALIZED_VARIABLE, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> 1
}
val x = <!UNINITIALIZED_VARIABLE, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!>
val y = 1
}
val x = <!UNINITIALIZED_VARIABLE, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!>
val y = 1
}
val b = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
val c = a.y
val b = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
val c = a.y
}
@@ -11,12 +11,14 @@ fun test1() {
doSmth(MyObject.<!INVISIBLE_MEMBER!>message<!>)
}
val MyObject1 = object {
private var message: String = "'Static'"
}
class Test {
private val MyObject1 = object {
private var message: String = "'Static'"
}
fun test2() {
doSmth(MyObject1.<!INVISIBLE_MEMBER!>message<!>)
fun test2() {
doSmth(MyObject1.<!INVISIBLE_MEMBER!>message<!>)
}
}
fun doSmth(s: String) = s
+15 -14
View File
@@ -1,20 +1,22 @@
package toplevelObjectDeclarations {
class Foo(y : Int) {
~foo()~open fun foo() : Int = 1
package toplevelObjectDeclarations
class Foo(y : Int) {
~foo()~open fun foo() : Int = 1
}
object ~A~A : Foo(0) {
~x~val x : Int = 2
fun test() {
return `x`x + `foo()`foo()
}
}
object ~A~A : Foo(0) {
~x~val x : Int = 2
object B : A {}
fun test() {
return `x`x + `foo()`foo()
}
}
object B : A {}
~ns.x~val x = `A`A.`foo()`foo()
~ns.x~val x = `A`A.`foo()`foo()
fun f() {
~y~val y = object : Foo(`ns.x`x) {
{
`ns.x`x + 12
@@ -25,4 +27,3 @@ package toplevelObjectDeclarations {
val z = `y`y.`y.foo()`foo()
}
+17 -12
View File
@@ -1,22 +1,27 @@
// JET-81 Assertion fails when processing self-referring anonymous objects
val y = object {
val a = <error>y</error>
}
class Test {
private val y = object {
val a = <error>y</error>
}
val z = y.<error>a</error>;
val z = y.<error>a</error>;
}
object A {
val x = A
}
val a = object {
{
<error>b</error> <error>+</error> 1
class Test2 {
private val a = object {
{
<error>b</error> <error>+</error> 1
}
val x = <error>b</error>
val y = 1
}
val x = <error>b</error>
val y = 1
}
val b = <error>a</error>.<error>x</error>
val c = a.y
val b = <error>a</error>.<error>x</error>
val c = a.y
}
@@ -1,17 +1,22 @@
package foo
val a = object {
fun c() = 3
fun b() = 2
}
class Test {
private val a = object {
fun c() = 3
fun b() = 2
}
fun box(): Boolean {
fun doTest(): Boolean {
if (a.c() != 3) {
return false;
}
if (a.b() != 2) {
return false;
}
return true;
}
}
}
fun box(): Boolean {
return Test().doTest();
}