Check expected type of annotation parameter correctly in AnnotationDeserializer

The main idea of this refactoring is to separate two usages of
`AnnotationDeserializer.resolveValue`: the one where we load annotation
argument values, and the one where we load constant values of properties
for JS/Native/Common
(`AnnotationAndConstantLoaderImpl.loadPropertyConstant`).

In the latter case, `expectedType` is the type of the property and it
can be a supertype of the actual value (e.g. see `arrayConst` in
compiler/testData/serialization/builtinsSerializer/compileTimeConstants.kt).
But in the former case, we need to check that the value conforms to the
expected type and disregard it if it's not the case, which is possible
if the annotation was recompiled separately.

 #KT-28927
This commit is contained in:
Alexander Udalov
2019-05-29 18:38:56 +02:00
parent c666b60ca3
commit 43cb17cdd5
6 changed files with 84 additions and 95 deletions
@@ -20008,6 +20008,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/reflection/annotations/onTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("classLiteralWithExpectedType.kt")
public void testClassLiteralWithExpectedType() throws Exception {
runTest("compiler/testData/codegen/box/reflection/annotations/onTypes/classLiteralWithExpectedType.kt");
}
@TestMetadata("differentArgumentTypes.kt")
public void testDifferentArgumentTypes() throws Exception {
runTest("compiler/testData/codegen/box/reflection/annotations/onTypes/differentArgumentTypes.kt");