[Type system] Fix algorithm of folding recursive types
There was a problem when we get type from type projection even if it is a star projection what is meaningless. Now we try to fold argument only if it's not a star projection
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a453ed50fa
commit
71ca1aa608
+13
-8
@@ -205,18 +205,23 @@ object NewCommonSuperTypeCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is used for folding recursive types like Inv<Inv<*>> into Inv<*>
|
||||||
|
fun collapseRecursiveArgumentIfPossible(argument: TypeArgumentMarker): TypeArgumentMarker {
|
||||||
|
if (argument.isStarProjection()) return argument
|
||||||
|
val argumentType = argument.getType().asSimpleType()
|
||||||
|
val argumentConstructor = argumentType?.typeConstructor()
|
||||||
|
return if (argument.getVariance() == TypeVariance.OUT && argumentConstructor == constructor && argumentType.asArgumentList()[index].isStarProjection()) {
|
||||||
|
createStarProjection(parameter)
|
||||||
|
} else {
|
||||||
|
argument
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val argument =
|
val argument =
|
||||||
if (thereIsStar || typeProjections.isEmpty()) {
|
if (thereIsStar || typeProjections.isEmpty()) {
|
||||||
createStarProjection(parameter)
|
createStarProjection(parameter)
|
||||||
} else {
|
} else {
|
||||||
val argument = calculateArgument(parameter, typeProjections, depth)
|
collapseRecursiveArgumentIfPossible(calculateArgument(parameter, typeProjections, depth))
|
||||||
val argumentType = argument.getType().asSimpleType()
|
|
||||||
val argumentConstructor = argumentType?.typeConstructor()
|
|
||||||
if (argument.getVariance() == TypeVariance.OUT && argumentConstructor == constructor && argumentType.asArgumentList()[index].isStarProjection()) {
|
|
||||||
createStarProjection(parameter)
|
|
||||||
} else {
|
|
||||||
argument
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments.add(argument)
|
arguments.add(argument)
|
||||||
|
|||||||
Reference in New Issue
Block a user