[FE 1.0] Fix reporting of non exhaustive when statement for whens with subject

^KT-48653 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-09-09 15:19:18 +03:00
parent f6ae6af741
commit 7a7672b0de
9 changed files with 145 additions and 4 deletions
@@ -1002,7 +1002,7 @@ class ControlFlowInformationProviderImpl private constructor(
trace.report(EXPECT_TYPE_IN_WHEN_WITHOUT_ELSE.on(element, it.typeOfDeclaration))
}
} else if (subjectExpression != null) {
val subjectType = trace.getType(subjectExpression)
val subjectType = WhenChecker.whenSubjectType(element, trace.bindingContext)
if (elseEntry != null) {
if (missingCases.isEmpty() && subjectType != null && !subjectType.isFlexible()) {
val subjectClass = subjectType.constructor.declarationDescriptor as? ClassDescriptor
@@ -1016,9 +1016,6 @@ class ControlFlowInformationProviderImpl private constructor(
}
}
continue
}
if (!usedAsExpression) {
}
if (!usedAsExpression) {
if (languageVersionSettings.supportsFeature(LanguageFeature.WarnAboutNonExhaustiveWhenOnAlgebraicTypes)) {