Skip to content

Commit

Permalink
Do not decompile old incompatible package parts
Browse files Browse the repository at this point in the history
Fix the test by reverting 282727b
  • Loading branch information
udalov committed Sep 16, 2015
1 parent e3ec6be commit 475519c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -17,7 +17,6 @@
package org.jetbrains.kotlin.idea.decompiler

import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.openapi.util.Key
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.ClassFileViewProvider
import org.jetbrains.kotlin.idea.caches.JarUserDataManager
Expand All @@ -28,7 +27,6 @@ import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name

/**
Expand Down Expand Up @@ -73,8 +71,15 @@ public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
if (ClassFileViewProvider.isInnerClass(file)) {
return true
}
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader() ?: return false
return (header.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS && header.syntheticClassKind != KotlinSyntheticClass.Kind.PACKAGE_PART) ||
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.classHeader ?: return false

if (header.syntheticClassKind == KotlinSyntheticClass.Kind.PACKAGE_PART) {
// Old package parts should not be decompiled and shown anywhere
val version = header.version
return version.major < 0 || (version.major == 0 && version.minor < 24)
}

return header.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS ||
(header.kind == KotlinClassHeader.Kind.CLASS && header.classKind != null && header.classKind != KotlinClass.Kind.CLASS) ||
(header.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART)
}
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas
return JetJdkAndLibraryProjectDescriptor(File(JetTestUtils.getTestDataPathBase() + "/cli/jvm/wrongAbiVersionLib/bin"))
}

fun testPackagePartIsInvisibleWrongAbiVersion() = doTestNoFilesAreBuiltForSyntheticClass(PACKAGE_PART)
fun testPackagePartIsInvisibleWrongAbiVersion() = doTestNoPsiFilesAreBuiltForSyntheticClass(PACKAGE_PART)

fun testTraitImplClassIsVisibleAsJavaClassWrongAbiVersion() = doTestTraitImplClassIsVisibleAsJavaClass()

Expand Down

0 comments on commit 475519c

Please sign in to comment.