[FIR] Add diagnostic for constructor delegation cycles

This commit is contained in:
Nick
2020-07-31 16:48:33 +03:00
committed by Mikhail Glukhikh
parent e841b3a77b
commit bb0e1b7390
24 changed files with 322 additions and 58 deletions
@@ -0,0 +1,67 @@
class B
class C
class A() {
constructor(a: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>("test") {}
constructor(a: String) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(10) {}
constructor(a: Boolean) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>('\n') {}
constructor(a: Char) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(0.0) {}
constructor(a: Double) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(false) {}
constructor(b: B) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3.14159265) {}
constructor(c: C) : this() {}
constructor(a: List<Int>) : this(C()) {}
}
class D {
constructor(i: Boolean) {}
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3) {}
}
class E<T> {
// this is not an error about the
// selection of the proper constructor
// but a type mismatch for the first
// argument
constructor(e: T, i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(i, 10) {}
}
class I<T> {
// this is not an error about the
// selection of the proper constructor
// but a type mismatch for the first
// argument
constructor(e: T, i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(i, 10)
}
class J<T> {
constructor(e: T, i: Int) : this(i, 10)
constructor(e: Int, i: Int)
}
class F(s: String) {
constructor(i: Boolean) {}
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3) {}
}
class G(x: Int) {
constructor() {}
}
class H(x: Int) {
constructor()
}
class K(x: Int) {
constructor() : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>() {}
}
class M {
constructor(m: Int)
}
class U : M {
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
}