"as" in binary / unary expressions now checked only for original type conversion #KT-10384 Fixed

Also #KT-10386 Fixed
This commit is contained in:
Mikhail Glukhikh
2015-12-14 17:12:10 +03:00
parent 233e8e58e8
commit 49e7417741
7 changed files with 119 additions and 0 deletions
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
interface Base
class Impl1 : Base
class Impl2 : Base
operator fun Base.plus(arg: Base) = Impl1()
operator fun Impl2.plus(arg: Base) = Impl2()
operator fun Base.plus(arg: Impl2) = Impl2()
operator fun Base.unaryMinus() = Impl1()
operator fun Impl2.unaryMinus() = Impl2()
// See also KT-10384: in non-error functions, as is necessary!
fun add1(x: Impl2, y: Base): Impl1 = x as Base + y
fun error1(x: Impl2, y: Base): Impl1 = <!TYPE_MISMATCH!>x + y<!>
fun add2(x: Base, y: Impl2): Impl1 = x + y as Base
fun error2(x: Base, y: Impl2): Impl1 = <!TYPE_MISMATCH!>x + y<!>
fun minus3(x: Impl2): Impl1 = -(x as Base)
fun error3(x: Impl2): Impl1 = <!TYPE_MISMATCH!>-x<!>
@@ -0,0 +1,33 @@
package
public fun add1(/*0*/ x: Impl2, /*1*/ y: Base): Impl1
public fun add2(/*0*/ x: Base, /*1*/ y: Impl2): Impl1
public fun error1(/*0*/ x: Impl2, /*1*/ y: Base): Impl1
public fun error2(/*0*/ x: Base, /*1*/ y: Impl2): Impl1
public fun error3(/*0*/ x: Impl2): Impl1
public fun minus3(/*0*/ x: Impl2): Impl1
public operator fun Base.plus(/*0*/ arg: Base): Impl1
public operator fun Base.plus(/*0*/ arg: Impl2): Impl2
public operator fun Impl2.plus(/*0*/ arg: Base): Impl2
public operator fun Base.unaryMinus(): Impl1
public operator fun Impl2.unaryMinus(): Impl2
public interface Base {
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
}
public final class Impl1 : Base {
public constructor Impl1()
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
}
public final class Impl2 : Base {
public constructor Impl2()
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
}