Fix exception at accidentally wrong annotation argument type

#KT-13740 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-02-06 19:14:18 +03:00
parent 655cf82534
commit 9f0403f72c
4 changed files with 30 additions and 1 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1518,6 +1518,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
KotlinType expectedType = bindingContext.getType(expression);
if (expectedType == null) {
return null;
}
return compileTimeValue.toConstantValue(expectedType);
}
@@ -0,0 +1,2 @@
annotation class A(val a: IntArray = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(1)<!>)
annotation class B(val a: IntArray = intArrayOf(1))
@@ -0,0 +1,17 @@
package
public final annotation class A : kotlin.Annotation {
public constructor A(/*0*/ a: kotlin.IntArray = ...)
public final val a: kotlin.IntArray
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final annotation class B : kotlin.Annotation {
public constructor B(/*0*/ a: kotlin.IntArray = ...)
public final val a: kotlin.IntArray
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -12519,6 +12519,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("arrayInAnnotationArgumentType.kt")
public void testArrayInAnnotationArgumentType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/const/arrayInAnnotationArgumentType.kt");
doTest(fileName);
}
@TestMetadata("constInteraction.kt")
public void testConstInteraction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/modifiers/const/constInteraction.kt");