Change properties to methods in light class hierarchy

There's a Kotlin-Java-Kotlin hierarchy with an abstract property in a
superclass and its implementation (as a get-method) in the Java subclass, which
caused problems because Kotlin subclass can't have both (different symbols,
same JVM signatures)
This commit is contained in:
Alexander Udalov
2015-02-04 12:03:30 +03:00
parent cafc1ea24d
commit 1c87464695
15 changed files with 35 additions and 24 deletions
@@ -48,7 +48,7 @@ public object JavaResolveExtension : CacheExtension<(PsiElement) -> Pair<JavaDes
}
fun PsiMethod.getJavaMethodDescriptor(): FunctionDescriptor {
if (this is KotlinLightMethod) throw AssertionError("Light methods are not allowed here: ${origin?.getText()}")
if (this is KotlinLightMethod) throw AssertionError("Light methods are not allowed here: ${getOrigin()?.getText()}")
val resolver = JavaResolveExtension.getResolver(getProject(), this)
val methodDescriptor = when {
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.FqName
class KotlinLightClassForDecompiledDeclaration(
private val clsClass: ClsClassImpl,
override val origin: JetClassOrObject?
private val origin: JetClassOrObject?
) : KotlinWrappingLightClass(clsClass.getManager()) {
override fun copy() = this
@@ -38,5 +38,7 @@ class KotlinLightClassForDecompiledDeclaration(
override fun getDelegate() = clsClass
override val fqName: FqName = origin?.getFqName() ?: FqName(clsClass.getQualifiedName())
override fun getOrigin() = origin
override fun getFqName() = origin?.getFqName() ?: FqName(clsClass.getQualifiedName())
}
@@ -111,7 +111,7 @@ private fun KotlinLightElement<*, *>.getModuleInfoForLightElement(): IdeaModuleI
if (this is KotlinLightClassForDecompiledDeclaration) {
return getModuleInfoByVirtualFile(getProject(), getContainingFile().getVirtualFile(), false)
}
val element = origin ?: when (this) {
val element = getOrigin() ?: when (this) {
is FakeLightClassForFileOfPackage -> this.getContainingFile()!!
is KotlinLightClassForPackage -> this.getFiles().first()
else -> throw IllegalStateException("Unknown light class without origin is referenced by IDE lazy resolve: $javaClass")
@@ -140,7 +140,7 @@ fun PsiReference.isPropertyReadOnlyUsage(): Boolean {
val refTarget = resolve()
if (refTarget is KotlinLightMethod) {
val origin = refTarget.origin
val origin = refTarget.getOrigin()
val declaration: JetNamedDeclaration? = when (origin) {
is JetPropertyAccessor -> origin.getNonStrictParentOfType<JetProperty>()
is JetProperty, is JetParameter -> origin as JetNamedDeclaration