Misc: Follow-up fixes for 172/182 bunches

This commit is contained in:
Alexey Sedunov
2018-05-11 18:49:01 +03:00
parent 55b61bdc53
commit 4a98f1dccc
2 changed files with 8 additions and 2 deletions
@@ -129,7 +129,13 @@ sealed class CreateCallableFromCallActionFactory<E : KtExpression>(
if (javaClass == null || !javaClass.canRefactor()) return null
TypeInfo.StaticContextRequired(TypeInfo(javaClassifier.defaultType, Variance.IN_VARIANCE))
}
is ReceiverValue -> TypeInfo(receiver.type, Variance.IN_VARIANCE)
is ReceiverValue -> {
val originalType = receiver.type
val finalType = if (receiver is ExpressionReceiver) {
getDataFlowAwareTypes(receiver.expression, context, originalType).firstOrNull() ?: originalType
} else originalType
TypeInfo(finalType, Variance.IN_VARIANCE)
}
else -> throw AssertionError("Unexpected receiver: $receiver")
}
}
@@ -456,7 +456,7 @@ fun PsiElement.canRefactor(): Boolean {
this is KtElement ||
this is PsiMember && language == JavaLanguage.INSTANCE ||
this is PsiDirectory ->
ProjectRootsUtil.isInProjectSource(this)
ProjectRootsUtil.isInProjectSource(this) || ((containingFile as? KtFile)?.isScript() ?: false)
else ->
false
}