[FIR] Fix incorrect matching of nested classes when actualized via typealias

There are still some places in `.fir.kt` where false-positive reports
remained. This is because of IR checker, which will be fixed in next
commit.

^KT-31636
This commit is contained in:
Roman Efremov
2023-11-20 11:42:20 +01:00
committed by Space Team
parent a768ece70d
commit 4aaf290c99
14 changed files with 190 additions and 20 deletions
@@ -14,7 +14,7 @@ annotation class AnnImpl {
annotation class Nested
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Ann<!> = AnnImpl
actual typealias Ann = AnnImpl
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>@AnnImpl.Nested
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>foo<!>() {}<!>
actual fun foo() {}<!>
@@ -14,7 +14,7 @@ annotation class AnnImpl {
annotation class Nested
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Ann<!> = AnnImpl
actual typealias Ann = AnnImpl
@AnnImpl.Nested
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>foo<!>() {}
actual fun foo() {}
@@ -11,4 +11,4 @@ class DefaultArgsInNestedClassImpl {
}
// Incompatible because of bug KT-31636
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>DefaultArgsInNestedClass<!> = DefaultArgsInNestedClassImpl
actual typealias DefaultArgsInNestedClass = DefaultArgsInNestedClassImpl
@@ -18,7 +18,7 @@ class FooImpl {
class Inner
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> = FooImpl
actual typealias Foo = FooImpl
class SeveralInnerImpl {
class Inner1 {
@@ -28,4 +28,4 @@ class SeveralInnerImpl {
}
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>SeveralInner<!> = SeveralInnerImpl
actual typealias SeveralInner = SeveralInnerImpl
@@ -18,7 +18,7 @@ class FooImpl {
class Inner
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> = FooImpl
actual typealias Foo = FooImpl
class SeveralInnerImpl {
class Inner1 {
@@ -28,4 +28,4 @@ class SeveralInnerImpl {
}
}
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>SeveralInner<!> = SeveralInnerImpl
actual typealias SeveralInner = SeveralInnerImpl
@@ -0,0 +1,34 @@
// False-positive reports in K1, because fixed only in K2
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
class Inner<T>
}
expect fun substituted(p: Foo.Inner<Any>)
<!EXPECT_ACTUAL_MISMATCH{JVM}!>expect fun substitutedIncorrect(p: Foo.Inner<Any>)<!>
expect fun <T> withTypeParam(p: Foo.Inner<T>)
<!EXPECT_ACTUAL_MISMATCH{JVM}!>expect fun <T, R> withTypeParamIncorrect(p: Foo.Inner<R>)<!>
expect fun star(p: Foo.Inner<*>)
<!EXPECT_ACTUAL_MISMATCH{JVM}!>expect fun starVsNonStar(p: Foo.Inner<*>)<!>
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
class FooImpl {
class Inner<T>
}
actual typealias Foo = FooImpl
actual fun substituted(p: Foo.Inner<Any>) {}
actual fun <!ACTUAL_WITHOUT_EXPECT!>substitutedIncorrect<!>(p: Foo.Inner<String>) {}
actual fun <T> withTypeParam(p: Foo.Inner<T>) {}
actual fun <T, R> <!ACTUAL_WITHOUT_EXPECT!>withTypeParamIncorrect<!>(p: Foo.Inner<T>) {}
actual fun star(p: Foo.Inner<*>) {}
actual fun <!ACTUAL_WITHOUT_EXPECT!>starVsNonStar<!>(p: Foo.Inner<Any>) {}
@@ -0,0 +1,34 @@
// False-positive reports in K1, because fixed only in K2
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
class Inner<T>
}
expect fun substituted<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><Any>)<!>
expect fun substitutedIncorrect<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><Any>)<!>
expect fun <T> withTypeParam<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><T>)<!>
expect fun <T, R> withTypeParamIncorrect<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><R>)<!>
expect fun star<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><*>)<!>
expect fun starVsNonStar<!NO_ACTUAL_FOR_EXPECT{JVM}!>(p: Foo.<!UNRESOLVED_REFERENCE{JVM}!>Inner<!><*>)<!>
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
class FooImpl {
class Inner<T>
}
actual typealias Foo = FooImpl
actual fun substituted<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><Any>)<!> {}
actual fun substitutedIncorrect<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><String>)<!> {}
actual fun <T> withTypeParam<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><T>)<!> {}
actual fun <T, R> withTypeParamIncorrect<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><T>)<!> {}
actual fun star<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><*>)<!> {}
actual fun starVsNonStar<!ACTUAL_WITHOUT_EXPECT!>(p: Foo.<!UNRESOLVED_REFERENCE!>Inner<!><Any>)<!> {}
@@ -0,0 +1,33 @@
// False-positive reports in K1, because fixed only in K2
// MODULE: m1-common
// FILE: common.kt
expect class Foo {
class Inner<T>
}
expect fun substituted(p: Foo.Inner<Any>)
expect fun substitutedIncorrect(p: Foo.Inner<Any>)
expect fun <T> withTypeParam(p: Foo.Inner<T>)
expect fun <T, R> withTypeParamIncorrect(p: Foo.Inner<R>)
expect fun star(p: Foo.Inner<*>)
expect fun starVsNonStar(p: Foo.Inner<*>)
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
class FooImpl {
class Inner<T>
}
actual typealias Foo = FooImpl
actual fun substituted(p: Foo.Inner<Any>) {}
actual fun <!ACTUAL_WITHOUT_EXPECT!>substitutedIncorrect<!>(p: Foo.Inner<String>) {}
actual fun <T> withTypeParam(p: Foo.Inner<T>) {}
actual fun <T, R> <!ACTUAL_WITHOUT_EXPECT!>withTypeParamIncorrect<!>(p: Foo.Inner<T>) {}
actual fun star(p: Foo.Inner<*>) {}
actual fun <!ACTUAL_WITHOUT_EXPECT!>starVsNonStar<!>(p: Foo.Inner<Any>) {}