FIR: enhance Java type parameter bounds

This also fixes handling of self-recursive types.

TODO: fix jspecify/{strict,warn}Mode/Captured.fir.kt
This commit is contained in:
pyos
2021-08-12 18:55:44 +02:00
committed by teamcityserver
parent e2a48d3945
commit 03304bce96
30 changed files with 222 additions and 382 deletions
@@ -27,6 +27,9 @@ abstract class AbstractSignatureParts<Annotation : Any> {
abstract val skipRawTypeArguments: Boolean
abstract val typeSystem: TypeSystemContext
open val forceOnlyHeadTypeConstructor: Boolean
get() = false
abstract val Annotation.forceWarning: Boolean
abstract val KotlinTypeMarker.annotations: Iterable<Annotation>
@@ -179,7 +182,8 @@ abstract class AbstractSignatureParts<Annotation : Any> {
// (outermost type), unless the type in the subclass is interchangeable with the all the types in superclasses:
// e.g. we have (Mutable)List<String!>! in the subclass and { List<String!>, (Mutable)List<String>! } from superclasses
// Note that `this` is flexible here, so it's equal to it's bounds
val onlyHeadTypeConstructor = isCovariant && overrides.any { !this@computeIndexedQualifiers.isEqual(it) }
val onlyHeadTypeConstructor = forceOnlyHeadTypeConstructor ||
(isCovariant && overrides.any { !this@computeIndexedQualifiers.isEqual(it) })
val treeSize = if (onlyHeadTypeConstructor) 1 else indexedThisType.size
val computedResult = Array(treeSize) { index ->