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:
Alexander Udalov
2016-10-13 12:15:39 +03:00
parent c0147860bd
commit 17e54b6d2d
3 changed files with 11 additions and 1 deletions
@@ -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()
}
}
@@ -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>
}
@@ -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) }