[Plugin API] Add extension point to contribute synthetic properties
- needs to fix KT_41006
This commit is contained in:
+6
@@ -54,6 +54,9 @@ interface SyntheticResolveExtension {
|
||||
override fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> =
|
||||
instances.flatMap { withLinkageErrorLogger(it) { getSyntheticFunctionNames(thisDescriptor) } }
|
||||
|
||||
override fun getSyntheticPropertiesNames(thisDescriptor: ClassDescriptor): List<Name> =
|
||||
instances.flatMap { withLinkageErrorLogger(it) { getSyntheticPropertiesNames(thisDescriptor) } }
|
||||
|
||||
override fun generateSyntheticClasses(
|
||||
thisDescriptor: ClassDescriptor, name: Name,
|
||||
ctx: LazyClassContext, declarationProvider: ClassMemberDeclarationProvider,
|
||||
@@ -142,6 +145,9 @@ interface SyntheticResolveExtension {
|
||||
|
||||
fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
|
||||
|
||||
@JvmDefault
|
||||
fun getSyntheticPropertiesNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
|
||||
|
||||
fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> = emptyList()
|
||||
|
||||
/**
|
||||
|
||||
+11
@@ -90,6 +90,7 @@ open class LazyClassMemberScope(
|
||||
|
||||
addDataClassMethods(result, location)
|
||||
addSyntheticFunctions(result, location)
|
||||
addSyntheticVariables(result, location)
|
||||
addSyntheticCompanionObject(result, location)
|
||||
addSyntheticNestedClasses(result, location)
|
||||
|
||||
@@ -106,6 +107,7 @@ open class LazyClassMemberScope(
|
||||
by storageManager.createLazyValue {
|
||||
mutableSetOf<Name>().apply {
|
||||
addAll(declarationProvider.getDeclarationNames())
|
||||
addAll(c.syntheticResolveExtension.getSyntheticPropertiesNames(thisDescriptor))
|
||||
supertypes.flatMapTo(this) {
|
||||
it.memberScope.getVariableNames()
|
||||
}
|
||||
@@ -344,6 +346,15 @@ open class LazyClassMemberScope(
|
||||
}.toList())
|
||||
}
|
||||
|
||||
private fun addSyntheticVariables(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
result.addAll(c.syntheticResolveExtension.getSyntheticPropertiesNames(thisDescriptor).flatMap {
|
||||
getContributedVariables(
|
||||
it,
|
||||
location
|
||||
)
|
||||
}.toList())
|
||||
}
|
||||
|
||||
private fun addSyntheticNestedClasses(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
result.addAll(c.syntheticResolveExtension.getSyntheticNestedClassNames(thisDescriptor).mapNotNull {
|
||||
getContributedClassifier(
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
<args>
|
||||
<arg>-Xjvm-default=enable</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
Reference in New Issue
Block a user