Fix EA-47308
Don't always cast PsiFile to JetFile, first check if it really is a Kotlin source
This commit is contained in:
@@ -58,9 +58,10 @@ public class CastExpressionFix extends JetIntentionAction<JetExpression> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||||
|
if (!super.isAvailable(project, editor, file)) return false;
|
||||||
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) file).getBindingContext();
|
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) file).getBindingContext();
|
||||||
JetType expressionType = context.get(BindingContext.EXPRESSION_TYPE, element);
|
JetType expressionType = context.get(BindingContext.EXPRESSION_TYPE, element);
|
||||||
return super.isAvailable(project, editor, file) && expressionType != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, expressionType);
|
return expressionType != null && JetTypeChecker.INSTANCE.isSubtypeOf(type, expressionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user