KT-13426: store map from ImplicitReceiver into KotlinType for implicit receiver smart casts
This commit is contained in:
+12
-3
@@ -29,6 +29,8 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.types.expressions.CaptureKind
|
||||
|
||||
internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingContext: BindingContext)
|
||||
@@ -79,9 +81,16 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
||||
override fun visitExpression(expression: KtExpression) {
|
||||
val implicitSmartCast = bindingContext.get(IMPLICIT_RECEIVER_SMARTCAST, expression)
|
||||
if (implicitSmartCast != null) {
|
||||
holder.createInfoAnnotation(expression,
|
||||
"Implicit receiver smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(implicitSmartCast))
|
||||
.textAttributes = SMART_CAST_RECEIVER
|
||||
for ((receiver, type) in implicitSmartCast.receiverTypes) {
|
||||
val receiverName = when (receiver) {
|
||||
is ExtensionReceiver -> "Extension implicit receiver"
|
||||
is ImplicitClassReceiver -> "Implicit receiver"
|
||||
else -> "Unknown receiver"
|
||||
}
|
||||
holder.createInfoAnnotation(expression,
|
||||
"$receiverName smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type))
|
||||
.textAttributes = SMART_CAST_RECEIVER
|
||||
}
|
||||
}
|
||||
|
||||
val nullSmartCast = bindingContext.get(SMARTCAST_NULL, expression) == true
|
||||
|
||||
Reference in New Issue
Block a user