[FE 1.0] Report warning on non-exhaustive when statements only after 1.6
^KT-47709
This commit is contained in:
committed by
teamcityserver
parent
865ad3698b
commit
a710a8d10f
+6
@@ -31681,6 +31681,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_5.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_5() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/nonExhaustiveWhenStatement_1_5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_6.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_6() throws Exception {
|
||||
|
||||
+6
@@ -31681,6 +31681,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_5.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_5() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/nonExhaustiveWhenStatement_1_5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_6.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_6() throws Exception {
|
||||
|
||||
+53
-17
@@ -37,10 +37,8 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getEnclosingDescriptor
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsResultOfLambda
|
||||
@@ -56,7 +54,6 @@ import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore
|
||||
import org.jetbrains.kotlin.resolve.checkers.PlatformDiagnosticSuppressor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.indexOrMinusOne
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils.*
|
||||
@@ -1025,20 +1022,16 @@ class ControlFlowInformationProviderImpl private constructor(
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (!usedAsExpression && missingCases.isNotEmpty()) {
|
||||
val kind = when {
|
||||
WhenChecker.getClassDescriptorOfTypeIfSealed(subjectType) != null -> AlgebraicTypeKind.Sealed
|
||||
WhenChecker.getClassDescriptorOfTypeIfEnum(subjectType) != null -> AlgebraicTypeKind.Enum
|
||||
subjectType?.isBooleanOrNullableBoolean() == true -> AlgebraicTypeKind.Boolean
|
||||
else -> null
|
||||
}
|
||||
if (!usedAsExpression) {
|
||||
|
||||
if (kind != null) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitNonExhaustiveWhenOnAlgebraicTypes)) {
|
||||
trace.report(NO_ELSE_IN_WHEN.on(element, missingCases))
|
||||
} else {
|
||||
trace.report(NON_EXHAUSTIVE_WHEN_STATEMENT.on(element, kind.displayName, missingCases))
|
||||
}
|
||||
}
|
||||
if (!usedAsExpression) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.WarnAboutNonExhaustiveWhenOnAlgebraicTypes)) {
|
||||
// report warnings on all non-exhaustive when's with algebraic subject
|
||||
checkExhaustiveWhenStatement(subjectType, element, missingCases)
|
||||
} else {
|
||||
// report info if subject is sealed class and warning if it is enum
|
||||
checkWhenStatement(subjectType, element, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1046,6 +1039,49 @@ class ControlFlowInformationProviderImpl private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkWhenStatement(
|
||||
subjectType: KotlinType?,
|
||||
element: KtWhenExpression,
|
||||
context: BindingContext
|
||||
) {
|
||||
val enumClassDescriptor = WhenChecker.getClassDescriptorOfTypeIfEnum(subjectType)
|
||||
if (enumClassDescriptor != null) {
|
||||
val enumMissingCases = WhenChecker.getEnumMissingCases(element, context, enumClassDescriptor)
|
||||
if (enumMissingCases.isNotEmpty()) {
|
||||
trace.report(NON_EXHAUSTIVE_WHEN.on(element, enumMissingCases))
|
||||
}
|
||||
}
|
||||
val sealedClassDescriptor = WhenChecker.getClassDescriptorOfTypeIfSealed(subjectType)
|
||||
if (sealedClassDescriptor != null) {
|
||||
val sealedMissingCases = WhenChecker.getSealedMissingCases(element, context, sealedClassDescriptor)
|
||||
if (sealedMissingCases.isNotEmpty()) {
|
||||
trace.report(NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS.on(element, sealedMissingCases))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkExhaustiveWhenStatement(
|
||||
subjectType: KotlinType?,
|
||||
element: KtWhenExpression,
|
||||
missingCases: List<WhenMissingCase>
|
||||
) {
|
||||
if (missingCases.isEmpty()) return
|
||||
val kind = when {
|
||||
WhenChecker.getClassDescriptorOfTypeIfSealed(subjectType) != null -> AlgebraicTypeKind.Sealed
|
||||
WhenChecker.getClassDescriptorOfTypeIfEnum(subjectType) != null -> AlgebraicTypeKind.Enum
|
||||
subjectType?.isBooleanOrNullableBoolean() == true -> AlgebraicTypeKind.Boolean
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (kind != null) {
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitNonExhaustiveWhenOnAlgebraicTypes)) {
|
||||
trace.report(NO_ELSE_IN_WHEN.on(element, missingCases))
|
||||
} else {
|
||||
trace.report(NON_EXHAUSTIVE_WHEN_STATEMENT.on(element, kind.displayName, missingCases))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum class AlgebraicTypeKind(val displayName: String) {
|
||||
Sealed("sealed class/interface"),
|
||||
Enum("enum"),
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
// FIR_IDENTICAL
|
||||
//FILE: foo.kt
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// FILE: foo.kt
|
||||
fun main() {
|
||||
val c: Type
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (<!UNINITIALIZED_VARIABLE!>c<!>) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE
|
||||
|
||||
fun foo(f: Boolean): Int {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// See also: KT-11998
|
||||
data class My(val x: Boolean?)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// See also: KT-11998
|
||||
data class My(val x: Boolean?)
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: -WarnAboutNonExhaustiveWhenOnAlgebraicTypes -ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: -WarnAboutNonExhaustiveWhenOnAlgebraicTypes -ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
<!NON_EXHAUSTIVE_WHEN!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package
|
||||
|
||||
public fun test_1(/*0*/ x: SomeEnum): kotlin.Unit
|
||||
public fun test_10(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_11(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_12(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_13(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_14(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_15(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_16(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_2(/*0*/ x: Base): kotlin.Unit
|
||||
public fun test_3(/*0*/ x: IBase): kotlin.Unit
|
||||
public fun test_4(/*0*/ x: kotlin.Boolean): kotlin.Unit
|
||||
public fun test_5(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_6(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_7(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_8(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_9(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
|
||||
public sealed class Base {
|
||||
protected constructor 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 A : Base {
|
||||
public constructor 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 final class B : Base {
|
||||
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 sealed interface IBase {
|
||||
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 A : IBase {
|
||||
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 B : IBase {
|
||||
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 enum class SomeEnum : kotlin.Enum<SomeEnum> {
|
||||
enum entry A
|
||||
|
||||
enum entry B
|
||||
|
||||
private constructor SomeEnum()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: SomeEnum): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<SomeEnum!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): SomeEnum
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<SomeEnum>
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes -ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes +ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// FIR_IDENTICAL
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
fun test1() {
|
||||
if (true) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (true) {
|
||||
|
||||
Generated
+6
@@ -31777,6 +31777,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_5.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_5() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/nonExhaustiveWhenStatement_1_5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_6.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_6() throws Exception {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -DEBUG_INFO_SMARTCAST
|
||||
// SKIP_TXT
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
// SKIP_TXT
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// SKIP_TXT
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
|
||||
/*
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_VALUE -VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// SKIP_TXT
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ enum class LanguageFeature(
|
||||
ProhibitSimplificationOfNonTrivialConstBooleanExpressions(KOTLIN_1_6),
|
||||
TypeInferenceOnCallsWithSelfTypes(KOTLIN_1_6),
|
||||
OptInRelease(KOTLIN_1_6),
|
||||
WarnAboutNonExhaustiveWhenOnAlgebraicTypes(KOTLIN_1_6, kind = BUG_FIX),
|
||||
|
||||
// 1.7
|
||||
|
||||
|
||||
+6
@@ -31681,6 +31681,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_5.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_5() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/when/nonExhaustiveWhenStatement_1_5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExhaustiveWhenStatement_1_6.kt")
|
||||
public void testNonExhaustiveWhenStatement_1_6() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user