Support builtin properties in ConstantExpressionEvaluator
This commit is contained in:
committed by
Mikhail Glukhikh
parent
e062e32f95
commit
0b9c9a6047
+5
@@ -565,6 +565,11 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return evaluateCall(calleeExpression, receiverExpression, expectedType)
|
||||
}
|
||||
|
||||
if (selectorExpression is JetSimpleNameExpression) {
|
||||
val result = evaluateCall(selectorExpression, expression.receiverExpression, expectedType)
|
||||
if (result != null) return result
|
||||
}
|
||||
|
||||
// MyEnum.A, Integer.MAX_VALUE
|
||||
if (selectorExpression != null) {
|
||||
return evaluate(selectorExpression, expectedType)
|
||||
|
||||
+1
@@ -98,6 +98,7 @@ internal val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
|
||||
unaryOperation(SHORT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
|
||||
unaryOperation(SHORT, "toString", { a -> a.toString() }, emptyUnaryFun),
|
||||
unaryOperation(STRING, "length", { a -> a.length() }, emptyUnaryFun),
|
||||
unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun)
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -35,4 +35,4 @@ val prop9 = "a" + "b"
|
||||
val prop10 = prop9 + "b"
|
||||
|
||||
// val prop11: 6
|
||||
val prop11 = "kotlin".length()
|
||||
val prop11 = "kotlin".length
|
||||
|
||||
Reference in New Issue
Block a user