Skip to content

Commit 475519c

Browse files
committed
Do not decompile old incompatible package parts
Fix the test by reverting 282727b
1 parent e3ec6be commit 475519c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/DecompiledUtils.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.jetbrains.kotlin.idea.decompiler
1818

1919
import com.intellij.ide.highlighter.JavaClassFileType
20-
import com.intellij.openapi.util.Key
2120
import com.intellij.openapi.vfs.VirtualFile
2221
import com.intellij.psi.ClassFileViewProvider
2322
import org.jetbrains.kotlin.idea.caches.JarUserDataManager
@@ -28,7 +27,6 @@ import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
2827
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
2928
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
3029
import org.jetbrains.kotlin.name.ClassId
31-
import org.jetbrains.kotlin.name.FqName
3230
import org.jetbrains.kotlin.name.Name
3331

3432
/**
@@ -73,8 +71,15 @@ public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
7371
if (ClassFileViewProvider.isInnerClass(file)) {
7472
return true
7573
}
76-
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader() ?: return false
77-
return (header.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS && header.syntheticClassKind != KotlinSyntheticClass.Kind.PACKAGE_PART) ||
74+
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.classHeader ?: return false
75+
76+
if (header.syntheticClassKind == KotlinSyntheticClass.Kind.PACKAGE_PART) {
77+
// Old package parts should not be decompiled and shown anywhere
78+
val version = header.version
79+
return version.major < 0 || (version.major == 0 && version.minor < 24)
80+
}
81+
82+
return header.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS ||
7883
(header.kind == KotlinClassHeader.Kind.CLASS && header.classKind != null && header.classKind != KotlinClass.Kind.CLASS) ||
7984
(header.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART)
8085
}

idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas
3636
return JetJdkAndLibraryProjectDescriptor(File(JetTestUtils.getTestDataPathBase() + "/cli/jvm/wrongAbiVersionLib/bin"))
3737
}
3838

39-
fun testPackagePartIsInvisibleWrongAbiVersion() = doTestNoFilesAreBuiltForSyntheticClass(PACKAGE_PART)
39+
fun testPackagePartIsInvisibleWrongAbiVersion() = doTestNoPsiFilesAreBuiltForSyntheticClass(PACKAGE_PART)
4040

4141
fun testTraitImplClassIsVisibleAsJavaClassWrongAbiVersion() = doTestTraitImplClassIsVisibleAsJavaClass()
4242

0 commit comments

Comments
 (0)