Kapt: typeElement.asType() should preserve type parameters and propagate it to its supertypes (KT-13865)
(cherry picked from commit 92c9cea)
This commit is contained in:
committed by
Yan Zhulanow
parent
a22721fbd8
commit
f83e7509b2
+3
-2
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.java.model.elements.JeAnnotationMirror
|
||||
import org.jetbrains.kotlin.java.model.elements.JeMethodExecutableElement
|
||||
import org.jetbrains.kotlin.java.model.elements.JePackageElement
|
||||
import org.jetbrains.kotlin.java.model.elements.JeTypeElement
|
||||
import org.jetbrains.kotlin.java.model.internal.getTypeWithTypeParameters
|
||||
import java.io.PrintWriter
|
||||
import java.io.Writer
|
||||
import javax.lang.model.element.*
|
||||
@@ -48,7 +49,7 @@ class KotlinElements(
|
||||
val hiderMethodClass = hiderMethod.containingClass ?: return false
|
||||
val hiddenMethodClass = hiddenMethod.containingClass ?: return false
|
||||
|
||||
if (PsiTypesUtil.getClassType(hiddenMethodClass) !in hiderMethodClass.superTypes) return false
|
||||
if (hiddenMethodClass.getTypeWithTypeParameters() !in hiderMethodClass.superTypes) return false
|
||||
|
||||
return isSubSignature(hiderMethod, hiddenMethod)
|
||||
}
|
||||
@@ -148,7 +149,7 @@ class KotlinElements(
|
||||
|
||||
private fun PsiClass.isSubclassOf(other: PsiClass?): Boolean {
|
||||
if (other == null) return false
|
||||
return TypeConversionUtil.isAssignable(PsiTypesUtil.getClassType(other), PsiTypesUtil.getClassType(this), false)
|
||||
return TypeConversionUtil.isAssignable(other.getTypeWithTypeParameters(), this.getTypeWithTypeParameters(), false)
|
||||
}
|
||||
|
||||
private fun isSubSignature(childMethod: PsiMethod, superMethod: PsiMethod): Boolean {
|
||||
|
||||
+2
-7
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.annotation.processing.impl
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.util.*
|
||||
import org.jetbrains.kotlin.java.model.JeElement
|
||||
@@ -135,10 +134,6 @@ class KotlinTypes(
|
||||
override fun directSupertypes(t: TypeMirror): List<TypeMirror> {
|
||||
if (t is NoType || t is ExecutableType) throw IllegalArgumentException("Invalid type: $t")
|
||||
|
||||
if (t is JeDeclaredType && t.psiType is PsiImmediateClassType) {
|
||||
return t.psiClass.superTypes.map { it.toJeType(psiManager()) }
|
||||
}
|
||||
|
||||
val psiType = (t as? JePsiType)?.psiType as? PsiClassType ?: return emptyList()
|
||||
return psiType.superTypes.map { it.toJeType(psiManager()) }
|
||||
}
|
||||
@@ -197,7 +192,7 @@ class KotlinTypes(
|
||||
i, t -> (t as? JePsiType)?.psiType ?: throw IllegalArgumentException("Invalid type argument #$i: $t")
|
||||
}
|
||||
|
||||
val psiType = createDeclaredType(psiClass, typeArgs) ?:
|
||||
val psiType = createImmediateClassType(psiClass, typeArgs) ?:
|
||||
throw IllegalStateException("Can't create declared type ($psiClass, $typeArgs)")
|
||||
return JeDeclaredType(psiType, psiClass)
|
||||
}
|
||||
@@ -229,7 +224,7 @@ class KotlinTypes(
|
||||
i, t -> (t as? JePsiType)?.psiType ?: throw IllegalArgumentException("Invalid type argument #$i: $t")
|
||||
}
|
||||
|
||||
val psiType = createDeclaredType(psiClass, typeArgs) ?:
|
||||
val psiType = createImmediateClassType(psiClass, typeArgs) ?:
|
||||
throw IllegalStateException("Can't create declared type ($psiClass, $typeArgs)")
|
||||
return JeDeclaredType(psiType, psiClass, containing)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user