Rename: casted -> cast
This commit is contained in:
@@ -313,7 +313,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
public static StackValue thisOrOuter(ExpressionCodegen codegen, ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) {
|
public static StackValue thisOrOuter(ExpressionCodegen codegen, ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) {
|
||||||
// Coerce this/super for traits to support traits with required classes.
|
// Coerce this/super for traits to support traits with required classes.
|
||||||
// Coerce explicit 'this' for the case when it is smartcasted.
|
// Coerce explicit 'this' for the case when it is smart cast.
|
||||||
// Do not coerce for other classes due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
|
// Do not coerce for other classes due to the 'protected' access issues (JVMS 7, 4.9.2 Structural Constraints).
|
||||||
boolean coerceType = descriptor.getKind() == ClassKind.TRAIT || (isExplicit && !isSuper);
|
boolean coerceType = descriptor.getKind() == ClassKind.TRAIT || (isExplicit && !isSuper);
|
||||||
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
|
return new ThisOuter(codegen, descriptor, isSuper, coerceType);
|
||||||
|
|||||||
+2
-2
@@ -152,10 +152,10 @@ public class SmartCastUtils {
|
|||||||
@NotNull JetExpression expression,
|
@NotNull JetExpression expression,
|
||||||
@NotNull JetType type,
|
@NotNull JetType type,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
boolean canBeCasted,
|
boolean canBeCast,
|
||||||
boolean recordExpressionType
|
boolean recordExpressionType
|
||||||
) {
|
) {
|
||||||
if (canBeCasted) {
|
if (canBeCast) {
|
||||||
trace.record(SMARTCAST, expression, type);
|
trace.record(SMARTCAST, expression, type);
|
||||||
if (recordExpressionType) {
|
if (recordExpressionType) {
|
||||||
//TODO
|
//TODO
|
||||||
|
|||||||
@@ -7067,9 +7067,9 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("smartCastedReceiverWithGenerics.kt")
|
@TestMetadata("smartCastReceiverWithGenerics.kt")
|
||||||
public void testSmartCastedReceiverWithGenerics() throws Exception {
|
public void testSmartCastReceiverWithGenerics() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastedReceiverWithGenerics.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/smartCastReceiverWithGenerics.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -1803,9 +1803,9 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("forInSmartCastedToArray.kt")
|
@TestMetadata("forInSmartCastToArray.kt")
|
||||||
public void testForInSmartCastedToArray() throws Exception {
|
public void testForInSmartCastToArray() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/forInSmartCastedToArray.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/forInSmartCastToArray.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6523,9 +6523,9 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitSmartCastedThis.kt")
|
@TestMetadata("implicitSmartCastThis.kt")
|
||||||
public void testImplicitSmartCastedThis() throws Exception {
|
public void testImplicitSmartCastThis() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/implicitSmartCastedThis.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/implicitSmartCastThis.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6553,9 +6553,9 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("smartCastedThis.kt")
|
@TestMetadata("smartCastThis.kt")
|
||||||
public void testSmartCastedThis() throws Exception {
|
public void testSmartCastThis() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/smartCastedThis.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/typeInfo/smartCastThis.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,17 +69,17 @@ public class CastExpressionFix extends JetIntentionAction<JetExpression> {
|
|||||||
@Override
|
@Override
|
||||||
public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
||||||
JetPsiFactory psiFactory = JetPsiFactory(file);
|
JetPsiFactory psiFactory = JetPsiFactory(file);
|
||||||
JetBinaryExpressionWithTypeRHS castedExpression =
|
JetBinaryExpressionWithTypeRHS castExpression =
|
||||||
(JetBinaryExpressionWithTypeRHS) psiFactory.createExpression("(" + element.getText() + ") as " + renderedType);
|
(JetBinaryExpressionWithTypeRHS) psiFactory.createExpression("(" + element.getText() + ") as " + renderedType);
|
||||||
if (JetPsiUtil.areParenthesesUseless((JetParenthesizedExpression) castedExpression.getLeft())) {
|
if (JetPsiUtil.areParenthesesUseless((JetParenthesizedExpression) castExpression.getLeft())) {
|
||||||
castedExpression = (JetBinaryExpressionWithTypeRHS) psiFactory.createExpression(element.getText() + " as " + renderedType);
|
castExpression = (JetBinaryExpressionWithTypeRHS) psiFactory.createExpression(element.getText() + " as " + renderedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
JetParenthesizedExpression castedExpressionInParentheses =
|
JetParenthesizedExpression castExpressionInParentheses =
|
||||||
(JetParenthesizedExpression) element.replace(psiFactory.createExpression("(" + castedExpression.getText() + ")"));
|
(JetParenthesizedExpression) element.replace(psiFactory.createExpression("(" + castExpression.getText() + ")"));
|
||||||
|
|
||||||
if (JetPsiUtil.areParenthesesUseless(castedExpressionInParentheses)) {
|
if (JetPsiUtil.areParenthesesUseless(castExpressionInParentheses)) {
|
||||||
castedExpressionInParentheses.replace(castedExpression);
|
castExpressionInParentheses.replace(castExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user