Support builtin properties in ConstantExpressionEvaluator

This commit is contained in:
Denis Zharkov
2015-10-13 18:09:11 +03:00
committed by Mikhail Glukhikh
parent e062e32f95
commit 0b9c9a6047
4 changed files with 15 additions and 7 deletions
@@ -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)
@@ -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
View File
@@ -35,4 +35,4 @@ val prop9 = "a" + "b"
val prop10 = prop9 + "b"
// val prop11: 6
val prop11 = "kotlin".length()
val prop11 = "kotlin".length