[Inference] Fix subtyping on classes with same FQN but with different number of arguments
Such situations may appear if there are multiple classes with same names from different modules in dependencies
This commit is contained in:
@@ -4,5 +4,5 @@ class G<T>
|
||||
|
||||
fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
|
||||
val v = p as G?
|
||||
checkSubtype<G<*>>(v!!)
|
||||
}
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><G<*>>(v!!)
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ import p.*
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(M1().a)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,6 +37,6 @@ import p.*
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>a<!>(M1().b) // Type arguments do not match
|
||||
c(M1().b) // Type arguments do not match
|
||||
<!INAPPLICABLE_CANDIDATE!>c<!>(M1().b) // Type arguments do not match
|
||||
d(M1().b) // Type arguments do match
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,9 +367,17 @@ object AbstractTypeChecker {
|
||||
// No way to check, as no index sometimes
|
||||
//if (capturedSubArguments === superType.arguments) return true
|
||||
|
||||
//val parameters = superType.constructor.parameters
|
||||
val superTypeConstructor = superType.typeConstructor()
|
||||
for (index in 0 until superTypeConstructor.parametersCount()) {
|
||||
|
||||
// Sometimes we can get two classes from different modules with different counts of type parameters
|
||||
// So for such situations we assume that those types are not sub type of each other
|
||||
val argumentsCount = capturedSubArguments.size()
|
||||
val parametersCount = superTypeConstructor.parametersCount()
|
||||
if (argumentsCount != parametersCount || argumentsCount != superType.argumentsCount()) {
|
||||
return false
|
||||
}
|
||||
|
||||
for (index in 0 until parametersCount) {
|
||||
val superProjection = superType.getArgument(index) // todo error index
|
||||
if (superProjection.isStarProjection()) continue // A<B> <: A<*>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user