Turn on inference when resolving constructor super-calls

It's only needed when one of candidates has it's own type parameters
Otherwise it does not make sense as arguments are already specified
This commit is contained in:
Denis Zharkov
2016-01-22 16:00:43 +03:00
parent 6542d091ee
commit c26ca5e7ef
7 changed files with 129 additions and 15 deletions
@@ -8,10 +8,10 @@ public class A<E> {
// FILE: main.kt
class B1(x: List<String>) : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><CharSequence><!>("", x)
class B2(x: List<Int>) : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><CharSequence><!>("", x)
class B1(x: List<String>) : A<CharSequence>("", x)
class B2(x: List<Int>) : <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>A<CharSequence>("", x)<!>
class C : A<CharSequence> {
constructor(x: List<String>) : super("", <!TYPE_MISMATCH(kotlin.collections.\(Mutable\)List<T!>!; kotlin.collections.List<kotlin.String>)!>x<!>)
constructor(x: List<Int>, y: Int) : super("", <!TYPE_MISMATCH!>x<!>)
constructor(x: List<String>) : super("", x)
constructor(x: List<Int>, y: Int) : <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>super<!>("", x)
}
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !CHECK_TYPE
// FILE: A.java
public class A<E> {
public <T extends E, Q> A(E x, java.util.List<E> y) {}
}
// FILE: main.kt
// TODO: It's effectively impossible to perform super call to such constructor
// if there is not enough information to infer corresponding arguments
// May be we could add some special syntax for such arguments
class B1(x: List<String>) : <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>A<!><CharSequence>("", x)
class B2(x: List<Int>) : <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>A<CharSequence>("", x)<!>
class C : A<CharSequence> {
constructor(x: List<String>) : <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>super<!>("", x)
constructor(x: List<Int>, y: Int) : <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>super<!>("", x)
}
@@ -0,0 +1,30 @@
package
public open class A</*0*/ E : kotlin.Any!> {
public constructor A</*0*/ E : kotlin.Any!, /*1*/ T : E!, /*2*/ Q : kotlin.Any!>(/*0*/ x: E!, /*1*/ y: kotlin.collections.(Mutable)List<E!>!)
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
}
public final class B1 : A<kotlin.CharSequence> {
public constructor B1(/*0*/ x: kotlin.collections.List<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
}
public final class B2 : A<kotlin.CharSequence> {
public constructor B2(/*0*/ x: kotlin.collections.List<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
}
public final class C : A<kotlin.CharSequence> {
public constructor C(/*0*/ x: kotlin.collections.List<kotlin.Int>, /*1*/ y: kotlin.Int)
public constructor C(/*0*/ x: kotlin.collections.List<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
}