diff --git a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt index ad882c18bc9..32da7c8aecb 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt @@ -4,5 +4,5 @@ class G fun foo(p: P) { val v = p as G? - checkSubtype>(v!!) -} \ No newline at end of file + checkSubtype>(v!!) +} diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt index 2b2f8bdf6a8..97610c28a91 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt @@ -26,4 +26,4 @@ import p.* fun test() { foo(M1().a) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt index a90aa734312..9de45048e8f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt @@ -37,6 +37,6 @@ import p.* fun test() { a(M1().b) // Type arguments do not match - c(M1().b) // Type arguments do not match + c(M1().b) // Type arguments do not match d(M1().b) // Type arguments do match -} \ No newline at end of file +} diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt index ddba646ece2..27fdc02b77c 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt @@ -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 <: A<*>