Fix internal visibility check for deserialized typealiases
#KT-15495 fixed
This commit is contained in:
+6
-2
@@ -24,7 +24,8 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment
|
||||
import org.jetbrains.kotlin.modules.Module
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedTypeAliasDescriptor
|
||||
import java.io.File
|
||||
|
||||
interface ModuleVisibilityManager {
|
||||
@@ -53,7 +54,7 @@ fun isContainedByCompiledPartOfOurModule(descriptor: DeclarationDescriptor, outD
|
||||
is KotlinJvmBinarySourceElement ->
|
||||
source.binaryClass
|
||||
is KotlinJvmBinaryPackageSourceElement ->
|
||||
if (descriptor is DeserializedCallableMemberDescriptor) {
|
||||
if (descriptor is DeserializedMemberDescriptor) {
|
||||
source.getContainingBinaryClass(descriptor) ?: source.getRepresentativeBinaryClass()
|
||||
}
|
||||
else {
|
||||
@@ -78,6 +79,9 @@ fun getSourceElement(descriptor: DeclarationDescriptor): SourceElement =
|
||||
if (descriptor is CallableMemberDescriptor && descriptor.source === SourceElement.NO_SOURCE) {
|
||||
descriptor.containingDeclaration.toSourceElement
|
||||
}
|
||||
else if (descriptor is DeserializedTypeAliasDescriptor) {
|
||||
descriptor.containingDeclaration.toSourceElement
|
||||
}
|
||||
else {
|
||||
descriptor.toSourceElement
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
import org.jetbrains.kotlin.load.java.descriptors.getImplClassNameForDeserialized
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor
|
||||
|
||||
class KotlinJvmBinaryPackageSourceElement(
|
||||
private val packageFragment: LazyJavaPackageFragment
|
||||
@@ -33,7 +33,7 @@ class KotlinJvmBinaryPackageSourceElement(
|
||||
return packageFragment.binaryClasses.values.first()
|
||||
}
|
||||
|
||||
fun getContainingBinaryClass(descriptor: DeserializedCallableMemberDescriptor): KotlinJvmBinaryClass? {
|
||||
fun getContainingBinaryClass(descriptor: DeserializedMemberDescriptor): KotlinJvmBinaryClass? {
|
||||
val name = descriptor.getImplClassNameForDeserialized() ?: return null
|
||||
return packageFragment.binaryClasses[name.asString()]
|
||||
}
|
||||
|
||||
+6
@@ -552,6 +552,12 @@ public class ExperimentalIncrementalJpsTestGenerated extends AbstractExperimenta
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("internalTypealias")
|
||||
public void testInternalTypealias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localClassChanged")
|
||||
public void testLocalClassChanged() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
||||
|
||||
+6
@@ -552,6 +552,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("internalTypealias")
|
||||
public void testInternalTypealias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/internalTypealias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localClassChanged")
|
||||
public void testLocalClassChanged() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/localClassChanged/");
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
internal typealias TypeAlias = Int
|
||||
@@ -0,0 +1,11 @@
|
||||
================ Step #1 =================
|
||||
|
||||
Cleaning output files:
|
||||
out/production/module/META-INF/module.kotlin_module
|
||||
out/production/module/foo/UseTypeAliasKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/useTypeAlias.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
internal fun useTypeAlias(x: TypeAlias) {
|
||||
x.toString()
|
||||
}
|
||||
Reference in New Issue
Block a user