Fix for a problem with smart cast impossible in a situation when it's not needed. A test for KT-3572. #KT-3572 Fixed.

This commit is contained in:
Mikhail Glukhikh
2015-04-30 11:50:38 +03:00
parent 093878bd06
commit f4dd685bbe
5 changed files with 59 additions and 7 deletions
@@ -0,0 +1,17 @@
trait Printer {
fun print()
}
class OKPrinter : Printer {
override fun print() { }
}
class MyClass(var printer: Printer)
fun main(m: MyClass) {
if (m.printer is OKPrinter) {
// We do not need smart cast here, so we should not get SMARTCAST_IMPOSSIBLE
m.printer.print()
}
}
@@ -0,0 +1,26 @@
package
internal fun main(/*0*/ m: MyClass): kotlin.Unit
internal final class MyClass {
public constructor MyClass(/*0*/ printer: Printer)
internal final var printer: Printer
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class OKPrinter : Printer {
public constructor OKPrinter()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal open override /*1*/ fun print(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal trait Printer {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
internal abstract fun print(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}