Report error when try to access to static field which come from many sources

This commit is contained in:
Zalim Bashorov
2015-10-08 21:28:37 +03:00
parent da00ddfc3e
commit e9b138557b
8 changed files with 344 additions and 1 deletions
@@ -85,7 +85,20 @@ public class LazyJavaStaticClassScope(
override fun computeNonDeclaredProperties(name: Name, result: MutableCollection<PropertyDescriptor>) {
val propertiesFromSupertypes = getStaticPropertiesFromJavaSupertypes(name, getContainingDeclaration())
result.addAll(DescriptorResolverUtils.resolveOverrides(name, propertiesFromSupertypes, result, getContainingDeclaration(), c.components.errorReporter))
val actualProperties =
if (!result.isEmpty()) {
DescriptorResolverUtils.resolveOverrides(name, propertiesFromSupertypes, result, getContainingDeclaration(), c.components.errorReporter)
}
else {
propertiesFromSupertypes.groupBy {
it.realOriginal
}.flatMap {
DescriptorResolverUtils.resolveOverrides(name, it.value, result, getContainingDeclaration(), c.components.errorReporter)
}
}
result.addAll(actualProperties)
}
override fun getContainingDeclaration() = super.getContainingDeclaration() as LazyJavaClassDescriptor
@@ -114,4 +127,11 @@ public class LazyJavaStaticClassScope(
return descriptor.typeConstructor.supertypes.flatMap(::getStaticProperties).toSet()
}
private val PropertyDescriptor.realOriginal: PropertyDescriptor
get() {
if (this.kind.isReal) return this
return this.overriddenDescriptors.map { it.realOriginal }.distinct().single()
}
}