Support java synthetic properties in DependencyCollector

This commit is contained in:
Mikhael Bogdanov
2017-11-17 16:39:48 +01:00
parent 8198599ef5
commit 5753f93a57
@@ -82,16 +82,25 @@ class DependenciesCollector {
private fun Collection<IrSymbol>.addTopLevelDeclarations() { private fun Collection<IrSymbol>.addTopLevelDeclarations() {
forEach { forEach {
addTopLevelDescriptor(getTopLevelDeclaration(it.descriptor)) getTopLevelDeclaration(it.descriptor)?.let { addTopLevelDescriptor(it) }
} }
} }
private fun getTopLevelDeclaration(descriptor: DeclarationDescriptor): DeclarationDescriptor { private fun getTopLevelDeclaration(descriptor: DeclarationDescriptor): DeclarationDescriptor? {
val containingDeclaration = descriptor.containingDeclaration val containingDeclaration = descriptor.containingDeclaration
return when (containingDeclaration) { return when (containingDeclaration) {
is PackageFragmentDescriptor -> descriptor is PackageFragmentDescriptor -> descriptor
is ClassDescriptor -> getTopLevelDeclaration(containingDeclaration) is ClassDescriptor -> getTopLevelDeclaration(containingDeclaration)
else -> throw AssertionError("Package or class expected: $containingDeclaration; for $descriptor") else ->
if (descriptor is PropertyAccessorDescriptor &&
descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED &&
containingDeclaration is ModuleDescriptor
) {
//skip synthetic java properties
null
} else {
throw AssertionError("Package or class expected: $containingDeclaration; for $descriptor")
}
} }
} }