Add constructor parameter for compileTimeConstant (can be used in annotation)
This commit is contained in:
+3
-2
@@ -90,11 +90,12 @@ public class TraceBasedJavaResolverCache implements JavaResolverCache {
|
||||
PsiField psiField = ((JavaFieldImpl) field).getPsi();
|
||||
trace.record(VARIABLE, psiField, descriptor);
|
||||
|
||||
if (AnnotationUtils.isPropertyCompileTimeConstant(descriptor)) {
|
||||
if (!descriptor.isVar()) {
|
||||
PsiExpression initializer = psiField.getInitializer();
|
||||
Object evaluatedExpression = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false);
|
||||
if (evaluatedExpression != null) {
|
||||
CompileTimeConstant<?> constant = JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue(evaluatedExpression, descriptor.getType());
|
||||
CompileTimeConstant<?> constant = JavaAnnotationArgumentResolver.
|
||||
resolveCompileTimeConstantValue(evaluatedExpression, AnnotationUtils.isPropertyCompileTimeConstant(descriptor), descriptor.getType());
|
||||
if (constant != null) {
|
||||
trace.record(COMPILE_TIME_INITIALIZER, descriptor, constant);
|
||||
}
|
||||
|
||||
@@ -555,8 +555,12 @@ public class JetControlFlowProcessor {
|
||||
}
|
||||
boolean conditionIsTrueConstant = false;
|
||||
if (condition instanceof JetConstantExpression && condition.getNode().getElementType() == JetNodeTypes.BOOLEAN_CONSTANT) {
|
||||
if (BooleanValue.TRUE == ConstantExpressionEvaluator.object$.evaluate(condition, trace, KotlinBuiltIns.getInstance().getBooleanType())) {
|
||||
conditionIsTrueConstant = true;
|
||||
CompileTimeConstant<?> compileTimeConstant = ConstantExpressionEvaluator.object$.evaluate(condition, trace, KotlinBuiltIns.getInstance().getBooleanType());
|
||||
if (compileTimeConstant instanceof BooleanValue) {
|
||||
Boolean value = ((BooleanValue) compileTimeConstant).getValue();
|
||||
if (Boolean.TRUE.equals(value)) {
|
||||
conditionIsTrueConstant = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!conditionIsTrueConstant) {
|
||||
|
||||
+52
-47
@@ -74,9 +74,9 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
return createStringConstant(this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType()))
|
||||
}
|
||||
|
||||
override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = StringValue(entry.getText())
|
||||
override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = StringValue(entry.getText(), true)
|
||||
|
||||
override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = StringValue(entry.getUnescapedValue())
|
||||
override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = StringValue(entry.getUnescapedValue(), true)
|
||||
}
|
||||
|
||||
override fun visitConstantExpression(expression: JetConstantExpression, expectedType: JetType?): CompileTimeConstant<*>? {
|
||||
@@ -123,6 +123,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
override fun visitStringTemplateExpression(expression: JetStringTemplateExpression, expectedType: JetType?): CompileTimeConstant<*>? {
|
||||
val sb = StringBuilder()
|
||||
var interupted = false
|
||||
var canBeUsedInAnnotation = true
|
||||
for (entry in expression.getEntries()) {
|
||||
val constant = stringExpressionEvaluator.evaluate(entry)
|
||||
if (constant == null) {
|
||||
@@ -130,10 +131,11 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
break
|
||||
}
|
||||
else {
|
||||
if (!constant.canBeUsedInAnnotations()) canBeUsedInAnnotation = false
|
||||
sb.append(constant.getValue())
|
||||
}
|
||||
}
|
||||
return if (!interupted) createCompileTimeConstant(sb.toString(), expression, expectedType) else null
|
||||
return if (!interupted) createCompileTimeConstant(sb.toString(), expression, expectedType, true, canBeUsedInAnnotation) else null
|
||||
}
|
||||
|
||||
override fun visitBinaryExpression(expression: JetBinaryExpression, expectedType: JetType?): CompileTimeConstant<*>? {
|
||||
@@ -198,13 +200,15 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
|
||||
val result = evaluateBinaryAndCheck(argumentForReceiver, argumentForParameter, resultingDescriptorName.asString(), callExpression)
|
||||
|
||||
val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression)
|
||||
val context = EvaluatorContext(canBeUsedInAnnotation)
|
||||
return when(resultingDescriptorName) {
|
||||
OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression)
|
||||
OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression)
|
||||
OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, context)
|
||||
OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, context)
|
||||
else -> {
|
||||
val areArgumentsPure = trace.get(BindingContext.IS_PURE_CONSTANT_EXPRESSION, argumentForReceiver.expression) ?: false &&
|
||||
trace.get(BindingContext.IS_PURE_CONSTANT_EXPRESSION, argumentForParameter.expression) ?: false
|
||||
val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression)
|
||||
|
||||
createCompileTimeConstant(result, fullExpression, expectedType, areArgumentsPure, canBeUsedInAnnotation)
|
||||
}
|
||||
}
|
||||
@@ -339,7 +343,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
val varargType = resultingDescriptor.getValueParameters().first?.getVarargElementType()!!
|
||||
|
||||
val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) }
|
||||
return ArrayValue(arguments, resultingDescriptor.getReturnType()!!)
|
||||
return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, true)
|
||||
}
|
||||
|
||||
// Ann()
|
||||
@@ -355,7 +359,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
|
||||
// javaClass()
|
||||
if (AnnotationUtils.isJavaClassMethodCall(call)) {
|
||||
return JavaClassValue(resultingDescriptor.getReturnType())
|
||||
return JavaClassValue(resultingDescriptor.getReturnType()!!)
|
||||
}
|
||||
|
||||
return null
|
||||
@@ -366,9 +370,9 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
for (argument in valueArguments) {
|
||||
val argumentExpression = argument.getArgumentExpression()
|
||||
if (argumentExpression != null) {
|
||||
val constant = evaluate(argumentExpression, expectedType)
|
||||
if (constant != null) {
|
||||
constants.add(constant)
|
||||
val compileTimeConstant = evaluate(argumentExpression, expectedType)
|
||||
if (compileTimeConstant != null) {
|
||||
constants.add(compileTimeConstant)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,14 +424,13 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet
|
||||
}
|
||||
|
||||
fun createCompileTimeConstant(value: Any?, expression: JetExpression, expectedType: JetType?, isPure: Boolean = true, canBeUsedInAnnotation: Boolean = true): CompileTimeConstant<*>? {
|
||||
val c = EvaluatorContext(canBeUsedInAnnotation)
|
||||
val compileTimeConstant =
|
||||
if (isPure) {
|
||||
trace.record(BindingContext.IS_PURE_CONSTANT_EXPRESSION, expression, true)
|
||||
createCompileTimeConstant(value, expectedType ?: TypeUtils.NO_EXPECTED_TYPE)
|
||||
createCompileTimeConstant(value, c, expectedType ?: TypeUtils.NO_EXPECTED_TYPE)
|
||||
}
|
||||
else createCompileTimeConstant(value)
|
||||
|
||||
compileTimeConstant?.setCanBeUsedInAnnotations(canBeUsedInAnnotation)
|
||||
else createCompileTimeConstant(value, c)
|
||||
|
||||
return compileTimeConstant
|
||||
}
|
||||
@@ -450,7 +453,7 @@ public fun recordCompileTimeValueForInitializerIfNeeded(
|
||||
}
|
||||
|
||||
public fun IntegerValueTypeConstant.createCompileTimeConstantWithType(expectedType: JetType): CompileTimeConstant<*>?
|
||||
= createCompileTimeConstant(getValue(expectedType))
|
||||
= createCompileTimeConstant(getValue(expectedType), EvaluatorContext(canBeUsedInAnnotations()))
|
||||
|
||||
private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L')
|
||||
|
||||
@@ -507,16 +510,16 @@ private fun parseBoolean(text: String): Boolean {
|
||||
}
|
||||
|
||||
|
||||
private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression): CompileTimeConstant<*>? {
|
||||
private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, context: EvaluatorContext): CompileTimeConstant<*>? {
|
||||
if (result is Boolean) {
|
||||
assert(operationReference is JetSimpleNameExpression, "This method should be called only for equals operations")
|
||||
val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType()
|
||||
return when (operationToken) {
|
||||
JetTokens.EQEQ -> BooleanValue.valueOf(result)
|
||||
JetTokens.EXCLEQ -> BooleanValue.valueOf(!result)
|
||||
JetTokens.EQEQ -> BooleanValue(result, context.canBeUsedInAnnotation)
|
||||
JetTokens.EXCLEQ -> BooleanValue(!result, context.canBeUsedInAnnotation)
|
||||
JetTokens.IDENTIFIER -> {
|
||||
assert ((operationReference as JetSimpleNameExpression).getReferencedNameAsName() == OperatorConventions.EQUALS, "This method should be called only for equals operations")
|
||||
return BooleanValue.valueOf(result)
|
||||
return BooleanValue(result, context.canBeUsedInAnnotation)
|
||||
}
|
||||
else -> throw IllegalStateException("Unknown equals operation token: $operationToken ${operationReference.getText()}")
|
||||
}
|
||||
@@ -524,18 +527,18 @@ private fun createCompileTimeConstantForEquals(result: Any?, operationReference:
|
||||
return null
|
||||
}
|
||||
|
||||
private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression): CompileTimeConstant<*>? {
|
||||
private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, context: EvaluatorContext): CompileTimeConstant<*>? {
|
||||
if (result is Int) {
|
||||
assert(operationReference is JetSimpleNameExpression, "This method should be called only for compareTo operations")
|
||||
val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType()
|
||||
return when (operationToken) {
|
||||
JetTokens.LT -> BooleanValue.valueOf(result < 0)
|
||||
JetTokens.LTEQ -> BooleanValue.valueOf(result <= 0)
|
||||
JetTokens.GT -> BooleanValue.valueOf(result > 0)
|
||||
JetTokens.GTEQ -> BooleanValue.valueOf(result >= 0)
|
||||
JetTokens.LT -> BooleanValue(result < 0, context.canBeUsedInAnnotation)
|
||||
JetTokens.LTEQ -> BooleanValue(result <= 0, context.canBeUsedInAnnotation)
|
||||
JetTokens.GT -> BooleanValue(result > 0, context.canBeUsedInAnnotation)
|
||||
JetTokens.GTEQ -> BooleanValue(result >= 0, context.canBeUsedInAnnotation)
|
||||
JetTokens.IDENTIFIER -> {
|
||||
assert ((operationReference as JetSimpleNameExpression).getReferencedNameAsName() == OperatorConventions.COMPARE_TO, "This method should be called only for compareTo operations")
|
||||
return IntValue(result)
|
||||
return IntValue(result, context.canBeUsedInAnnotation)
|
||||
}
|
||||
else -> throw IllegalStateException("Unknown compareTo operation token: $operationToken")
|
||||
}
|
||||
@@ -545,33 +548,33 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen
|
||||
|
||||
private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? {
|
||||
return when (value) {
|
||||
is IntegerValueTypeConstant -> StringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString())
|
||||
is IntegerValueTypeConstant -> StringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString(), value.canBeUsedInAnnotations())
|
||||
is StringValue -> value
|
||||
is IntValue, is ByteValue, is ShortValue, is LongValue,
|
||||
is CharValue,
|
||||
is DoubleValue, is FloatValue,
|
||||
is BooleanValue,
|
||||
is NullValue -> StringValue(value.getValue().toString())
|
||||
is NullValue -> StringValue(value.getValue().toString(), value.canBeUsedInAnnotations())
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun createCompileTimeConstant(value: Any?, expectedType: JetType? = null): CompileTimeConstant<*>? {
|
||||
private fun createCompileTimeConstant(value: Any?, c: EvaluatorContext, expectedType: JetType? = null): CompileTimeConstant<*>? {
|
||||
if (expectedType == null) {
|
||||
when(value) {
|
||||
is Byte -> return ByteValue(value)
|
||||
is Short -> return ShortValue(value)
|
||||
is Int -> return IntValue(value)
|
||||
is Long -> return LongValue(value)
|
||||
is Byte -> return ByteValue(value, c.canBeUsedInAnnotation)
|
||||
is Short -> return ShortValue(value, c.canBeUsedInAnnotation)
|
||||
is Int -> return IntValue(value, c.canBeUsedInAnnotation)
|
||||
is Long -> return LongValue(value, c.canBeUsedInAnnotation)
|
||||
}
|
||||
}
|
||||
return when(value) {
|
||||
is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), expectedType)
|
||||
is Char -> CharValue(value)
|
||||
is Float -> FloatValue(value)
|
||||
is Double -> DoubleValue(value)
|
||||
is Boolean -> BooleanValue.valueOf(value)
|
||||
is String -> StringValue(value)
|
||||
is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), c, expectedType)
|
||||
is Char -> CharValue(value, c.canBeUsedInAnnotation)
|
||||
is Float -> FloatValue(value, c.canBeUsedInAnnotation)
|
||||
is Double -> DoubleValue(value, c.canBeUsedInAnnotation)
|
||||
is Boolean -> BooleanValue(value, c.canBeUsedInAnnotation)
|
||||
is String -> StringValue(value, c.canBeUsedInAnnotation)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -579,29 +582,29 @@ private fun createCompileTimeConstant(value: Any?, expectedType: JetType? = null
|
||||
|
||||
fun isIntegerType(value: Any?) = value is Byte || value is Short || value is Int || value is Long
|
||||
|
||||
private fun getIntegerValue(value: Long, expectedType: JetType): CompileTimeConstant<*>? {
|
||||
private fun getIntegerValue(value: Long, c: EvaluatorContext, expectedType: JetType): CompileTimeConstant<*>? {
|
||||
fun defaultIntegerValue(value: Long) = when (value) {
|
||||
value.toInt().toLong() -> IntValue(value.toInt())
|
||||
else -> LongValue(value)
|
||||
value.toInt().toLong() -> IntValue(value.toInt(), c.canBeUsedInAnnotation)
|
||||
else -> LongValue(value, c.canBeUsedInAnnotation)
|
||||
}
|
||||
|
||||
if (CompileTimeConstantChecker.noExpectedTypeOrError(expectedType)) {
|
||||
return IntegerValueTypeConstant(value)
|
||||
return IntegerValueTypeConstant(value, c.canBeUsedInAnnotation)
|
||||
}
|
||||
|
||||
val builtIns = KotlinBuiltIns.getInstance()
|
||||
|
||||
return when (TypeUtils.makeNotNullable(expectedType)) {
|
||||
builtIns.getLongType() -> LongValue(value)
|
||||
builtIns.getLongType() -> LongValue(value, c.canBeUsedInAnnotation)
|
||||
builtIns.getShortType() -> when (value) {
|
||||
value.toShort().toLong() -> ShortValue(value.toShort())
|
||||
value.toShort().toLong() -> ShortValue(value.toShort(), c.canBeUsedInAnnotation)
|
||||
else -> defaultIntegerValue(value)
|
||||
}
|
||||
builtIns.getByteType() -> when (value) {
|
||||
value.toByte().toLong() -> ByteValue(value.toByte())
|
||||
value.toByte().toLong() -> ByteValue(value.toByte(), c.canBeUsedInAnnotation)
|
||||
else -> defaultIntegerValue(value)
|
||||
}
|
||||
builtIns.getCharType() -> IntValue(value.toInt())
|
||||
builtIns.getCharType() -> IntValue(value.toInt(), c.canBeUsedInAnnotation)
|
||||
else -> defaultIntegerValue(value)
|
||||
}
|
||||
}
|
||||
@@ -633,6 +636,8 @@ private fun getCompileTimeType(c: JetType): CompileTimeType<out Any>? {
|
||||
}
|
||||
}
|
||||
|
||||
private class EvaluatorContext(val canBeUsedInAnnotation: Boolean)
|
||||
|
||||
private class CompileTimeType<T>
|
||||
|
||||
private val BYTE = CompileTimeType<Byte>()
|
||||
|
||||
@@ -227,7 +227,7 @@ public class AnnotationResolver {
|
||||
if (arrayType == null) {
|
||||
arrayType = KotlinBuiltIns.getInstance().getArrayType(varargElementType);
|
||||
}
|
||||
annotationDescriptor.setValueArgument(parameterDescriptor, new ArrayValue(constants, arrayType));
|
||||
annotationDescriptor.setValueArgument(parameterDescriptor, new ArrayValue(constants, arrayType, true));
|
||||
}
|
||||
else {
|
||||
for (CompileTimeConstant<?> constant : constants) {
|
||||
|
||||
+3
-3
@@ -167,7 +167,7 @@ public class CompileTimeConstantChecker {
|
||||
if (text.charAt(0) != '\\') {
|
||||
// No escape
|
||||
if (text.length() == 1) {
|
||||
return new CharValue(text.charAt(0));
|
||||
return new CharValue(text.charAt(0), true);
|
||||
}
|
||||
return createErrorValue(TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL.on(expression, expression));
|
||||
}
|
||||
@@ -190,13 +190,13 @@ public class CompileTimeConstantChecker {
|
||||
if (escaped == null) {
|
||||
return illegalEscape(expression);
|
||||
}
|
||||
return new CharValue(escaped);
|
||||
return new CharValue(escaped, true);
|
||||
case 5:
|
||||
// unicode escape
|
||||
if (escape.charAt(0) == 'u') {
|
||||
try {
|
||||
Integer intValue = Integer.valueOf(escape.substring(1), 16);
|
||||
return new CharValue((char) intValue.intValue());
|
||||
return new CharValue((char) intValue.intValue(), true);
|
||||
} catch (NumberFormatException e) {
|
||||
// Will be reported below
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
annotation class Ann(vararg val i: Boolean)
|
||||
fun foo() {
|
||||
val bool1 = true
|
||||
|
||||
[Ann(<!ANNOTATION_PARAMETER_MUST_BE_CONST!>bool1<!>)] val <!UNUSED_VARIABLE!>a<!> = bool1
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
annotation class Ann(vararg val i: Boolean)
|
||||
fun foo() {
|
||||
val a1 = 1 > 2
|
||||
val a2 = 1 == 2
|
||||
val a3 = a1 == a2
|
||||
val a4 = a1 > a2
|
||||
|
||||
[Ann(
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a1<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a2<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a3<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a1 > a2<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a1 == a2<!>
|
||||
)] val b = 1
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// FILE: Test.java
|
||||
public class Test {
|
||||
public static int i1 = 1;
|
||||
public static final int i2 = 1;
|
||||
public static final int i3 = i1;
|
||||
public static final int i4 = i2;
|
||||
public static int i5 = i1;
|
||||
public static int i6 = i2;
|
||||
|
||||
public final int i7 = 1;
|
||||
}
|
||||
|
||||
// FILE: a.kt
|
||||
annotation class Ann(vararg val i: Int)
|
||||
|
||||
Ann(
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>Test.i1<!>,
|
||||
Test.i2,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>Test.i3<!>,
|
||||
Test.i4,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>Test.i5<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>Test.i6<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>Test().i7<!>
|
||||
)
|
||||
class A
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
annotation class Ann(vararg val i: Int)
|
||||
|
||||
Ann(
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>i1<!>,
|
||||
i2,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>i3<!>,
|
||||
i4,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>i5<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>i6<!>
|
||||
)
|
||||
class Test
|
||||
|
||||
var i1 = 1 // var
|
||||
val i2 = 1 // val
|
||||
val i3 = i1 // val with var in initializer
|
||||
val i4 = i2 // val with val in initializer
|
||||
var i5 = i1 // var with var in initializer
|
||||
var i6 = i2 // var with val in initializer
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
annotation class Ann(vararg val i: String)
|
||||
|
||||
val topLevel = "topLevel"
|
||||
|
||||
fun foo() {
|
||||
val a1 = "a"
|
||||
val a2 = "b"
|
||||
val a3 = a1 + a2
|
||||
|
||||
val a4 = 1
|
||||
val a5 = 1.0
|
||||
|
||||
[Ann(
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a1<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a2<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a3<!>,
|
||||
"$topLevel",
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"$a1"<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"$a1 $topLevel"<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"$a4"<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"$a5"<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>a1 + a2<!>,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"a" + a2<!>,
|
||||
"a" + topLevel,
|
||||
<!ANNOTATION_PARAMETER_MUST_BE_CONST!>"a" + a4<!>
|
||||
)] val b = 1
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// FILE: Test.java
|
||||
public class Test {
|
||||
public static int i1 = Integer.MAX_VALUE;
|
||||
public static final int i2 = Integer.MAX_VALUE;
|
||||
public final int i3 = Integer.MAX_VALUE;
|
||||
public int i4 = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
// FILE: A.kt
|
||||
val a1: Int = Test.i1 + 1
|
||||
val a2: Int = <!INTEGER_OVERFLOW!>Test.i2 + 1<!>
|
||||
val a3: Int = <!INTEGER_OVERFLOW!>Test().i3 + 1<!>
|
||||
val a4: Int = Test().i4 + 1
|
||||
@@ -551,26 +551,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationModifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationParameterMustBeClassLiteral.kt")
|
||||
public void testAnnotationParameterMustBeClassLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeClassLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationParameterMustBeConstant.kt")
|
||||
public void testAnnotationParameterMustBeConstant() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationParameterMustBeConstantVararg.kt")
|
||||
public void testAnnotationParameterMustBeConstantVararg() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstantVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("annotationParameterMustBeEnumConst.kt")
|
||||
public void testAnnotationParameterMustBeEnumConst() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeEnumConst.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationsForClasses.kt")
|
||||
public void testAnnotationsForClasses() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.kt");
|
||||
@@ -662,6 +642,51 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/array.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("booleanLocalVal.kt")
|
||||
public void testBooleanLocalVal() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classLiteral.kt")
|
||||
public void testClassLiteral() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/classLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compareAndEquals.kt")
|
||||
public void testCompareAndEquals() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enumConst.kt")
|
||||
public void testEnumConst() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaProperties.kt")
|
||||
public void testJavaProperties() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinProperties.kt")
|
||||
public void testKotlinProperties() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("strings.kt")
|
||||
public void testStrings() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/vararg.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
@@ -2879,6 +2904,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/evaluate/intOverflow.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intOverflowWithJavaProperties.kt")
|
||||
public void testIntOverflowWithJavaProperties() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/evaluate/intOverflowWithJavaProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("integer.kt")
|
||||
public void testInteger() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/evaluate/integer.kt");
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
|
||||
private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): CompileTimeConstant<*>? {
|
||||
return when (argument) {
|
||||
is JavaLiteralAnnotationArgument -> JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue(argument.getValue(), null)
|
||||
is JavaLiteralAnnotationArgument -> JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue(argument.getValue(), true, null)
|
||||
is JavaReferenceAnnotationArgument -> resolveFromReference(argument.resolve())
|
||||
is JavaArrayAnnotationArgument -> resolveFromArray(argument.getName() ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements())
|
||||
is JavaAnnotationAsAnnotationArgument -> resolveFromAnnotation(argument.getAnnotation())
|
||||
@@ -123,7 +123,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
val values = elements.map {
|
||||
argument -> resolveAnnotationArgument(argument) ?: NullValue.NULL
|
||||
}
|
||||
return ArrayValue(values, valueParameter.getType())
|
||||
return ArrayValue(values, valueParameter.getType(), true)
|
||||
}
|
||||
|
||||
private fun resolveFromReference(element: JavaElement?): CompileTimeConstant<*>? {
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
ValueParameterDescriptor value = DescriptorResolverUtils.getAnnotationParameterByName(
|
||||
JavaAnnotationResolver.DEFAULT_ANNOTATION_MEMBER_NAME, annotationClass);
|
||||
assert value != null : "jet.deprecated must have one parameter called value";
|
||||
annotation.setValueArgument(value, new StringValue("Deprecated in Java"));
|
||||
annotation.setValueArgument(value, new StringValue("Deprecated in Java", true));
|
||||
return annotation;
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -70,7 +70,7 @@ public final class JavaAnnotationArgumentResolver {
|
||||
@NotNull PostponedTasks postponedTasks
|
||||
) {
|
||||
if (argument instanceof JavaLiteralAnnotationArgument) {
|
||||
return resolveCompileTimeConstantValue(((JavaLiteralAnnotationArgument) argument).getValue(), null);
|
||||
return resolveCompileTimeConstantValue(((JavaLiteralAnnotationArgument) argument).getValue(), true, null);
|
||||
}
|
||||
// Enum
|
||||
else if (argument instanceof JavaReferenceAnnotationArgument) {
|
||||
@@ -124,7 +124,7 @@ public final class JavaAnnotationArgumentResolver {
|
||||
values.add(value == null ? NullValue.NULL : value);
|
||||
}
|
||||
|
||||
return new ArrayValue(values, valueParameter.getType());
|
||||
return new ArrayValue(values, valueParameter.getType(), true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -167,44 +167,44 @@ public final class JavaAnnotationArgumentResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CompileTimeConstant<?> resolveCompileTimeConstantValue(@Nullable Object value, @Nullable JetType expectedType) {
|
||||
public static CompileTimeConstant<?> resolveCompileTimeConstantValue(@Nullable Object value, boolean canBeUseInAnnotation, @Nullable JetType expectedType) {
|
||||
if (value instanceof String) {
|
||||
return new StringValue((String) value);
|
||||
return new StringValue((String) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Byte) {
|
||||
return new ByteValue((Byte) value);
|
||||
return new ByteValue((Byte) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Short) {
|
||||
return new ShortValue((Short) value);
|
||||
return new ShortValue((Short) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Character) {
|
||||
return new CharValue((Character) value);
|
||||
return new CharValue((Character) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Integer) {
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
Integer integer = (Integer) value;
|
||||
if (builtIns.getShortType().equals(expectedType)) {
|
||||
return new ShortValue(integer.shortValue());
|
||||
return new ShortValue(integer.shortValue(), canBeUseInAnnotation);
|
||||
}
|
||||
else if (builtIns.getByteType().equals(expectedType)) {
|
||||
return new ByteValue(integer.byteValue());
|
||||
return new ByteValue(integer.byteValue(), canBeUseInAnnotation);
|
||||
}
|
||||
else if (builtIns.getCharType().equals(expectedType)) {
|
||||
return new CharValue((char) integer.intValue());
|
||||
return new CharValue((char) integer.intValue(), canBeUseInAnnotation);
|
||||
}
|
||||
return new IntValue(integer);
|
||||
return new IntValue(integer, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Long) {
|
||||
return new LongValue((Long) value);
|
||||
return new LongValue((Long) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Float) {
|
||||
return new FloatValue((Float) value);
|
||||
return new FloatValue((Float) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Double) {
|
||||
return new DoubleValue((Double) value);
|
||||
return new DoubleValue((Double) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Boolean) {
|
||||
return BooleanValue.valueOf((Boolean) value);
|
||||
return new BooleanValue((Boolean) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value == null) {
|
||||
return NullValue.NULL;
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
|
||||
@Override
|
||||
public void visit(@Nullable Name name, @Nullable Object value) {
|
||||
if (name != null) {
|
||||
CompileTimeConstant<?> argument = JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue(value, null);
|
||||
CompileTimeConstant<?> argument = JavaAnnotationArgumentResolver.resolveCompileTimeConstantValue(value, true, null);
|
||||
setArgumentValueByName(name, argument != null ? argument : ErrorValue.create("Unsupported annotation argument: " + name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class AnnotationValue extends CompileTimeConstant<AnnotationDescriptor> {
|
||||
|
||||
public AnnotationValue(@NotNull AnnotationDescriptor value) {
|
||||
super(value);
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,8 +27,8 @@ public class ArrayValue extends CompileTimeConstant<List<CompileTimeConstant<?>>
|
||||
|
||||
private final JetType type;
|
||||
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type) {
|
||||
super(value);
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class BooleanValue extends CompileTimeConstant<Boolean> {
|
||||
|
||||
public static final BooleanValue FALSE = new BooleanValue(false);
|
||||
public static final BooleanValue TRUE = new BooleanValue(true);
|
||||
|
||||
private BooleanValue(boolean value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static BooleanValue valueOf(boolean value) {
|
||||
return value ? TRUE : FALSE;
|
||||
public BooleanValue(boolean value, boolean canBeUseInAnnotation) {
|
||||
super(value, canBeUseInAnnotation);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ByteValue extends CompileTimeConstant<Byte> {
|
||||
public static final Function<Long, ByteValue> CREATE = new Function<Long, ByteValue>() {
|
||||
@Override
|
||||
public ByteValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new ByteValue(input.byteValue());
|
||||
}
|
||||
};
|
||||
|
||||
public ByteValue(byte value) {
|
||||
super(value);
|
||||
public ByteValue(byte value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class CharValue extends CompileTimeConstant<Character> {
|
||||
|
||||
public CharValue(char value) {
|
||||
super(value);
|
||||
public CharValue(char value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-6
@@ -24,20 +24,17 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public abstract class CompileTimeConstant<T> {
|
||||
protected final T value;
|
||||
private boolean canBeUsedInAnnotations = true;
|
||||
private final boolean canBeUsedInAnnotations;
|
||||
|
||||
protected CompileTimeConstant(T value) {
|
||||
protected CompileTimeConstant(T value, boolean canBeUsedInAnnotations) {
|
||||
this.value = value;
|
||||
this.canBeUsedInAnnotations = canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
public boolean canBeUsedInAnnotations() {
|
||||
return canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
public void setCanBeUsedInAnnotations(boolean canBeUsedInAnnotations) {
|
||||
this.canBeUsedInAnnotations = canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue() {
|
||||
return value;
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class DoubleValue extends CompileTimeConstant<Double> {
|
||||
|
||||
public DoubleValue(double value) {
|
||||
super(value);
|
||||
public DoubleValue(double value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
|
||||
public EnumValue(@NotNull ClassDescriptor value) {
|
||||
super(value);
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public abstract class ErrorValue extends CompileTimeConstant<Void> {
|
||||
|
||||
public ErrorValue() {
|
||||
super(null);
|
||||
super(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class FloatValue extends CompileTimeConstant<Float> {
|
||||
|
||||
public FloatValue(float value) {
|
||||
super(value);
|
||||
public FloatValue(float value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class IntValue extends CompileTimeConstant<Integer> {
|
||||
public static final Function<Long, IntValue> CREATE = new Function<Long, IntValue>() {
|
||||
@Override
|
||||
public IntValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new IntValue(input.intValue());
|
||||
}
|
||||
};
|
||||
|
||||
public IntValue(int value) {
|
||||
super(value);
|
||||
public IntValue(int value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public class IntegerValueTypeConstant extends CompileTimeConstant<Number> {
|
||||
|
||||
private final IntegerValueTypeConstructor typeConstructor;
|
||||
|
||||
public IntegerValueTypeConstant(@NotNull Number value) {
|
||||
super(value);
|
||||
public IntegerValueTypeConstant(@NotNull Number value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
this.typeConstructor = new IntegerValueTypeConstructor(value.longValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class JavaClassValue extends CompileTimeConstant<JetType> {
|
||||
|
||||
public JavaClassValue(JetType value) {
|
||||
super(value);
|
||||
public JavaClassValue(@NotNull JetType value) {
|
||||
super(value, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,23 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class LongValue extends CompileTimeConstant<Long> {
|
||||
public static final Function<Long, LongValue> CREATE = new Function<Long, LongValue>() {
|
||||
@Override
|
||||
public LongValue apply(@Nullable Long input) {
|
||||
return new LongValue(input);
|
||||
}
|
||||
};
|
||||
|
||||
public LongValue(long value) {
|
||||
super(value);
|
||||
public LongValue(long value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,7 +26,7 @@ public class NullValue extends CompileTimeConstant<Void> {
|
||||
public static final NullValue NULL = new NullValue();
|
||||
|
||||
private NullValue() {
|
||||
super(null);
|
||||
super(null, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ShortValue extends CompileTimeConstant<Short> {
|
||||
public static final Function<Long, ShortValue> CREATE = new Function<Long, ShortValue>() {
|
||||
@Override
|
||||
public ShortValue apply(@Nullable Long input) {
|
||||
assert input != null;
|
||||
return new ShortValue(input.shortValue());
|
||||
}
|
||||
};
|
||||
|
||||
public ShortValue(short value) {
|
||||
super(value);
|
||||
public ShortValue(short value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
public class StringValue extends CompileTimeConstant<String> {
|
||||
|
||||
|
||||
public StringValue(String value) {
|
||||
super(value);
|
||||
public StringValue(String value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user