Change logic of constructor delegation call resolution
- If class has type arguments (A<T1,..>) then resolve it's delegation call to `this` as for expression A<T1, ..>() like type arguments are explicitly specified. - Same logic works for `super` delegation calls. - It could be just enough to substitute all candidates before resolve but diagnostic messages looks more correct when substitution is performed within CandidateResolver.performResolutionForCandidateCall because it works the same way as when resolving A<T1, ..>(). #KT-6992 Fixed #KT-6993 Fixed #KT-6994 Fixed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
|
||||
open class B<T>(x: T, y: T) {
|
||||
constructor(x: T): this(x, x) {}
|
||||
constructor(): this(null) {}
|
||||
constructor(): this(null!!, null!!) {}
|
||||
}
|
||||
|
||||
class A0 : B<String?> {
|
||||
@@ -16,3 +16,6 @@ class A1<R> : B<R> {
|
||||
constructor(x: R, y: R): super(x, y) {}
|
||||
}
|
||||
|
||||
class A2<R> {
|
||||
constructor(t: R, i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(<!TYPE_MISMATCH!>i<!>, 1) {}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@ internal final class A1</*0*/ R> : B<R> {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class A2</*0*/ R> {
|
||||
public constructor A2</*0*/ R>(/*0*/ t: R, /*1*/ i: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal open class B</*0*/ T> {
|
||||
public constructor B</*0*/ T>()
|
||||
public constructor B</*0*/ T>(/*0*/ x: T)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
open class B<R1, R2>(x: R1, y: R2)
|
||||
|
||||
class A0<T1, T2> {
|
||||
constructor(x: T1, y: T2): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(x, y) {}
|
||||
|
||||
constructor(x: T1, y: T2, z: T2): this(x, 1) {} // ok, delegates to constructor(x: T1, y: Int)
|
||||
|
||||
constructor(x: T1, y: Int): <!NONE_APPLICABLE!>this<!>(x, "") {}
|
||||
constructor(x: T1): this(x, 1) {}
|
||||
constructor(x: T1, y: T2, z: String): <!NONE_APPLICABLE!>this<!>(y, x) {}
|
||||
}
|
||||
|
||||
class A1<T1, T2> : B<T1, T2> {
|
||||
constructor(x: T1, y: T2): super(x, y) {}
|
||||
constructor(x: T1, y: Int): super(x, <!TYPE_MISMATCH(T2; kotlin.Int)!>y<!>) {}
|
||||
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(T2; T1)!>y<!>) {}
|
||||
}
|
||||
|
||||
class A2<T1, T2> : B<T1, Int> {
|
||||
constructor(x: T1, y: T2): super(x, <!TYPE_MISMATCH(kotlin.Int; T2)!>y<!>) {}
|
||||
constructor(x: T1, y: Int): super(x, y) {}
|
||||
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(kotlin.Int; T1)!>y<!>) {}
|
||||
constructor(x: T1, y: T2, z: String): super(<!TYPE_MISMATCH(T1; T2)!>y<!>, 1) {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
internal final class A0</*0*/ T1, /*1*/ T2> {
|
||||
public constructor A0</*0*/ T1, /*1*/ T2>(/*0*/ x: T1)
|
||||
public constructor A0</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2)
|
||||
public constructor A0</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2, /*2*/ z: T2)
|
||||
public constructor A0</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2, /*2*/ z: kotlin.String)
|
||||
public constructor A0</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class A1</*0*/ T1, /*1*/ T2> : B<T1, T2> {
|
||||
public constructor A1</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T1, /*2*/ z: T1)
|
||||
public constructor A1</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2)
|
||||
public constructor A1</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class A2</*0*/ T1, /*1*/ T2> : B<T1, kotlin.Int> {
|
||||
public constructor A2</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T1, /*2*/ z: T1)
|
||||
public constructor A2</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2)
|
||||
public constructor A2</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: T2, /*2*/ z: kotlin.String)
|
||||
public constructor A2</*0*/ T1, /*1*/ T2>(/*0*/ x: T1, /*1*/ y: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal open class B</*0*/ R1, /*1*/ R2> {
|
||||
public constructor B</*0*/ R1, /*1*/ R2>(/*0*/ x: R1, /*1*/ y: R2)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
open class B<X, Y : X> {
|
||||
constructor(x: X, y: Y) {}
|
||||
constructor(x: X, s: String) {}
|
||||
constructor(y: Y, i: Int) : this(y, "") {}
|
||||
}
|
||||
|
||||
class A<T1, T2 : T1> : B<T1, T2> {
|
||||
constructor(x: T1, y: T2): super(x, y) {}
|
||||
constructor(x: T2, y: T2, z: String): super(x, y) {}
|
||||
|
||||
constructor(x: T2, z: String, z1: String): super(x, "") {}
|
||||
constructor(x: T2, z: String, z1: String, z2: String): super(x, 1) {}
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "") {}
|
||||
constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): <!NONE_APPLICABLE!>super<!>(x, 1) {}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package
|
||||
|
||||
internal final class A</*0*/ T1, /*1*/ T2 : T1> : B<T1, T2> {
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T1, /*1*/ y: T2)
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T1, /*1*/ z: kotlin.String, /*2*/ z1: kotlin.String, /*3*/ z2: kotlin.String, /*4*/ z3: kotlin.String)
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T1, /*1*/ z: kotlin.String, /*2*/ z1: kotlin.String, /*3*/ z2: kotlin.String, /*4*/ z3: kotlin.String, /*5*/ z4: kotlin.String)
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T2, /*1*/ y: T2, /*2*/ z: kotlin.String)
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T2, /*1*/ z: kotlin.String, /*2*/ z1: kotlin.String)
|
||||
public constructor A</*0*/ T1, /*1*/ T2 : T1>(/*0*/ x: T2, /*1*/ z: kotlin.String, /*2*/ z1: kotlin.String, /*3*/ z2: kotlin.String)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal open class B</*0*/ X, /*1*/ Y : X> {
|
||||
public constructor B</*0*/ X, /*1*/ Y : X>(/*0*/ x: X, /*1*/ y: Y)
|
||||
public constructor B</*0*/ X, /*1*/ Y : X>(/*0*/ x: X, /*1*/ s: kotlin.String)
|
||||
public constructor B</*0*/ X, /*1*/ Y : X>(/*0*/ y: Y, /*1*/ i: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class X<T>(val t: T) {
|
||||
constructor(t: String): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(t) {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal final class X</*0*/ T> {
|
||||
public constructor X</*0*/ T>(/*0*/ t: T)
|
||||
public constructor X</*0*/ T>(/*0*/ t: kotlin.String)
|
||||
internal final val t: T
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class X<T>(val t: T) {
|
||||
constructor(t: T, i: Int) : <!NONE_APPLICABLE!>this<!>(i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal final class X</*0*/ T> {
|
||||
public constructor X</*0*/ T>(/*0*/ t: T)
|
||||
public constructor X</*0*/ T>(/*0*/ t: T, /*1*/ i: kotlin.Int)
|
||||
internal final val t: T
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class X<T> {
|
||||
constructor(t: T, i: Int): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(<!TYPE_MISMATCH!>i<!>, 1) { // no error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
internal final class X</*0*/ T> {
|
||||
public constructor X</*0*/ T>(/*0*/ t: T, /*1*/ i: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A<T1, T2> {
|
||||
constructor(block: (T1) -> T2) {}
|
||||
constructor(x: T2): this({ x }) {}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
internal final class A</*0*/ T1, /*1*/ T2> {
|
||||
public constructor A</*0*/ T1, /*1*/ T2>(/*0*/ block: (T1) -> T2)
|
||||
public constructor A</*0*/ T1, /*1*/ T2>(/*0*/ x: T2)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user