// SKIP_JAVAC // This directive is needed to skip this test in LazyBodyIsNotTouchedTilContractsPhaseTestGenerated, // because it fails to parse module structure of multimodule test // ISSUE: KT-49127 // MODULE: lib class Final open class Base class Derived : Base() class FinalWithOverride { override fun equals(other: Any?): Boolean { // some custom implementation return this === other } } // MODULE: main(lib) fun testFinal(x: Final<*>, y: Final) { if (x == y) { // 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 } } fun testBase(x: Base<*>, y: Base) { if (x == y) { takeIntBase(x) // Error } if (x === y) { takeIntBase(x) // OK } } fun testDerived(x: Derived<*>, y: Derived) { if (x == y) { // 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 } } fun testFinalWithOverride(x: FinalWithOverride<*>, y: FinalWithOverride) { if (x == y) { takeIntFinalWithOverride(x) // Error } if (x === y) { takeIntFinalWithOverride(x) // OK } } fun takeIntFinal(x: Final) {} fun takeIntBase(x: Base) {} fun takeIntDerived(x: Derived) {} fun takeIntFinalWithOverride(x: FinalWithOverride) {}