FIR: Fix smartcast case after equals on class from different module
^KT-50534 Relates
This commit is contained in:
compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastsFromEquals_differentModule.fir.txt
Vendored
+2
-2
@@ -33,7 +33,7 @@ FILE: module_main_smartcastsFromEquals_differentModule.kt
|
||||
public final fun testFinal(x: R|Final<*>|, y: R|Final<kotlin/Int>|): R|kotlin/Unit| {
|
||||
when () {
|
||||
==(R|<local>/x|, R|<local>/y|) -> {
|
||||
<Inapplicable(INAPPLICABLE): /takeIntFinal>#(R|<local>/x|)
|
||||
R|/takeIntFinal|(R|<local>/x|)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ FILE: module_main_smartcastsFromEquals_differentModule.kt
|
||||
public final fun testDerived(x: R|Derived<*>|, y: R|Derived<kotlin/Int>|): R|kotlin/Unit| {
|
||||
when () {
|
||||
==(R|<local>/x|, R|<local>/y|) -> {
|
||||
<Inapplicable(INAPPLICABLE): /takeIntDerived>#(R|<local>/x|)
|
||||
R|/takeIntDerived|(R|<local>/x|)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-2
@@ -20,7 +20,10 @@ class FinalWithOverride<T> {
|
||||
// MODULE: main(lib)
|
||||
fun testFinal(x: Final<*>, y: Final<Int>) {
|
||||
if (x == y) {
|
||||
takeIntFinal(<!ARGUMENT_TYPE_MISMATCH!>x<!>) // Error
|
||||
// No error, even while `Final` belongs to a different module and "equals" contract might be changed without re-compilation
|
||||
// But since we had such behavior in FE1.0, it might be too strict to prohibit it now, especially once there's a lot of cases
|
||||
// when different modules belong to a single project, so they're totally safe (see KT-50534)
|
||||
takeIntFinal(x)
|
||||
}
|
||||
if (x === y) {
|
||||
takeIntFinal(x) // OK
|
||||
@@ -38,7 +41,10 @@ fun testBase(x: Base<*>, y: Base<Int>) {
|
||||
|
||||
fun testDerived(x: Derived<*>, y: Derived<Int>) {
|
||||
if (x == y) {
|
||||
takeIntDerived(<!ARGUMENT_TYPE_MISMATCH!>x<!>) // Error
|
||||
// No error, even while `Final` belongs to a different module and "equals" contract might be changed without re-compilation
|
||||
// But since we had such behavior in FE1.0, it might be too strict to prohibit it now, especially once there's a lot of cases
|
||||
// when different modules belong to a single project, so they're totally safe (see KT-50534)
|
||||
takeIntDerived(x)
|
||||
}
|
||||
if (x === y) {
|
||||
takeIntDerived(x) // OK
|
||||
|
||||
Reference in New Issue
Block a user