diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties
index e9247de5c9d..978c737a23c 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinBundle.properties
@@ -135,6 +135,7 @@ options.kotlin.attribute.descriptor.variable.as.function.like.call=Variable as f
options.kotlin.attribute.descriptor.smart.cast=Smart-cast value
options.kotlin.attribute.descriptor.smart.constant=Smart constant
options.kotlin.attribute.descriptor.smart.cast.receiver=Smart-cast implicit receiver
+options.kotlin.attribute.descriptor.implicit.exhaustive.when=Implicitly exhaustive when
options.kotlin.attribute.descriptor.label=Label
change.to.function.invocation=Change to function invocation
migrate.sure=Replace sure() calls by !! in project
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
index 0720295be39..11eb4e4e656 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightingColors.java
@@ -85,6 +85,7 @@ public class KotlinHighlightingColors {
public static final TextAttributesKey SMART_CAST_VALUE = createTextAttributesKey("KOTLIN_SMART_CAST_VALUE");
public static final TextAttributesKey SMART_CONSTANT = createTextAttributesKey("KOTLIN_SMART_CONSTANT");
public static final TextAttributesKey SMART_CAST_RECEIVER = createTextAttributesKey("KOTLIN_SMART_CAST_RECEIVER");
+ public static final TextAttributesKey IMPLICIT_EXHAUSTIVE_WHEN = createTextAttributesKey("KOTLIN_IMPLICIT_EXHAUSTIVE_WHEN");
public static final TextAttributesKey LABEL = createTextAttributesKey("KOTLIN_LABEL");
public static final TextAttributesKey DEBUG_INFO = createTextAttributesKey("KOTLIN_DEBUG_INFO");
public static final TextAttributesKey RESOLVED_TO_ERROR = createTextAttributesKey("KOTLIN_RESOLVED_TO_ERROR");
diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java
index d59ce1a88bb..b61742a2c70 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java
@@ -110,6 +110,15 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
.setTextAttributes(KotlinHighlightingColors.SMART_CAST_VALUE);
}
+ if (expression instanceof KtWhenExpression) {
+ KtWhenExpression whenExpression = (KtWhenExpression) expression;
+ boolean implicitExhaustiveWhen = bindingContext.get(IMPLICIT_EXHAUSTIVE_WHEN, whenExpression) == Boolean.TRUE;
+ if (implicitExhaustiveWhen) {
+ holder.createInfoAnnotation(whenExpression.getWhenKeyword(), "When is implicitly exhaustive")
+ .setTextAttributes(KotlinHighlightingColors.IMPLICIT_EXHAUSTIVE_WHEN);
+ }
+ }
+
super.visitExpression(expression);
}
diff --git a/idea/resources/colorScheme/Darcula_Kotlin.xml b/idea/resources/colorScheme/Darcula_Kotlin.xml
index 79e46f2670d..2c5f7fd6cce 100644
--- a/idea/resources/colorScheme/Darcula_Kotlin.xml
+++ b/idea/resources/colorScheme/Darcula_Kotlin.xml
@@ -40,6 +40,11 @@
+
diff --git a/idea/resources/colorScheme/Default_Kotlin.xml b/idea/resources/colorScheme/Default_Kotlin.xml
index e9b6ec4051d..1c0f804c24d 100644
--- a/idea/resources/colorScheme/Default_Kotlin.xml
+++ b/idea/resources/colorScheme/Default_Kotlin.xml
@@ -40,6 +40,11 @@
+
+
+
+
+
diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt
index d0869be09a6..d54b9521843 100644
--- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt
@@ -63,13 +63,17 @@ public class KotlinColorSettingsPage : ColorSettingsPage {
}
}
-fun Int?.bar() {
+fun Int?.bar(): Int {
if (this != null) {
println(toString())
}
else {
println(this.toString())
}
+ when (this != null) {
+ true -> return 1
+ false -> return 0
+ }
}
var globalCounter : Int = 5
@@ -157,6 +161,7 @@ var globalCount
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.cast") to KotlinHighlightingColors.SMART_CAST_VALUE,
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.constant") to KotlinHighlightingColors.SMART_CONSTANT,
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.cast.receiver") to KotlinHighlightingColors.SMART_CAST_RECEIVER,
+ KotlinBundle.message("options.kotlin.attribute.descriptor.implicit.exhaustive.when") to KotlinHighlightingColors.IMPLICIT_EXHAUSTIVE_WHEN,
KotlinBundle.message("options.kotlin.attribute.descriptor.label") to KotlinHighlightingColors.LABEL)
}
diff --git a/idea/testData/checker/infos/WhenImplicitExhaustive.kt b/idea/testData/checker/infos/WhenImplicitExhaustive.kt
new file mode 100644
index 00000000000..a6ffe810924
--- /dev/null
+++ b/idea/testData/checker/infos/WhenImplicitExhaustive.kt
@@ -0,0 +1,6 @@
+fun foo(b: Boolean): Int {
+ when (b) {
+ true -> return 1
+ false -> return 0
+ }
+}
diff --git a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java
index 073c97680b5..47789e23f8f 100644
--- a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java
@@ -766,6 +766,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
doTestWithInfos(fileName);
}
+ @TestMetadata("WhenImplicitExhaustive.kt")
+ public void testWhenImplicitExhaustive() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/WhenImplicitExhaustive.kt");
+ doTestWithInfos(fileName);
+ }
+
@TestMetadata("WrapIntoRef.kt")
public void testWrapIntoRef() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/WrapIntoRef.kt");