Fix exception from backend in light classes mode for null passed as annotation argument

This commit is contained in:
Pavel V. Talanov
2015-11-02 19:46:53 +03:00
parent 7e091d0df4
commit f5c4f82971
3 changed files with 25 additions and 1 deletions
@@ -389,7 +389,15 @@ public abstract class AnnotationCodegen {
}
private Void visitUnsupportedValue(ConstantValue<?> value) {
throw new IllegalStateException("Don't know how to compile annotation value " + value);
ClassBuilderMode mode = typeMapper.getClassBuilderMode();
switch (mode) {
case FULL:
throw new IllegalStateException("Don't know how to compile annotation value " + value);
case LIGHT_CLASSES:
return null;
default:
throw new IllegalStateException("Unknown builder mode: " + mode);
}
}
};
+10
View File
@@ -0,0 +1,10 @@
// test for KT-5337
package test
annotation class A(val value: String)
@A(<error>null</error>)
fun foo() {}
@A(<error>null</error>)
class B
@@ -187,6 +187,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
doTest(fileName);
}
@TestMetadata("NullAsAnnotationArgument.kt")
public void testNullAsAnnotationArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/NullAsAnnotationArgument.kt");
doTest(fileName);
}
@TestMetadata("Nullability.kt")
public void testNullability() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/Nullability.kt");