Files
kotlin/compiler/testData/diagnostics/tests/annotations/inheritFromAnnotationClass.kt
Alexander Udalov 56a51c1d22 Do not treat annotation classes as interfaces in bridges codegen
From Kotlin's point of view, everything in annotation classes is
non-abstract. A class inheriting from an annotation has a non-abstract
fake override for each property of the annotation class constructor. But
because members of annotation classes themselves were considered as
abstract in the bridge-generating code (see
DescriptorBasedFunctionHandle.isAbstract), there was a situation where a
concrete fake override has only one declaration among overridden
descriptors and it was abstract. This situation is invalid (a concrete
fake override must have exactly one concrete super-declaration),
therefore an exception was thrown.

The fix is to avoid considering annotation class members abstract for
the purposes of bridge generation. It's reasonably safe because no
bridges should be ever generated for annotation subclasses anyway,
because annotations can only have members with simple return types
(final and non-generic).

Note that in KT-19928, the problem is reproducible because of an
incorrect "inexact analysis" in light classes where "Target" is resolved
to an annotation class kotlin.annotation.Target. This behavior of the
analysis in light classes seems to do no harm otherwise, so it's not a
goal of this commit to change anything in that regard

 #KT-19928 Fixed
2017-11-02 14:02:09 +01:00

5 lines
125 B
Kotlin
Vendored

// !DIAGNOSTICS: -FINAL_SUPERTYPE
// This error needs to be suppressed to cause light class generation
class Foo : Target()