Store map (Call to KotlinType) for SMARTCAST slice #KT-13426 Fixed

Also EA-86848 Fixed
This commit is contained in:
Mikhail Glukhikh
2016-08-16 11:31:52 +03:00
parent dbff2be6fa
commit ae856e834a
15 changed files with 171 additions and 19 deletions
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContext.*
import org.jetbrains.kotlin.resolve.calls.smartcasts.MultipleSmartCasts
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
@@ -101,9 +102,19 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
val smartCast = bindingContext.get(SMARTCAST, expression)
if (smartCast != null) {
holder.createInfoAnnotation(getSmartCastTarget(expression),
"Smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(smartCast))
.textAttributes = SMART_CAST_VALUE
val defaultType = smartCast.defaultType
if (defaultType != null) {
holder.createInfoAnnotation(getSmartCastTarget(expression),
"Smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(defaultType))
.textAttributes = SMART_CAST_VALUE
}
else if (smartCast is MultipleSmartCasts) {
for ((call, type) in smartCast.map) {
holder.createInfoAnnotation(getSmartCastTarget(expression),
"Smart cast to ${DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type)} (for $call call)")
.textAttributes = SMART_CAST_VALUE
}
}
}
super.visitExpression(expression)