Fix reflection on reference to generic property

See a93484b457 for the similar fix to function
references

 #KT-12967 Fixed
This commit is contained in:
Alexander Udalov
2016-07-04 16:11:45 +03:00
parent 48fe9fb2c0
commit 3b349e9be0
4 changed files with 23 additions and 4 deletions
@@ -109,6 +109,10 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
RuntimeTypeMapper.mapPropertySignature(descriptor).asString() == signature
}
if (properties.isEmpty()) {
throw KotlinReflectionInternalError("Property '$name' (JVM signature: $signature) not resolved in $this")
}
if (properties.size != 1) {
// Try working around the case of a Java class with a field 'foo' and a method 'getFoo' which overrides Kotlin property 'foo'.
// Such class has two property descriptors with the name 'foo' in its scope and they may be indistinguishable from each other.
@@ -129,10 +133,8 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
return mostVisibleProperties.first()
}
val debugText = "'$name' (JVM signature: $signature)"
throw KotlinReflectionInternalError(
if (properties.isEmpty()) "Property $debugText not resolved in $this"
else "${properties.size} properties $debugText resolved in $this: $properties"
"${properties.size} properties '$name' (JVM signature: $signature) resolved in $this: $properties"
)
}