Intersection types are no more allowed in signatures #KT-10244 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-12-22 19:46:09 +03:00
parent f56dc722d9
commit 6b8b39a7bd
8 changed files with 82 additions and 3 deletions
@@ -0,0 +1,23 @@
// See KT-10244: no intersection types in signatures
open class B
interface A
interface C
// Error!
fun <!IMPLICIT_INTERSECTION_TYPE!>foo<!>(b: B) = if (b is A && b is C) b else null
// Ok: given explicitly
fun gav(b: B): A? = if (b is A && b is C) <!DEBUG_INFO_SMARTCAST!>b<!> else null
class My(b: B) {
// Error!
val <!IMPLICIT_INTERSECTION_TYPE!>x<!> = if (b is A && b is C) b else null
// Ok: given explicitly
val y: C? = if (b is A && b is C) <!DEBUG_INFO_SMARTCAST!>b<!> else null
}
fun bar(b: B): String {
// Ok: local variable
val tmp = if (b is A && b is C) b else null
return tmp.toString()
}
@@ -0,0 +1,33 @@
package
public fun bar(/*0*/ b: B): kotlin.String
public fun foo(/*0*/ b: B): {C & A & B}?
public fun gav(/*0*/ b: B): A?
public interface A {
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 open class B {
public constructor B()
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 interface C {
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 My {
public constructor My(/*0*/ b: B)
public final val x: {C & A & B}?
public final val y: C?
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
}