Extension point for synthetic function names contributions

This commit is contained in:
Leonid Startsev
2017-11-15 12:50:46 +03:00
parent d6e5551237
commit 44d232a83c
2 changed files with 10 additions and 0 deletions
@@ -42,6 +42,9 @@ interface SyntheticResolveExtension {
override fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> =
instances.flatMap { it.getSyntheticNestedClassNames(thisDescriptor) }
override fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> =
instances.flatMap { it.getSyntheticFunctionNames(thisDescriptor) }
override fun generateSyntheticClasses(thisDescriptor: ClassDescriptor, name: Name,
ctx: LazyClassContext, declarationProvider: ClassMemberDeclarationProvider,
result: MutableSet<ClassDescriptor>) =
@@ -69,6 +72,8 @@ interface SyntheticResolveExtension {
fun getSyntheticCompanionObjectNameIfNeeded(thisDescriptor: ClassDescriptor): Name? = null
fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
fun addSyntheticSupertypes(thisDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) {}
@@ -80,6 +80,7 @@ open class LazyClassMemberScope(
}
addDataClassMethods(result, location)
addSyntheticFunctions(result, location)
addSyntheticCompanionObject(result, location)
addSyntheticNestedClasses(result, location)
@@ -220,6 +221,10 @@ open class LazyClassMemberScope(
result.add(descriptor)
}
private fun addSyntheticFunctions(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
result.addAll(c.syntheticResolveExtension.getSyntheticFunctionNames(thisDescriptor).flatMap { getContributedFunctions(it, location) }.toList())
}
private fun addSyntheticNestedClasses(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
result.addAll(c.syntheticResolveExtension.getSyntheticNestedClassNames(thisDescriptor).mapNotNull { getContributedClassifier(it, location) }.toList())
}