Implicit nothing / intersection types are now checked also for member functions #KT-11666 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-03-30 13:10:51 +03:00
committed by Mikhail Glukhikh
parent 0ea3b4ade4
commit 4c03aaabd4
13 changed files with 49 additions and 16 deletions
@@ -14,6 +14,8 @@ class My(b: B) {
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
// Error!
fun <!IMPLICIT_INTERSECTION_TYPE!>foo<!>(b: B) = if (b is A && b is C) b else null
}
fun bar(b: B): String {
@@ -28,6 +28,7 @@ public final class My {
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 final fun foo(/*0*/ b: B): {C & A & B}?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
+18
View File
@@ -16,3 +16,21 @@ fun check() {
// Unreachable / unused, but not implicit Nothing
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>x<!> =<!> null!!
}
class Klass {
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>bar<!>() = null!!
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>y<!> = null!!
init {
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>local<!>() = bar()
// Should be unreachable: see KT-5311
val z = null!!
}
fun foo() {
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>local<!>() = bar()
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>x<!> =<!> y
}
}
+10
View File
@@ -7,3 +7,13 @@ public fun baz(): kotlin.Nothing
public fun check(): kotlin.Unit
public fun foo(): kotlin.Nothing
public fun gav(): kotlin.Any
public final class Klass {
public constructor Klass()
public final val y: kotlin.Nothing
public final fun bar(): kotlin.Nothing
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}