From d62d7dd84f4b851ec31005ec5471f659e0e11919 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 23 Dec 2015 15:39:43 +0300 Subject: [PATCH] Introduced binding context storage for implicit exhaustive when (KT-8700) --- .../src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java | 7 +++++++ .../src/org/jetbrains/kotlin/resolve/BindingContext.java | 1 + 2 files changed, 8 insertions(+) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java index 39b6f7ff34f..19d39f1d56d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/CheckerTestUtil.java @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer; import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.psi.KtReferenceExpression; +import org.jetbrains.kotlin.psi.KtWhenExpression; import org.jetbrains.kotlin.resolve.AnalyzingUtils; import org.jetbrains.kotlin.resolve.BindingContext; @@ -165,6 +166,11 @@ public class CheckerTestUtil { debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.CONSTANT)); } } + for (KtWhenExpression expression : bindingContext.getSliceContents(BindingContext.IMPLICIT_EXHAUSTIVE_WHEN).keySet()) { + if (PsiTreeUtil.isAncestor(root, expression, false)) { + debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.IMPLICIT_EXHAUSTIVE)); + } + } return debugAnnotations; } @@ -527,6 +533,7 @@ public class CheckerTestUtil { public static final DebugInfoDiagnosticFactory SMARTCAST = new DebugInfoDiagnosticFactory("SMARTCAST"); public static final DebugInfoDiagnosticFactory IMPLICIT_RECEIVER_SMARTCAST = new DebugInfoDiagnosticFactory("IMPLICIT_RECEIVER_SMARTCAST"); public static final DebugInfoDiagnosticFactory CONSTANT = new DebugInfoDiagnosticFactory("CONSTANT"); + public static final DebugInfoDiagnosticFactory IMPLICIT_EXHAUSTIVE = new DebugInfoDiagnosticFactory("IMPLICIT_EXHAUSTIVE"); public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE"); public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET"); public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java index fded8ff905c..0a1b2324b17 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java @@ -135,6 +135,7 @@ public interface BindingContext { WritableSlice IMPLICIT_RECEIVER_SMARTCAST = Slices.createSimpleSlice(); WritableSlice EXHAUSTIVE_WHEN = Slices.createSimpleSlice(); + WritableSlice IMPLICIT_EXHAUSTIVE_WHEN = Slices.createSimpleSlice(); WritableSlice LEXICAL_SCOPE = Slices.createSimpleSlice();