// ISSUE: KT-49127 class Final open class Base class Derived : Base() class FinalWithOverride { override fun equals(other: Any?): Boolean { // some custom implementation return this === other } } fun testFinal(x: Final<*>, y: Final) { if (x == y) { takeIntFinal(x) // OK } 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) { takeIntDerived(x) // OK } 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) {}