Check type of elvis with expected type info
#KT-6713
This commit is contained in:
+1
-1
@@ -1306,7 +1306,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If break or continue was possible, take condition check info as the jump info
|
// If break or continue was possible, take condition check info as the jump info
|
||||||
return TypeInfoFactoryPackage.createTypeInfo(DataFlowUtils.checkType(type, expression, context),
|
return TypeInfoFactoryPackage.createTypeInfo(DataFlowUtils.checkType(type, expression, contextWithExpectedType),
|
||||||
dataFlowInfo,
|
dataFlowInfo,
|
||||||
loopBreakContinuePossible,
|
loopBreakContinuePossible,
|
||||||
context.dataFlowInfo);
|
context.dataFlowInfo);
|
||||||
|
|||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class RightElvisOperand {
|
||||||
|
static String foo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
fun baz(): String? = null
|
||||||
|
|
||||||
|
fun bar(): String = baz() ?: RightElvisOperand.foo()
|
||||||
|
|
||||||
|
fun foo(x: String) {}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
try {
|
||||||
|
foo(baz() ?: RightElvisOperand.foo())
|
||||||
|
return "Fail: should have been an exception in `foo(baz() ?: RightElvisOperand.foo())`"
|
||||||
|
}
|
||||||
|
catch(e: IllegalStateException) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bar()
|
||||||
|
return "Fail: should have been an exception in `bar()`"
|
||||||
|
}
|
||||||
|
catch(e: IllegalStateException) {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -423,6 +423,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/notNullAssertions/Delegation.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/notNullAssertions/Delegation.kt");
|
||||||
doTestAgainstJava(fileName);
|
doTestAgainstJava(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("RightElvisOperand.kt")
|
||||||
|
public void testRightElvisOperand() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/notNullAssertions/RightElvisOperand.kt");
|
||||||
|
doTestAgainstJava(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/platformTypes")
|
@TestMetadata("compiler/testData/codegen/boxAgainstJava/platformTypes")
|
||||||
|
|||||||
Reference in New Issue
Block a user