Filter out non-builtin package fragments from module when needed
In subsequent commits, a JVM module will be able to have up to two package fragments for a given package FQ name. For example, for package "kotlin" in kotlin-runtime.jar there will be a LazyJavaPackageFragment with binary (Kotlin+Java) dependencies, and a BuiltInsPackageFragment for built-ins metadata (which is loaded from kotlin/kotlin.kotlin_builtins)
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ class JvmBuiltInClassDescriptorFactory(
|
||||
) : ClassDescriptorFactory {
|
||||
private val cloneable by storageManager.createLazyValue {
|
||||
ClassDescriptorImpl(
|
||||
moduleDescriptor.getPackage(KOTLIN_FQ_NAME).fragments.single(),
|
||||
moduleDescriptor.getPackage(KOTLIN_FQ_NAME).fragments.filterIsInstance<BuiltInsPackageFragment>().single(),
|
||||
CLONEABLE_NAME, Modality.ABSTRACT, ClassKind.INTERFACE, listOf(moduleDescriptor.builtIns.anyType),
|
||||
SourceElement.NO_SOURCE
|
||||
).apply {
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.builtins.functions
|
||||
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor.Kind
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -79,7 +80,7 @@ class BuiltInFictitiousFunctionClassFactory(
|
||||
val packageFqName = classId.packageFqName
|
||||
val (kind, arity) = parseClassName(className, packageFqName) ?: return null
|
||||
|
||||
val containingPackageFragment = module.getPackage(packageFqName).fragments.single()
|
||||
val containingPackageFragment = module.getPackage(packageFqName).fragments.filterIsInstance<BuiltInsPackageFragment>().single()
|
||||
|
||||
return FunctionClassDescriptor(storageManager, containingPackageFragment, kind, arity)
|
||||
}
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.builtins.functions
|
||||
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -129,8 +130,8 @@ class FunctionClassDescriptor(
|
||||
|
||||
// For KFunction{n}, add corresponding numbered Function{n} class, e.g. Function2 for KFunction2
|
||||
if (functionKind == Kind.KFunction) {
|
||||
val module = containingDeclaration.containingDeclaration
|
||||
val kotlinPackageFragment = module.getPackage(BUILT_INS_PACKAGE_FQ_NAME).fragments.single()
|
||||
val packageView = containingDeclaration.containingDeclaration.getPackage(BUILT_INS_PACKAGE_FQ_NAME)
|
||||
val kotlinPackageFragment = packageView.fragments.filterIsInstance<BuiltInsPackageFragment>().single()
|
||||
|
||||
add(kotlinPackageFragment, Kind.Function.numberedClassName(arity))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user