Kapt+JVM_IR: support annotations with error types

This is a hack to implement KT-32596 in the JVM IR version of kapt.
Basically we allow psi2ir to generate annotations whose classifier is
error class, which happens when it's unresolved. Because there's no
physical IR for an error class, we create stub IR for it via
SyntheticDeclarationsGenerator in case we'll need it.

With this hack, annotations with unresolved classifiers magically
survive all the way until the codegen (with a minor change in
IrBasedDescriptors) where they are generated as
`@error.NonExistentClass`, which then gets corrected by the kapt's
"correct error types" mode as in all other cases of error types.
This commit is contained in:
Alexander Udalov
2023-01-04 23:44:09 +01:00
parent 4a91957ff0
commit 6d0628900e
8 changed files with 72 additions and 18 deletions
+3 -4
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES
@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST")
@@ -15,6 +14,6 @@ class ErrorSomeMissingAnnotations
annotation class Anno(val klass: KClass<*>)
// EXPECTED_ERROR: (kotlin:10:1) cannot find symbol
// EXPECTED_ERROR: (kotlin:13:1) cannot find symbol
// EXPECTED_ERROR: (kotlin:7:1) cannot find symbol
// EXPECTED_ERROR: (kotlin:9:1) cannot find symbol
// EXPECTED_ERROR: (kotlin:12:1) cannot find symbol
// EXPECTED_ERROR: (kotlin:6:1) cannot find symbol