Extract isCompatibleAbiVersion from kinds enum and store read kinds even for incompatible version

Original commit: c242665cd3
This commit is contained in:
Nikolay Krasko
2014-11-06 19:03:48 +03:00
parent 5afcf74024
commit 5ff297aed5
2 changed files with 11 additions and 7 deletions
@@ -42,6 +42,8 @@ import org.jetbrains.jps.builders.storage.StorageProvider
import java.io.IOException import java.io.IOException
import java.util.Scanner import java.util.Scanner
import org.jetbrains.jet.lang.resolve.java.JvmAbi import org.jetbrains.jet.lang.resolve.java.JvmAbi
import org.jetbrains.jet.lang.resolve.kotlin.header.isCompatiblePackageFacadeKind
import org.jetbrains.jet.lang.resolve.kotlin.header.isCompatibleClassKind
val INLINE_ANNOTATION_DESC = "Lkotlin/inline;" val INLINE_ANNOTATION_DESC = "Lkotlin/inline;"
@@ -106,11 +108,11 @@ public class IncrementalCacheImpl(val baseDir: File): StorageOwner, IncrementalC
val annotationDataEncoded = header.annotationData val annotationDataEncoded = header.annotationData
if (annotationDataEncoded != null) { if (annotationDataEncoded != null) {
val data = BitEncoding.decodeBytes(annotationDataEncoded) val data = BitEncoding.decodeBytes(annotationDataEncoded)
when (header.kind) { when {
KotlinClassHeader.Kind.PACKAGE_FACADE -> { header.isCompatiblePackageFacadeKind() -> {
return if (protoMap.put(className, data)) COMPILE_OTHERS else DO_NOTHING return if (protoMap.put(className, data)) COMPILE_OTHERS else DO_NOTHING
} }
KotlinClassHeader.Kind.CLASS -> { header.isCompatibleClassKind() -> {
val inlinesChanged = inlineFunctionsMap.process(className, fileBytes) val inlinesChanged = inlineFunctionsMap.process(className, fileBytes)
val protoChanged = protoMap.put(className, data) val protoChanged = protoMap.put(className, data)
val constantsChanged = constantsMap.process(className, fileBytes) val constantsChanged = constantsMap.process(className, fileBytes)
@@ -118,7 +120,7 @@ public class IncrementalCacheImpl(val baseDir: File): StorageOwner, IncrementalC
return if (inlinesChanged) RECOMPILE_ALL else if (protoChanged || constantsChanged) COMPILE_OTHERS else DO_NOTHING return if (inlinesChanged) RECOMPILE_ALL else if (protoChanged || constantsChanged) COMPILE_OTHERS else DO_NOTHING
} }
else -> { else -> {
throw IllegalStateException("Unexpected kind with annotationData: ${header.kind}") throw IllegalStateException("Unexpected kind with annotationData: ${header.kind}, isCompatible: ${header.isCompatibleAbiVersion}")
} }
} }
} }
@@ -36,6 +36,8 @@ import java.io.ByteArrayInputStream
import org.jetbrains.jet.descriptors.serialization.DebugProtoBuf import org.jetbrains.jet.descriptors.serialization.DebugProtoBuf
import java.util.Arrays import java.util.Arrays
import org.jetbrains.jet.jps.incremental.LocalFileKotlinClass import org.jetbrains.jet.jps.incremental.LocalFileKotlinClass
import org.jetbrains.jet.lang.resolve.kotlin.header.isCompatibleClassKind
import org.jetbrains.jet.lang.resolve.kotlin.header.isCompatiblePackageFacadeKind
// Set this to true if you want to dump all bytecode (test will fail in this case) // Set this to true if you want to dump all bytecode (test will fail in this case)
val DUMP_ALL = System.getProperty("comparison.dump.all") == "true" val DUMP_ALL = System.getProperty("comparison.dump.all") == "true"
@@ -140,11 +142,11 @@ fun classFileToString(classFile: File): String {
out.write("\n------ simpleNames proto -----\n${DebugProtoBuf.StringTable.parseDelimitedFrom(input)}") out.write("\n------ simpleNames proto -----\n${DebugProtoBuf.StringTable.parseDelimitedFrom(input)}")
out.write("\n------ qualifiedNames proto -----\n${DebugProtoBuf.QualifiedNameTable.parseDelimitedFrom(input)}") out.write("\n------ qualifiedNames proto -----\n${DebugProtoBuf.QualifiedNameTable.parseDelimitedFrom(input)}")
when (classHeader!!.kind) { when {
KotlinClassHeader.Kind.PACKAGE_FACADE -> classHeader!!.isCompatiblePackageFacadeKind() ->
out.write("\n------ package proto -----\n${DebugProtoBuf.Package.parseFrom(input, getExtensionRegistry())}") out.write("\n------ package proto -----\n${DebugProtoBuf.Package.parseFrom(input, getExtensionRegistry())}")
KotlinClassHeader.Kind.CLASS -> classHeader.isCompatibleClassKind() ->
out.write("\n------ class proto -----\n${DebugProtoBuf.Class.parseFrom(input, getExtensionRegistry())}") out.write("\n------ class proto -----\n${DebugProtoBuf.Class.parseFrom(input, getExtensionRegistry())}")
else -> throw IllegalStateException() else -> throw IllegalStateException()