K2: Fix false-positive on delegated constructor call of outer class
See callingOuterGenericClassConstructorWithSelfTypes.kt
Previously, for A<B>(""), we used substituted constructor
where `X` was substituted with `B` (or `A<X>.B`).
But when resolving the call for constructor, we use `X`
as a type variable of the call, thus in some positions
we used `X` as TV (Xv in the comments) and somewhere `X` as a type
parameter, thus leading to contradictions (see clarifying comment).
The idea of the fix is simply repeating of the regular (not delegated)
constructor call resolution:
- We substitute only type parameters of outer class
- All the declared parameters of the callee are being checked
through regular resolution & inference mechanisms.
NB: Diagnostic only being reported on arguments because there
when we add `String <: Any` constraint it fails due to existing
contradiction in the CS.
Without the argument/parameter the error is just being lost, but that's
a different story (seeKT-65224).
^KT-64841 Fixed
This commit is contained in:
committed by
Space Team
parent
81d559ad7f
commit
7b82ca8b6f
Vendored
+2
-2
@@ -11,10 +11,10 @@ public class A<E> {
|
||||
// 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>) : <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>A<CharSequence><!>("", x)
|
||||
class B1(x: List<String>) : <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>A<CharSequence><!>("", x)
|
||||
class B2(x: List<Int>) : A<CharSequence>("", <!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
|
||||
class C : A<CharSequence> {
|
||||
constructor(x: List<String>) : <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>super<!>("", x)
|
||||
constructor(x: List<String>) : <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>super<!>("", x)
|
||||
constructor(x: List<Int>, y: Int) : super("", <!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user