Kapt: Fix type arguments in JeDeclaredType. In case of type variable, JeTypeVariableType should be returned

(cherry picked from commit ed34ec0)
This commit is contained in:
Yan Zhulanow
2016-08-24 01:27:06 +03:00
committed by Yan Zhulanow
parent ebcc762ae9
commit 7810678389
3 changed files with 48 additions and 3 deletions
@@ -49,10 +49,22 @@ class JeDeclaredType(
get() = psiClass.manager
override fun getTypeArguments(): List<TypeMirror> {
if (psiType.isRaw) return emptyList()
return when (psiType) {
is PsiClassReferenceType -> psiType.parameters.map { it.toJeType(psiManager) }
is PsiClassType -> {
val substitutor = psiType.resolveGenerics().substitutor
val psiClass = psiType.resolve() ?: return psiType.parameters.map { it.toJeType(psiManager) }
val args = mutableListOf<TypeMirror>()
for (typeParameter in psiClass.typeParameters) {
val substitutedParameter = substitutor.substitute(typeParameter)
if (substitutedParameter != null)
args += substitutedParameter.toJeType(psiManager)
else
args += JeTypeVariableType(PsiTypesUtil.getClassType(typeParameter), typeParameter)
}
args
}
else -> emptyList()
}
}