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