Limit "always null" scope: only for !!, is and dot; senseless comparison rolled back; "smart constant" information for nulls #KT-10029 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-11-23 14:50:20 +03:00
parent db42941586
commit 89e56093a2
41 changed files with 323 additions and 151 deletions
@@ -134,6 +134,7 @@ options.kotlin.attribute.descriptor.constructor.call=Constructor call
options.kotlin.attribute.descriptor.variable.as.function.call=Variable as function call
options.kotlin.attribute.descriptor.variable.as.function.like.call=Variable as function-like call
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.label=Label
change.to.function.invocation=Change to function invocation
@@ -83,6 +83,7 @@ public class KotlinHighlightingColors {
// other
public static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("KOTLIN_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
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 LABEL = createTextAttributesKey("KOTLIN_LABEL");
public static final TextAttributesKey DEBUG_INFO = createTextAttributesKey("KOTLIN_DEBUG_INFO");
@@ -76,6 +76,12 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
.setTextAttributes(KotlinHighlightingColors.SMART_CAST_RECEIVER);
}
boolean nullSmartCast = bindingContext.get(SMARTCAST_NULL, expression) == Boolean.TRUE;
if (nullSmartCast) {
holder.createInfoAnnotation(expression, "Always null")
.setTextAttributes(KotlinHighlightingColors.SMART_CONSTANT);
}
KotlinType smartCast = bindingContext.get(SMARTCAST, expression);
if (smartCast != null) {
holder.createInfoAnnotation(expression, "Smart cast to " +