Introduce KotlinSyntheticClass annotation

Will be used instead of KotlinPackagePart, KotlinTraitImpl and other
hypothetical annotations we were planning to write on our synthesized classes
(lambdas, local functions, etc.)
This commit is contained in:
Alexander Udalov
2014-02-28 23:38:19 +04:00
parent 8762a02844
commit cfe3619db7
10 changed files with 52 additions and 62 deletions
@@ -23,8 +23,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
public final class JvmAnnotationNames {
public static final FqName KOTLIN_CLASS = new FqName("kotlin.jvm.internal.KotlinClass");
public static final FqName KOTLIN_PACKAGE = new FqName("kotlin.jvm.internal.KotlinPackage");
public static final FqName KOTLIN_PACKAGE_PART = new FqName("kotlin.jvm.internal.KotlinPackagePart");
public static final FqName KOTLIN_TRAIT_IMPL = new FqName("kotlin.jvm.internal.KotlinTraitImpl");
public static final FqName KOTLIN_SYNTHETIC_CLASS = new FqName("kotlin.jvm.internal.KotlinSyntheticClass");
public static final FqName KOTLIN_SIGNATURE = new FqName("kotlin.jvm.KotlinSignature");
public static final FqName OLD_KOTLIN_SIGNATURE = new FqName("jet.runtime.typeinfo.KotlinSignature");
@@ -44,7 +44,7 @@ public final class DescriptorResolverUtils {
public static boolean isCompiledKotlinPackageClass(@NotNull JavaClass javaClass) {
if (javaClass.getOriginKind() == JavaClass.OriginKind.COMPILED) {
return javaClass.findAnnotation(JvmAnnotationNames.KOTLIN_PACKAGE) != null
|| javaClass.findAnnotation(JvmAnnotationNames.KOTLIN_PACKAGE_PART) != null;
|| javaClass.findAnnotation(JvmAnnotationNames.KOTLIN_SYNTHETIC_CLASS) != null;
}
return false;
}
@@ -24,8 +24,7 @@ public class KotlinClassHeader {
public enum Kind {
CLASS,
PACKAGE_FACADE,
PACKAGE_PART,
TRAIT_IMPL,
SYNTHETIC_CLASS,
INCOMPATIBLE_ABI_VERSION
}
@@ -39,8 +39,7 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
static {
HEADER_KINDS.put(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_CLASS), CLASS);
HEADER_KINDS.put(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_PACKAGE), PACKAGE_FACADE);
HEADER_KINDS.put(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_PACKAGE_PART), PACKAGE_PART);
HEADER_KINDS.put(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_TRAIT_IMPL), TRAIT_IMPL);
HEADER_KINDS.put(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_SYNTHETIC_CLASS), SYNTHETIC_CLASS);
@SuppressWarnings("deprecation")
List<FqName> incompatible = Arrays.asList(OLD_JET_CLASS_ANNOTATION, OLD_JET_PACKAGE_CLASS_ANNOTATION, OLD_KOTLIN_CLASS,
@@ -100,8 +99,8 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
if (newKind == CLASS || newKind == PACKAGE_FACADE) {
return kotlinClassOrPackageVisitor(annotationClassName);
}
else if (newKind == PACKAGE_PART || newKind == TRAIT_IMPL) {
return annotationWithAbiVersionVisitor(annotationClassName);
else if (newKind == SYNTHETIC_CLASS) {
return syntheticClassAnnotationVisitor(annotationClassName);
}
return null;
@@ -175,7 +174,7 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
}
@NotNull
private AnnotationArgumentVisitor annotationWithAbiVersionVisitor(@NotNull final JvmClassName annotationClassName) {
private AnnotationArgumentVisitor syntheticClassAnnotationVisitor(@NotNull final JvmClassName annotationClassName) {
return new AnnotationArgumentVisitor() {
@Override
public void visit(@Nullable Name name, @Nullable Object value) {
@@ -184,7 +183,7 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
@Override
public void visitEnum(@NotNull Name name, @NotNull JvmClassName enumClassName, @NotNull Name enumEntryName) {
unexpectedArgument(name, annotationClassName);
// TODO: save kind to somewhere
}
@Nullable