Remove KotlinClassFileHeader.HeaderType.NONE
Use null instead
This commit is contained in:
+1
-1
@@ -127,7 +127,7 @@ public final class DeserializedDescriptorResolver {
|
||||
private String[] readData(@NotNull VirtualFile virtualFile) {
|
||||
KotlinClassFileHeader header = KotlinClassFileHeader.readKotlinHeaderFromClassFile(virtualFile);
|
||||
int version = header.getVersion();
|
||||
if (!isAbiVersionCompatible(version) && header.getType() != KotlinClassFileHeader.HeaderType.NONE) {
|
||||
if (!isAbiVersionCompatible(version) && header.getType() != null) {
|
||||
errorReporter.reportIncompatibleAbiVersion(header.getFqName(), virtualFile, version);
|
||||
return null;
|
||||
}
|
||||
|
||||
+12
-12
@@ -42,8 +42,7 @@ public final class KotlinClassFileHeader {
|
||||
CLASS(JvmAnnotationNames.KOTLIN_CLASS),
|
||||
PACKAGE(JvmAnnotationNames.KOTLIN_PACKAGE),
|
||||
OLD_CLASS(JvmAnnotationNames.OLD_JET_CLASS_ANNOTATION),
|
||||
OLD_PACKAGE(JvmAnnotationNames.OLD_JET_PACKAGE_CLASS_ANNOTATION),
|
||||
NONE(null);
|
||||
OLD_PACKAGE(JvmAnnotationNames.OLD_JET_PACKAGE_CLASS_ANNOTATION);
|
||||
|
||||
@Nullable
|
||||
private final JvmClassName correspondingAnnotation;
|
||||
@@ -56,7 +55,7 @@ public final class KotlinClassFileHeader {
|
||||
return this == CLASS || this == PACKAGE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
private static HeaderType byDescriptor(@NotNull String desc) {
|
||||
for (HeaderType headerType : HeaderType.values()) {
|
||||
JvmClassName annotation = headerType.correspondingAnnotation;
|
||||
@@ -67,7 +66,7 @@ public final class KotlinClassFileHeader {
|
||||
return headerType;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +74,8 @@ public final class KotlinClassFileHeader {
|
||||
|
||||
@Nullable
|
||||
private String[] annotationData = null;
|
||||
@NotNull
|
||||
private HeaderType type = HeaderType.NONE;
|
||||
@Nullable
|
||||
private HeaderType type = null;
|
||||
@Nullable
|
||||
private JvmClassName jvmClassName = null;
|
||||
|
||||
@@ -84,7 +83,7 @@ public final class KotlinClassFileHeader {
|
||||
return version;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public HeaderType getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -93,7 +92,7 @@ public final class KotlinClassFileHeader {
|
||||
* @return true if this is a header for compiled Kotlin file with correct abi version which can be processed by compiler or the IDE
|
||||
*/
|
||||
public boolean isCompatibleKotlinCompiledFile() {
|
||||
return type.isValidAnnotation() && isAbiVersionCompatible(version);
|
||||
return type != null && type.isValidAnnotation() && isAbiVersionCompatible(version);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +106,7 @@ public final class KotlinClassFileHeader {
|
||||
|
||||
@Nullable
|
||||
public String[] getAnnotationData() {
|
||||
if (annotationData == null && type != HeaderType.NONE) {
|
||||
if (annotationData == null && type != null) {
|
||||
LOG.error("Data for annotations " + type.correspondingAnnotation + " was not read.");
|
||||
}
|
||||
return annotationData;
|
||||
@@ -127,14 +126,15 @@ public final class KotlinClassFileHeader {
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
|
||||
HeaderType headerTypeByAnnotation = HeaderType.byDescriptor(desc);
|
||||
if (headerTypeByAnnotation == HeaderType.NONE) {
|
||||
if (headerTypeByAnnotation == null) {
|
||||
return null;
|
||||
}
|
||||
if (headerTypeByAnnotation.isValidAnnotation() && type.isValidAnnotation()) {
|
||||
boolean alreadyFoundValid = type != null && type.isValidAnnotation();
|
||||
if (headerTypeByAnnotation.isValidAnnotation() && alreadyFoundValid) {
|
||||
throw new IllegalStateException("Both " + type.correspondingAnnotation + " and "
|
||||
+ headerTypeByAnnotation.correspondingAnnotation + " present!");
|
||||
}
|
||||
if (!type.isValidAnnotation()) {
|
||||
if (!alreadyFoundValid) {
|
||||
type = headerTypeByAnnotation;
|
||||
}
|
||||
if (!headerTypeByAnnotation.isValidAnnotation()) {
|
||||
|
||||
Reference in New Issue
Block a user