Do not look into captured star projection as types
This commit is contained in:
+7
-3
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.*
|
||||
import org.jetbrains.kotlin.types.AbstractNullabilityChecker
|
||||
import org.jetbrains.kotlin.types.AbstractNullabilityChecker.hasPathByNotMarkedNullableNodes
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
object NewCommonSuperTypeCalculator {
|
||||
@@ -174,7 +177,8 @@ object NewCommonSuperTypeCalculator {
|
||||
}
|
||||
|
||||
private fun TypeSystemCommonSuperTypesContext.isCapturedStubType(type: SimpleTypeMarker): Boolean {
|
||||
val projectedType = type.asCapturedType()?.typeConstructor()?.projection()?.getType() ?: return false
|
||||
val projectedType =
|
||||
type.asCapturedType()?.typeConstructor()?.projection()?.takeUnless { it.isStarProjection() }?.getType() ?: return false
|
||||
return projectedType.asSimpleType()?.isStubType() == true
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -185,10 +185,12 @@ class NewConstraintSystemImpl(
|
||||
val capturedType = it.asSimpleType()?.asCapturedType()
|
||||
// TODO: change NewCapturedType to markered one for FE-IR
|
||||
val typeToCheck = if (capturedType is CapturedTypeMarker && capturedType.captureStatus() == CaptureStatus.FROM_EXPRESSION)
|
||||
capturedType.typeConstructorProjection().getType()
|
||||
capturedType.typeConstructorProjection().takeUnless { projection -> projection.isStarProjection() }?.getType()
|
||||
else
|
||||
it
|
||||
|
||||
if (typeToCheck == null) return@contains false
|
||||
|
||||
storage.allTypeVariables.containsKey(typeToCheck.typeConstructor())
|
||||
}
|
||||
}
|
||||
@@ -333,4 +335,4 @@ class NewConstraintSystemImpl(
|
||||
|
||||
return constraints.any { (it.kind == ConstraintKind.UPPER || it.kind == ConstraintKind.EQUALITY) && it.type.isUnit() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
|
||||
fun KotlinTypeMarker.isDynamic(): Boolean = asFlexibleType()?.asDynamicType() != null
|
||||
fun KotlinTypeMarker.isCapturedDynamic(): Boolean =
|
||||
asSimpleType()?.asCapturedType()?.typeConstructor()?.projection()?.getType()?.isDynamic() == true
|
||||
asSimpleType()?.asCapturedType()?.typeConstructor()?.projection()?.takeUnless { it.isStarProjection() }
|
||||
?.getType()?.isDynamic() == true
|
||||
|
||||
fun KotlinTypeMarker.isDefinitelyNotNullType(): Boolean = asSimpleType()?.asDefinitelyNotNullType() != null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user