Add ClassDescriptorFactory#getAllContributedClassesIfPossible
Currently a no-op, will be used soon to make Cloneable a synthesized class, visible in scope's getContributedDescriptors()
This commit is contained in:
+6
@@ -83,4 +83,10 @@ class BuiltInFictitiousFunctionClassFactory(
|
||||
|
||||
return FunctionClassDescriptor(storageManager, containingPackageFragment, kind, arity)
|
||||
}
|
||||
|
||||
override fun getAllContributedClassesIfPossible(packageFqName: FqName): Collection<ClassDescriptor> {
|
||||
// We don't want to return 256 classes here since it would cause them to appear in every import list of every file
|
||||
// and likely slow down compilation very much
|
||||
return emptySet()
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -25,4 +25,7 @@ interface ClassDescriptorFactory {
|
||||
fun shouldCreateClass(packageFqName: FqName, name: Name): Boolean
|
||||
|
||||
fun createClass(classId: ClassId): ClassDescriptor?
|
||||
|
||||
// Note: do not rely on this function to return _all_ classes. Some factories can not enumerate all classes that they're able to create
|
||||
fun getAllContributedClassesIfPossible(packageFqName: FqName): Collection<ClassDescriptor>
|
||||
}
|
||||
|
||||
+2
-1
@@ -42,7 +42,8 @@ open class DeserializedPackageMemberScope(
|
||||
private val packageFqName = packageDescriptor.fqName
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
= computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) +
|
||||
c.components.fictitiousClassDescriptorFactories.flatMap { it.getAllContributedClassesIfPossible(packageFqName) }
|
||||
|
||||
override fun hasClass(name: Name) =
|
||||
super.hasClass(name) || c.components.fictitiousClassDescriptorFactories.any { it.shouldCreateClass(packageFqName, name) }
|
||||
|
||||
Reference in New Issue
Block a user