New J2K: Add variance type parameters
This commit is contained in:
committed by
Ilya Kirillov
parent
14f5d866ee
commit
524b07f6ac
@@ -493,6 +493,13 @@ class NewCodeBuilder {
|
||||
is JKContextType -> return
|
||||
is JKStarProjectionType ->
|
||||
printer.printWithNoIndent("*")
|
||||
is JKVarianceTypeParameterType -> {
|
||||
when (type.variance) {
|
||||
JKVarianceTypeParameterType.Variance.IN -> printer.printWithNoIndent("in ")
|
||||
JKVarianceTypeParameterType.Variance.OUT -> printer.printWithNoIndent("out ")
|
||||
}
|
||||
renderType(type.boundType)
|
||||
}
|
||||
else -> printer.printWithNoIndent("Unit /* TODO: ${type::class} */")
|
||||
}
|
||||
if (type is JKParametrizedType && type.parameters.isNotEmpty()) {
|
||||
|
||||
@@ -60,6 +60,17 @@ interface JKType {
|
||||
val nullability: Nullability
|
||||
}
|
||||
|
||||
interface JKVarianceTypeParameterType : JKType {
|
||||
val variance: Variance
|
||||
val boundType: JKType
|
||||
override val nullability: Nullability
|
||||
get() = Nullability.NotNull
|
||||
|
||||
enum class Variance {
|
||||
IN, OUT
|
||||
}
|
||||
}
|
||||
|
||||
interface JKNoType : JKType
|
||||
|
||||
interface JKParametrizedType : JKType {
|
||||
|
||||
@@ -70,7 +70,20 @@ fun PsiType.toJK(symbolProvider: JKSymbolProvider, nullability: Nullability = Nu
|
||||
?: error("Invalid primitive type $presentableText")
|
||||
is PsiDisjunctionType ->
|
||||
JKJavaDisjunctionTypeImpl(disjunctions.map { it.toJK(symbolProvider) })
|
||||
is PsiWildcardType -> JKStarProjectionTypeImpl()
|
||||
is PsiWildcardType ->
|
||||
when {
|
||||
isExtends ->
|
||||
JKVarianceTypeParameterTypeImpl(
|
||||
JKVarianceTypeParameterType.Variance.OUT,
|
||||
extendsBound.toJK(symbolProvider)
|
||||
)
|
||||
isSuper ->
|
||||
JKVarianceTypeParameterTypeImpl(
|
||||
JKVarianceTypeParameterType.Variance.IN,
|
||||
superBound.toJK(symbolProvider)
|
||||
)
|
||||
else -> JKStarProjectionTypeImpl()
|
||||
}
|
||||
else -> throw Exception("Invalid PSI ${this::class.java}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user