K2: suppress exception when reading unsupported metadata
Before the change, the compiler threw exception in the unmuted tests, because it tried to load metadata even though it had an unsupported version. Use the same approach as in K1 (see DeserializedDescriptorResolver). Now the tests are unmuted, but note that test data differs from K1. K1 does not report errors related to the class `a.A` because it loads this class as a _Java class_, so calling its constructor and methods somehow works. This behavior is questionable since the compiler surely knows that it is a Kotlin class, but with an unsupported metadata version. Trying to interpret it as a Java class may lead to subtle problems. So it's safer for now to avoid loading Kotlin classes with unsupported metadata versions in K2. #KT-60795 Fixed
This commit is contained in:
committed by
Space Team
parent
8f720ad24b
commit
8738ffb84f
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
$TMP_DIR$/library-after.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 42.0.0, expected version is $ABI_VERSION$.
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:5:16: error: unresolved reference 'A'.
|
||||
fun baz(param: A, nested: A.Nested) {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:5:27: error: unresolved reference 'A.Nested'.
|
||||
fun baz(param: A, nested: A.Nested) {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:6:23: error: unresolved reference 'A'.
|
||||
val constructor = A()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:7:18: error: unresolved reference 'A'.
|
||||
val nested = A.Nested()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:8:22: error: unresolved reference 'getQuux'.
|
||||
val quux = param.getQuux()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:9:28: error: unresolved reference 'method'.
|
||||
val methodCall = param.method()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:10:30: error: unresolved reference 'A'.
|
||||
val supertype = object : A() {}
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:12:13: error: unresolved reference 'foo'.
|
||||
val x = foo()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:13:13: error: unresolved reference 'bar'.
|
||||
val y = bar
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:14:5: error: unresolved reference 'bar'.
|
||||
bar = 239
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/wrongMetadataVersionBadMetadata/source.kt:15:12: error: unresolved reference 'TA'.
|
||||
val z: TA = ""
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Reference in New Issue
Block a user