Refine expect classes in CliSealedClassInheritorsProvider

KT-45796 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-04-05 12:11:10 +03:00
committed by TeamCityServer
parent 2ee8ac2e15
commit 1633190478
6 changed files with 140 additions and 3 deletions
@@ -0,0 +1,30 @@
// !LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-45796
// MODULE: m1-common
expect sealed class SealedClass() {
class Nested : SealedClass {
class NestedDeeper : SealedClass
}
}
fun whenForExpectSealed(s: SealedClass): Int {
return when (s) { // should be error, because actual sealed class may add more implementations
is SealedClass.Nested.NestedDeeper -> 7
is SealedClass.Nested -> 8
}
}
// MODULE: m1-jvm(m1-common)
actual sealed class SealedClass {
actual class Nested : SealedClass() {
actual class NestedDeeper : SealedClass()
}
}
fun whenForSealed(s: SealedClass): Int {
return when (s) { // Should be OK
is SealedClass.Nested.NestedDeeper -> 7
is SealedClass.Nested -> 8
}
}
@@ -0,0 +1,30 @@
// !LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-45796
// MODULE: m1-common
expect sealed class SealedClass() {
class Nested : SealedClass {
class NestedDeeper : SealedClass
}
}
fun whenForExpectSealed(s: SealedClass): Int {
return <!EXPECT_TYPE_IN_WHEN_WITHOUT_ELSE, NO_ELSE_IN_WHEN!>when<!> (s) { // should be error, because actual sealed class may add more implementations
is SealedClass.Nested.NestedDeeper -> 7
is SealedClass.Nested -> 8
}
}
// MODULE: m1-jvm(m1-common)
actual sealed class SealedClass {
actual class Nested : SealedClass() {
actual class NestedDeeper : SealedClass()
}
}
fun whenForSealed(s: SealedClass): Int {
return when (s) { // Should be OK
is SealedClass.Nested.NestedDeeper -> 7
is SealedClass.Nested -> 8
}
}
@@ -0,0 +1,51 @@
// -- Module: <m1-common> --
package
public fun whenForExpectSealed(/*0*/ s: SealedClass): kotlin.Int
public sealed expect class SealedClass {
protected constructor SealedClass()
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 expect class Nested : SealedClass {
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 expect class NestedDeeper : SealedClass {
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
}
}
}
// -- Module: <m1-jvm> --
package
public fun whenForExpectSealed(/*0*/ s: SealedClass): kotlin.Int
public fun whenForSealed(/*0*/ s: SealedClass): kotlin.Int
public sealed actual class SealedClass {
protected constructor SealedClass()
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 actual class Nested : SealedClass {
public constructor Nested()
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 actual class NestedDeeper : SealedClass {
public constructor NestedDeeper()
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
}
}
}