Catch exceptions evaluating expression
This commit is contained in:
+5
-1
@@ -234,7 +234,11 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
if (functions == null) return null
|
||||
|
||||
val (function, checker) = functions
|
||||
val actualResult = function(receiver.value, parameter.value)
|
||||
val actualResult = try {
|
||||
function(receiver.value, parameter.value)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
if (checker == emptyBinaryFun) {
|
||||
return actualResult
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
// val prop1: null
|
||||
val prop1 = "".get(0)
|
||||
@@ -53,6 +53,11 @@ public class EvaluateExpressionTestGenerated extends AbstractEvaluateExpressionT
|
||||
doConstantTest("compiler/testData/evaluate/constant/equals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exceptionWhenEvaluate.kt")
|
||||
public void testExceptionWhenEvaluate() throws Exception {
|
||||
doConstantTest("compiler/testData/evaluate/constant/exceptionWhenEvaluate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
doConstantTest("compiler/testData/evaluate/constant/float.kt");
|
||||
|
||||
Reference in New Issue
Block a user