NI: discard def not null types if they appear in return positions, in inv or in variance

^KT-37343 Fixed
This commit is contained in:
Victor Petukhov
2020-02-21 12:44:12 +03:00
parent 368b0d9b0b
commit 92a0ddfe71
28 changed files with 1451 additions and 37 deletions
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
import org.jetbrains.kotlin.types.checker.NewCapturedType
import org.jetbrains.kotlin.types.model.*
import org.jetbrains.kotlin.utils.addToStdlib.cast
@@ -267,6 +268,16 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
return this.constructor.typeParameterMarker
}
override fun CapturedTypeMarker.withNotNullProjection(): KotlinTypeMarker {
require(this is ConeCapturedType)
return this // TODO
}
override fun CapturedTypeMarker.isProjectionNotNull(): Boolean {
require(this is ConeCapturedType)
return false // TODO
}
override fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker {
require(this is ConeDefinitelyNotNullType)
return this.original as SimpleTypeMarker
@@ -10725,6 +10725,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/constraints/constraintOnFunctionLiteral.kt");
}
@TestMetadata("definitelyNotNullTypeInArguments.kt")
public void testDefinitelyNotNullTypeInArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInArguments.kt");
}
@TestMetadata("definitelyNotNullTypeInReturnPosition.kt")
public void testDefinitelyNotNullTypeInReturnPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.kt");
}
@TestMetadata("definitelyNotNullTypeInvariantPosition.kt")
public void testDefinitelyNotNullTypeInvariantPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInvariantPosition.kt");
@@ -75,6 +75,9 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
override fun CapturedTypeMarker.typeConstructor(): CapturedTypeConstructorMarker =
error("Captured types should be used for IrTypes")
override fun CapturedTypeMarker.isProjectionNotNull(): Boolean =
error("Captured types should be used for IrTypes")
override fun CapturedTypeMarker.captureStatus(): CaptureStatus =
error("Captured types should be used for IrTypes")
@@ -12,8 +12,10 @@ import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.incremental.record
import org.jetbrains.kotlin.resolve.calls.components.CollectionTypeVariableUsagesInfo.getTypeParameterByVariable
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper.TypeArgumentsMapping.NoExplicitArguments
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
import org.jetbrains.kotlin.resolve.calls.inference.model.*
import org.jetbrains.kotlin.resolve.calls.inference.substitute
@@ -26,6 +28,9 @@ import org.jetbrains.kotlin.resolve.calls.tower.VisibilityError
import org.jetbrains.kotlin.resolve.sam.SAM_LOOKUP_NAME
import org.jetbrains.kotlin.resolve.sam.getFunctionTypeForPossibleSamType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
import org.jetbrains.kotlin.types.model.typeConstructor
import org.jetbrains.kotlin.types.typeUtil.contains
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.makeNullable
@@ -285,6 +290,144 @@ internal object CheckExplicitReceiverKindConsistency : ResolutionPart() {
}
}
internal object CollectionTypeVariableUsagesInfo : ResolutionPart() {
private val KotlinType.isComputed get() = this !is WrappedType || isComputed()
private fun NewConstraintSystem.isContainedInInvariantOrContravariantPositions(
variableTypeConstructor: TypeConstructorMarker,
baseType: KotlinTypeMarker,
wasOutVariance: Boolean = true
): Boolean {
if (baseType !is KotlinType) return false
val dependentTypeParameter = getTypeParameterByVariable(variableTypeConstructor) ?: return false
val declaredTypeParameters = baseType.constructor.parameters
if (declaredTypeParameters.size < baseType.arguments.size) return false
for ((argumentsIndex, argument) in baseType.arguments.withIndex()) {
if (argument.isStarProjection || argument.type.isMarkedNullable) continue
val currentEffectiveVariance =
declaredTypeParameters[argumentsIndex].variance == Variance.OUT_VARIANCE || argument.projectionKind == Variance.OUT_VARIANCE
val effectiveVarianceFromTopLevel = wasOutVariance && currentEffectiveVariance
if ((argument.type.constructor == dependentTypeParameter || argument.type.constructor == variableTypeConstructor) && !effectiveVarianceFromTopLevel)
return true
if (isContainedInInvariantOrContravariantPositions(variableTypeConstructor, argument.type, effectiveVarianceFromTopLevel))
return true
}
return false
}
private fun isContainedInInvariantOrContravariantPositionsAmongTypeParameters(
checkingType: TypeVariableFromCallableDescriptor,
typeParameters: List<TypeParameterDescriptor>
) = typeParameters.any {
it.variance != Variance.OUT_VARIANCE && it.typeConstructor == checkingType.originalTypeParameter.typeConstructor
}
private fun NewConstraintSystem.getDependentTypeParameters(
variable: TypeConstructorMarker,
dependentTypeParametersSeen: List<Pair<TypeConstructorMarker, KotlinTypeMarker?>> = listOf()
): List<Pair<TypeConstructorMarker, KotlinTypeMarker?>> {
val context = asConstraintSystemCompleterContext()
val dependentTypeParameters = getBuilder().currentStorage().notFixedTypeVariables.mapNotNull { (typeConstructor, constraints) ->
val upperBounds = constraints.constraints.filter {
it.position.from is DeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER
}
upperBounds.mapNotNull { constraint ->
if (constraint.type.typeConstructor(context) != variable) {
val suitableUpperBound = upperBounds.find { upperBound ->
with(context) { upperBound.type.contains { it.typeConstructor() == variable } }
}?.type
if (suitableUpperBound != null) typeConstructor to suitableUpperBound else null
} else typeConstructor to null
}
}.flatten().filter { it !in dependentTypeParametersSeen && it.first != variable }
return dependentTypeParameters + dependentTypeParameters.mapNotNull { (typeConstructor, _) ->
if (typeConstructor != variable) {
getDependentTypeParameters(typeConstructor, dependentTypeParameters + dependentTypeParametersSeen)
} else null
}.flatten()
}
private fun NewConstraintSystem.isContainedInInvariantOrContravariantPositionsAmongUpperBound(
checkingType: TypeConstructorMarker,
dependentTypeParameters: List<Pair<TypeConstructorMarker, KotlinTypeMarker?>>
): Boolean {
var currentTypeParameterConstructor = checkingType
return dependentTypeParameters.any { (typeConstructor, upperBound) ->
val isContainedOrNoUpperBound =
upperBound == null || isContainedInInvariantOrContravariantPositions(currentTypeParameterConstructor, upperBound)
currentTypeParameterConstructor = typeConstructor
isContainedOrNoUpperBound
}
}
private fun NewConstraintSystem.getTypeParameterByVariable(typeConstructor: TypeConstructorMarker) =
(getBuilder().currentStorage().allTypeVariables[typeConstructor] as? TypeVariableFromCallableDescriptor)?.originalTypeParameter?.typeConstructor
private fun NewConstraintSystem.getDependingOnTypeParameter(variable: TypeConstructor) =
getBuilder().currentStorage().notFixedTypeVariables[variable]?.constraints?.mapNotNull {
if (it.position.from is DeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER) {
it.type.typeConstructor(asConstraintSystemCompleterContext())
} else null
} ?: emptyList()
private fun NewConstraintSystem.isContainedInInvariantOrContravariantPositionsWithDependencies(
variable: TypeVariableFromCallableDescriptor,
declarationDescriptor: DeclarationDescriptor?
): Boolean {
if (declarationDescriptor !is CallableDescriptor) return false
val returnType = declarationDescriptor.returnType ?: return false
if (!returnType.isComputed) return false
val typeVariableConstructor = variable.freshTypeConstructor
val dependentTypeParameters = getDependentTypeParameters(typeVariableConstructor)
val dependingOnTypeParameter = getDependingOnTypeParameter(typeVariableConstructor)
val isContainedInUpperBounds =
isContainedInInvariantOrContravariantPositionsAmongUpperBound(typeVariableConstructor, dependentTypeParameters)
val isContainedAnyDependentTypeInReturnType = dependentTypeParameters.any { (typeParameter, _) ->
returnType.contains {
it.typeConstructor(asConstraintSystemCompleterContext()) == getTypeParameterByVariable(typeParameter) && !it.isMarkedNullable
}
}
return isContainedInInvariantOrContravariantPositions(typeVariableConstructor, returnType)
|| dependingOnTypeParameter.any { isContainedInInvariantOrContravariantPositions(it, returnType) }
|| dependentTypeParameters.any { isContainedInInvariantOrContravariantPositions(it.first, returnType) }
|| (isContainedAnyDependentTypeInReturnType && isContainedInUpperBounds)
}
private fun TypeVariableFromCallableDescriptor.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter() {
freshTypeConstructor.isContainedInInvariantOrContravariantPositions = true
}
override fun KotlinResolutionCandidate.process(workIndex: Int) {
for (variable in resolvedCall.freshVariablesSubstitutor.freshVariables) {
if (resolvedCall.candidateDescriptor is ClassConstructorDescriptor) {
val typeParameters = resolvedCall.candidateDescriptor.containingDeclaration.declaredTypeParameters
if (isContainedInInvariantOrContravariantPositionsAmongTypeParameters(variable, typeParameters)) {
variable.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter()
}
} else if (getSystem().isContainedInInvariantOrContravariantPositionsWithDependencies(variable, candidateDescriptor)) {
variable.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter()
}
}
}
}
private fun KotlinResolutionCandidate.resolveKotlinArgument(
argument: KotlinCallArgument,
candidateParameter: ParameterDescriptor?,
@@ -5,9 +5,11 @@
package org.jetbrains.kotlin.resolve.calls.inference.components
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
import org.jetbrains.kotlin.types.AbstractNullabilityChecker
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
import org.jetbrains.kotlin.types.checker.NewCapturedType
import org.jetbrains.kotlin.types.model.*
abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheckerContext(), TypeSystemInferenceExtensionContext {
@@ -179,9 +181,31 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
private fun simplifyLowerConstraint(typeVariable: KotlinTypeMarker, subType: KotlinTypeMarker): Boolean {
val lowerConstraint = when (typeVariable) {
is SimpleTypeMarker ->
// Foo <: T or
// Foo <: T? -- Foo!! <: T
if (typeVariable.isMarkedNullable()) subType.makeDefinitelyNotNullOrNotNull() else subType
/*
* Foo <: T -- Foo <: T
* Foo <: T? (T is contained in invariant or contravariant positions of a return type) -- Foo <: T
* Example:
* fun <T> foo(x: T?): Inv<T> {}
* fun <K> main(z: K) { val x = foo(z) }
* Foo <: T? (T isn't contained there) -- Foo!! <: T
* Example:
* fun <T> foo(x: T?) {}
* fun <K> main(z: K) { foo(z) }
*/
if (typeVariable.isMarkedNullable()) {
val typeVariableTypeConstructor = typeVariable.typeConstructor()
val subTypeConstructor = subType.typeConstructor()
if (subTypeConstructor !is TypeVariableTypeConstructor && typeVariableTypeConstructor is TypeVariableTypeConstructor && typeVariableTypeConstructor.isContainedInInvariantOrContravariantPositions) {
if (subType is NewCapturedType) {
subType.withNotNullProjection()
} else {
subType.withNullability(false)
}
} else {
subType.makeDefinitelyNotNullOrNotNull()
}
} else subType
is FlexibleTypeMarker -> {
assertFlexibleTypeVariable(typeVariable)
@@ -49,10 +49,12 @@ class TypeVariableTypeConstructor(private val builtIns: KotlinBuiltIns, val debu
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): TypeConstructor = this
override fun toString() = "TypeVariable($debugName)"
var isContainedInInvariantOrContravariantPositions: Boolean = false
}
sealed class NewTypeVariable(builtIns: KotlinBuiltIns, name: String) : TypeVariableMarker {
val freshTypeConstructor: TypeConstructor = TypeVariableTypeConstructor(builtIns, name)
val freshTypeConstructor = TypeVariableTypeConstructor(builtIns, name)
// member scope is used if we have receiver with type TypeVariable(T)
// todo add to member scope methods from supertypes for type variable
@@ -206,6 +206,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
NoTypeArguments,
NoArguments,
CreateFreshVariablesSubstitutor,
CollectionTypeVariableUsagesInfo,
CheckExplicitReceiverKindConsistency,
CheckReceivers,
PostponedVariablesInitializerResolutionPart
@@ -220,6 +221,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
MapArguments,
ArgumentsToCandidateParameterDescriptor,
CreateFreshVariablesSubstitutor,
CollectionTypeVariableUsagesInfo,
CheckExplicitReceiverKindConsistency,
CheckReceivers,
CheckArgumentsInParenthesis,
@@ -41,7 +41,6 @@ open class TypeApproximatorConfiguration {
open val errorType get() = false
open val integerLiteralType: Boolean = false // IntegerLiteralTypeConstructor
open val definitelyNotNullType get() = true
open val definitelyNotNullTypeInInvariantPosition get() = true
open val intersection: IntersectionStrategy = TO_COMMON_SUPERTYPE
open val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean = { false }
@@ -83,10 +82,7 @@ open class TypeApproximatorConfiguration {
override val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean get() = { true }
}
object IncorporationConfiguration : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FOR_INCORPORATION) {
override val definitelyNotNullTypeInInvariantPosition: Boolean get() = false
}
object IncorporationConfiguration : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FOR_INCORPORATION)
object SubtypeCapturedTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FOR_SUBTYPING)
object CapturedAndIntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) {
override val integerLiteralType: Boolean get() = true
@@ -95,7 +91,6 @@ open class TypeApproximatorConfiguration {
object FinalApproximationAfterResolutionAndInference :
TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) {
override val integerLiteralType: Boolean get() = true
override val definitelyNotNullTypeInInvariantPosition: Boolean get() = false
}
object IntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AllFlexibleSameValue() {
@@ -377,7 +372,11 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
// C = in Int, Int <: C => Int? <: C?
// C = out Number, C <: Number => C? <: Number?
return if (type.isMarkedNullable()) baseResult.withNullability(true) else baseResult
return when {
type.isMarkedNullable() -> baseResult.withNullability(true)
type.isProjectionNotNull() -> baseResult.withNullability(false)
else -> baseResult
}
}
private fun approximateSimpleToSuperType(type: SimpleTypeMarker, conf: TypeApproximatorConfiguration, depth: Int) =
@@ -480,12 +479,6 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
if (argument.isStarProjection()) continue
val effectiveVariance = AbstractTypeChecker.effectiveVariance(parameter.getVariance(), argument.getVariance())
if (effectiveVariance == TypeVariance.INV) {
val argumentType = argument.getType()
if (argumentType is DefinitelyNotNullTypeMarker && !conf.definitelyNotNullTypeInInvariantPosition) {
newArguments[index] = argumentType.original().withNullability(false).asTypeArgument()
}
}
val argumentType = newArguments[index]?.getType() ?: argument.getType()
@@ -0,0 +1,131 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -UNUSED_VARIABLE
class Foo<T>(x: T)
class Bar<S>
class OutBar<out S>
class InBar<in S>
fun <K> foo0(x: K?, y: Bar<K>) {}
fun <K> foo1(x: K?, y: Foo<Bar<K>>) {}
fun <K, T: K> foo2(x: K?, y: Foo<Bar<T>>) {}
fun <T, K: T> foo3(x: K?, y: Foo<Bar<T>>) {}
fun <K> foo4(x: K?, y: Foo<Bar<out K>>) {}
fun <K> foo5(x: K?, y: Bar<in K>) {}
fun <K> foo6(x: K?, y: OutBar<K>) {}
fun <K> foo7(x: K?, y: InBar<K>) {}
fun <T, K: T, S: K, M: S> foo8(x: T?, y: Foo<Bar<M>>) {}
fun <T, K: T, S: K, M: S> foo9(x: M?, y: Foo<Bar<T>>) {}
fun <T: J, K: T, S: K, M: S, J: L, L> foo10(x: L?, y: Foo<Bar<T>>, z: Bar<M>) {}
fun <T: J, K: T, S: K, M: S, J: L, L> foo11(x: M?, y: Foo<Bar<T>>, z: Bar<L>) {}
fun <K: Any> foo12(x: K?, y: Bar<K>) {}
class Foo13<T>(x: T) {
fun <K: T> foo1(x: T?, y: Bar<K>) {}
fun <K: T> foo2(x: K?, y: Bar<T>) {}
}
fun <K> foo14(x: K?, y: Bar<K>) where K: Comparable<K>, K: CharSequence {}
fun <K: T?, T> foo15(x: T, y: Bar<K>) {}
fun <K: T?, T> foo16(x: K, y: Bar<T>) {}
fun <K: T?, T> Bar<K>.foo18(x: T) {}
fun <K> foo21(x: K?, y: Foo<Foo<OutBar<K>>>) {}
fun <K> foo22(x: K?, y: Foo<Foo<InBar<K>>>) {}
fun <K> foo23(x: K?, y: Foo<Foo<Bar<out K>>>) {}
fun <K> foo24(x: K?, y: Foo<Foo<Bar<in K>>>) {}
fun <L> main(x: L?, y: L) {
foo0(x, Bar())
foo0(y, Bar())
foo1(x, Foo(Bar()))
foo1(y, Foo(Bar()))
if (x != null && y != null) {
foo1(x, Foo(Bar()))
foo1(y, Foo(Bar()))
}
foo2(x, Foo(Bar()))
foo2(y, Foo(Bar()))
foo3(x, Foo(Bar()))
foo3(y, Foo(Bar()))
foo4(x, Foo(Bar()))
foo4(y, Foo(Bar()))
foo5(x, Bar())
foo5(y, Bar())
foo6(x, OutBar())
foo6(y, OutBar())
foo7(x, InBar())
foo7(y, InBar())
foo8(x, Foo(Bar()))
foo8(y, Foo(Bar()))
foo9(x, Foo(Bar()))
foo9(y, Foo(Bar()))
foo10(x, Foo(Bar()), Bar())
foo10(y, Foo(Bar()), Bar())
foo11(x, Foo(Bar()), Bar())
foo11(y, Foo(Bar()), Bar())
if (x != null && y != null) {
foo12(x, Bar())
foo12(y, Bar())
}
foo12(x, Bar())
foo12(y, Bar())
Foo13(x).foo1(x, Bar())
Foo13(x).foo2(y, Bar())
Foo13(y).foo1(x, Bar())
Foo13(y).foo2(y, Bar())
if (x != null) {
Foo13(x).foo2(y, Bar())
Foo13(y).foo2(x, Bar())
}
if (y != null) {
Foo13(x).foo2(y, Bar())
Foo13(y).foo2(x, Bar())
}
foo14("y", Bar())
foo14("x", Bar())
foo15(x, Bar())
foo15(y, Bar())
if (x != null && y != null) {
foo15(x, Bar())
foo15(y, Bar())
}
foo16(x, Bar())
foo16(y, Bar())
if (x != null && y != null) {
foo16(x, Bar())
foo16(y, Bar())
}
Bar().foo18(x)
Bar().foo18(y)
foo21(x, Foo(Foo(OutBar())))
foo21(y, Foo(Foo(OutBar())))
foo22(x, Foo(Foo(InBar())))
foo22(y, Foo(Foo(InBar())))
foo23(x, Foo(Foo(Bar())))
foo23(y, Foo(Foo(Bar())))
foo24(x, Foo(Foo(Bar())))
foo24(y, Foo(Foo(Bar())))
}
@@ -0,0 +1,131 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -UNUSED_VARIABLE
class Foo<T>(x: T)
class Bar<S>
class OutBar<out S>
class InBar<in S>
fun <K> foo0(x: K?, y: Bar<K>) {}
fun <K> foo1(x: K?, y: Foo<Bar<K>>) {}
fun <K, T: K> foo2(x: K?, y: Foo<Bar<T>>) {}
fun <T, K: T> foo3(x: K?, y: Foo<Bar<T>>) {}
fun <K> foo4(x: K?, y: Foo<Bar<out K>>) {}
fun <K> foo5(x: K?, y: Bar<in K>) {}
fun <K> foo6(x: K?, y: OutBar<K>) {}
fun <K> foo7(x: K?, y: InBar<K>) {}
fun <T, K: T, S: K, M: S> foo8(x: T?, y: Foo<Bar<M>>) {}
fun <T, K: T, S: K, M: S> foo9(x: M?, y: Foo<Bar<T>>) {}
fun <T: J, K: T, S: K, M: S, J: L, L> foo10(x: L?, y: Foo<Bar<T>>, z: Bar<M>) {}
fun <T: J, K: T, S: K, M: S, J: L, L> foo11(x: M?, y: Foo<Bar<T>>, z: Bar<L>) {}
fun <K: Any> foo12(x: K?, y: Bar<K>) {}
class Foo13<T>(x: T) {
fun <K: T> foo1(x: T?, y: Bar<K>) {}
fun <K: T> foo2(x: K?, y: Bar<T>) {}
}
fun <K> foo14(x: K?, y: Bar<K>) where K: Comparable<K>, K: CharSequence {}
fun <K: T?, T> foo15(x: T, y: Bar<K>) {}
fun <K: T?, T> foo16(x: K, y: Bar<T>) {}
fun <K: T?, T> Bar<K>.foo18(x: T) {}
fun <K> foo21(x: K?, y: Foo<Foo<OutBar<K>>>) {}
fun <K> foo22(x: K?, y: Foo<Foo<InBar<K>>>) {}
fun <K> foo23(x: K?, y: Foo<Foo<Bar<out K>>>) {}
fun <K> foo24(x: K?, y: Foo<Foo<Bar<in K>>>) {}
fun <L> main(x: L?, y: L) {
foo0(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo0(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo1(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo1(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
if (x != null && y != null) {
foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L!! & L?")!>x<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L & L!!")!>y<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
}
foo2(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo2(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo3(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo3(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo4(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L!!>>")!>Foo(Bar())<!>)
foo4(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L!!>>")!>Foo(Bar())<!>)
foo5(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo5(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo6(x, <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<L!!>")!>OutBar()<!>)
foo6(y, <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<L!!>")!>OutBar()<!>)
foo7(x, <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L!!>")!>InBar()<!>)
foo7(y, <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L!!>")!>InBar()<!>)
foo8(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo8(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo9(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo9(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>)
foo10(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo10(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo11(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo11(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>Foo(Bar())<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
if (x != null && y != null) {
foo12(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo12(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
}
foo12(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo12(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
Foo13(x).foo1(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
Foo13(x).foo2(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
Foo13(y).foo1(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Bar()<!>)
Foo13(y).foo2(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Bar()<!>)
if (x != null) {
Foo13(<!DEBUG_INFO_SMARTCAST!>x<!>).foo2(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
Foo13(y).foo2(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Bar()<!>)
}
if (y != null) {
Foo13(x).foo2(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
Foo13(<!DEBUG_INFO_SMARTCAST!>y<!>).foo2(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
}
foo14("y", <!DEBUG_INFO_EXPRESSION_TYPE("Bar<kotlin.String>")!>Bar()<!>)
foo14("x", <!DEBUG_INFO_EXPRESSION_TYPE("Bar<kotlin.String>")!>Bar()<!>)
foo15(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
foo15(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
if (x != null && y != null) {
foo15(<!DEBUG_INFO_SMARTCAST!>x<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
foo15(<!DEBUG_INFO_SMARTCAST!>y<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Bar()<!>)
}
foo16(x, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Bar()<!>)
foo16(y, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Bar()<!>)
if (x != null && y != null) {
foo16(<!DEBUG_INFO_SMARTCAST!>x<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
foo16(<!DEBUG_INFO_SMARTCAST!>y<!>, <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>Bar()<!>)
}
<!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo18<!>(x)
<!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo18<!>(y)
foo21(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<OutBar<L!!>>>")!>Foo(Foo(OutBar()))<!>)
foo21(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<OutBar<L!!>>>")!>Foo(Foo(OutBar()))<!>)
foo22(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L!!>>>")!>Foo(Foo(InBar()))<!>)
foo22(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L!!>>>")!>Foo(Foo(InBar()))<!>)
foo23(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L!!>>>")!>Foo(Foo(Bar()))<!>)
foo23(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L!!>>>")!>Foo(Foo(Bar()))<!>)
foo24(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L!!>>>")!>Foo(Foo(Bar()))<!>)
foo24(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L!!>>>")!>Foo(Foo(Bar()))<!>)
}
@@ -0,0 +1,61 @@
package
public fun </*0*/ K> foo0(/*0*/ x: K?, /*1*/ y: Bar<K>): kotlin.Unit
public fun </*0*/ K> foo1(/*0*/ x: K?, /*1*/ y: Foo<Bar<K>>): kotlin.Unit
public fun </*0*/ T : J, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S, /*4*/ J : L, /*5*/ L> foo10(/*0*/ x: L?, /*1*/ y: Foo<Bar<T>>, /*2*/ z: Bar<M>): kotlin.Unit
public fun </*0*/ T : J, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S, /*4*/ J : L, /*5*/ L> foo11(/*0*/ x: M?, /*1*/ y: Foo<Bar<T>>, /*2*/ z: Bar<L>): kotlin.Unit
public fun </*0*/ K : kotlin.Any> foo12(/*0*/ x: K?, /*1*/ y: Bar<K>): kotlin.Unit
public fun </*0*/ K : kotlin.Comparable<K>> foo14(/*0*/ x: K?, /*1*/ y: Bar<K>): kotlin.Unit where K : kotlin.CharSequence
public fun </*0*/ K : T?, /*1*/ T> foo15(/*0*/ x: T, /*1*/ y: Bar<K>): kotlin.Unit
public fun </*0*/ K : T?, /*1*/ T> foo16(/*0*/ x: K, /*1*/ y: Bar<T>): kotlin.Unit
public fun </*0*/ K, /*1*/ T : K> foo2(/*0*/ x: K?, /*1*/ y: Foo<Bar<T>>): kotlin.Unit
public fun </*0*/ K> foo21(/*0*/ x: K?, /*1*/ y: Foo<Foo<OutBar<K>>>): kotlin.Unit
public fun </*0*/ K> foo22(/*0*/ x: K?, /*1*/ y: Foo<Foo<InBar<K>>>): kotlin.Unit
public fun </*0*/ K> foo23(/*0*/ x: K?, /*1*/ y: Foo<Foo<Bar<out K>>>): kotlin.Unit
public fun </*0*/ K> foo24(/*0*/ x: K?, /*1*/ y: Foo<Foo<Bar<in K>>>): kotlin.Unit
public fun </*0*/ T, /*1*/ K : T> foo3(/*0*/ x: K?, /*1*/ y: Foo<Bar<T>>): kotlin.Unit
public fun </*0*/ K> foo4(/*0*/ x: K?, /*1*/ y: Foo<Bar<out K>>): kotlin.Unit
public fun </*0*/ K> foo5(/*0*/ x: K?, /*1*/ y: Bar<in K>): kotlin.Unit
public fun </*0*/ K> foo6(/*0*/ x: K?, /*1*/ y: OutBar<K>): kotlin.Unit
public fun </*0*/ K> foo7(/*0*/ x: K?, /*1*/ y: InBar<K>): kotlin.Unit
public fun </*0*/ T, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S> foo8(/*0*/ x: T?, /*1*/ y: Foo<Bar<M>>): kotlin.Unit
public fun </*0*/ T, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S> foo9(/*0*/ x: M?, /*1*/ y: Foo<Bar<T>>): kotlin.Unit
public fun </*0*/ L> main(/*0*/ x: L?, /*1*/ y: L): kotlin.Unit
public fun </*0*/ K : T?, /*1*/ T> Bar<K>.foo18(/*0*/ x: T): kotlin.Unit
public final class Bar</*0*/ S> {
public constructor Bar</*0*/ S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo</*0*/ T> {
public constructor Foo</*0*/ T>(/*0*/ x: T)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo13</*0*/ T> {
public constructor Foo13</*0*/ T>(/*0*/ x: T)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun </*0*/ K : T> foo1(/*0*/ x: T?, /*1*/ y: Bar<K>): kotlin.Unit
public final fun </*0*/ K : T> foo2(/*0*/ x: K?, /*1*/ y: Bar<T>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class InBar</*0*/ in S> {
public constructor InBar</*0*/ in S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class OutBar</*0*/ out S> {
public constructor OutBar</*0*/ out S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,278 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -CAST_NEVER_SUCCEEDS -UNUSED_VARIABLE -UNCHECKED_CAST
class Foo<T>(x: T)
class Bar<S>
class OutBar<out S>
class InBar<in S>
interface IBar<S>
interface IFoo<S>
typealias OutBarAliasUseSite<T> = Bar<out T>
typealias OutBarAliasDecSite<T> = OutBar<T>
fun <T> materialize(): T = null as T
fun <K> foo0(x: K?): Bar<K> = materialize()
fun <K> foo1(x: K?): Foo<Bar<K>> = materialize()
fun <K, T: K> foo2(x: K?): Foo<Bar<T>> = materialize()
fun <T, K: T> foo3(x: K?): Foo<Bar<T>> = materialize()
fun <K> foo4(x: K?): Foo<Bar<out K>> = materialize()
fun <K> foo5(x: K?): Bar<in K> = materialize()
fun <K> foo6(x: K?): OutBar<K> = materialize()
fun <K> foo7(x: K?): InBar<K> = materialize()
fun <T, K: T, S: K, M: S> foo8(x: T?): Foo<Bar<M>> = materialize()
fun <T, K: T, S: K, M: S> foo9(x: M?): Foo<Bar<T>> = materialize()
fun <T: J, K: T, S: K, M: S, J: L, L> foo10(x: L?, y: Foo<Bar<T>>): Bar<M> = materialize()
fun <T: J, K: T, S: K, M: S, J: L, L> foo11(x: M?, y: Foo<Bar<T>>): Bar<L> = materialize()
fun <K: Any> foo12(x: K?): Bar<K> = materialize()
class Foo13<T>(x: T) {
fun <K: T> foo1(x: K?): Bar<T> = materialize()
}
fun <K> foo14(x: K?): Bar<K> where K: Comparable<K>, K: CharSequence = materialize()
fun <K: T?, T> foo15(x: T): Bar<K> = materialize()
fun <K: T?, T> foo16(x: K): Bar<T> = materialize()
fun <K: T?, T> foo17(x: K): Bar<T> = null as Bar<T>
fun <K> foo19(x: Bar<K>): K = null as K
fun <K> Bar<K>.foo20(): K = null as K
fun <K> foo21(x: K?): Foo<Foo<OutBar<K>>> = materialize()
fun <K> foo22(x: K?): Foo<Foo<InBar<K>>> = materialize()
fun <K> foo23(x: K?): Foo<Foo<Bar<out K>>> = materialize()
fun <K> foo24(x: K?): Foo<Foo<Bar<in K>>> = materialize()
fun <K> foo25(x: K?): Bar<out K> = materialize()
fun <K> foo26(x: K?): Foo<out Foo<out Bar<out K>>> = materialize()
fun <K> foo27(x: K?): Foo<out Foo<Bar<out K>>> = materialize()
fun <K> foo28(x: K?): OutBar<OutBar<OutBar<K>>> = materialize()
fun <K> foo29(x: K?): OutBar<Bar<OutBar<K>>> = materialize()
fun <K> foo30(x: K?): OutBar<Bar<out OutBar<K>>> = materialize()
fun <K> foo31(x: K?): OutBarAliasUseSite<K> = materialize()
fun <K> foo32(x: K?): OutBarAliasDecSite<K> = materialize()
fun <K> foo33(x: K?): OutBar<InBar<OutBar<K>>> = materialize()
fun <K> foo34(x: K?): OutBar<Bar<in OutBar<K>>> = materialize()
fun <K> foo35(x: K?): InBar<K> = materialize()
fun <K> foo36(x: K?): Bar<in K> = materialize()
fun <K, T: Bar<K>> foo37(x: K?): T = materialize()
fun <K, T: Bar<S>, S: Bar<K>> foo38(x: K?): T = materialize()
fun <K, T: Bar<S>, S: Bar<K>> foo39(x: K?): Bar<T> = materialize()
fun <K, T: Bar<K>> foo40(x: K?): Bar<T> = materialize()
fun <K, T: Bar<K>> foo41(x: K?): T = materialize()
fun <K, S: K, T> foo42(x: K?): T where T: IFoo<S> = materialize()
fun <K, S: K, T> foo43(x: K?): T where T: IBar<S>, T: IFoo<S> = materialize()
fun <K, S, T: S> foo44(x: K?): T where S: IFoo<String>, S: IBar<K> = materialize()
fun <K, T: OutBar<S>, S: Bar<K>> foo45(x: K?): OutBar<T> = materialize()
fun <K, T: OutBar<S>, S: OutBar<K>> foo46(x: K?): Bar<T> = materialize()
fun <K, T: OutBar<S>, S: OutBar<K>> foo47(x: K?): OutBar<T> = materialize()
fun <U: Any> foo48(fn: Function0<U?>): Bar<U> = materialize()
val <K> K?.vfoo0: Foo<Bar<K>> get() = materialize()
val <K> K?.vfoo1: OutBar<Bar<out OutBar<K>>> get() = materialize()
val <K> K?.vfoo2: OutBar<Bar<in OutBar<K>>> get() = materialize()
class Main<L>(x: L?, y: L) {
init {
if (x != null && y != null) {
val x12 = foo1(x)
val x13 = foo1(y)
}
if (x != null && y != null) {
val x120 = foo12(x)
val x121 = foo12(y)
}
if (x != null) {
val x137 = Foo13(y).foo1(x)
}
if (y != null) {
val x138 = Foo13(x).foo1(y)
}
if (x != null && y != null) {
val x153 = foo15(x)
val x154 = foo15(y)
}
if (x != null && y != null) {
val x163 = foo16(x)
val x164 = foo16(y)
}
}
val x00 = foo0(x)
val x01 = foo0(y)
val x10 = foo1(x)
val x11 = foo1(y)
val x12 = foo1(x!!)
val x13 = foo1(y!!)
val x20 = foo2(x)
val x21 = foo2(y)
val x30 = foo3(x)
val x31 = foo3(y)
val x40 = foo4(x)
val x41 = foo4(y)
val x50 = foo5(x)
val x51 = foo5(y)
val x60 = foo6(x)
val x61 = foo6(y)
val x70 = foo7(x)
val x71 = foo7(y)
val x80 = foo8(x)
val x81 = foo8(y)
val x90 = foo9(x)
val x91 = foo9(y)
val x100 = foo10(x, Foo(Bar()))
val x101 = foo10(y, Foo(Bar()))
val x110 = foo11(x, Foo(Bar()))
val x111 = foo11(y, Foo(Bar()))
val x120 = foo12(x!!)
val x121 = foo12(y!!)
val x122 = foo12(x)
val x123 = foo12(y)
val x133 = Foo13(x).foo1(y)
val x135 = Foo13(y).foo1(y)
val x137 = Foo13(y).foo1(x!!)
val x138 = Foo13(x).foo1(y!!)
val x140 = foo14("y")
val x141 = foo14("x")
val x151 = foo15(x)
val x152 = foo15(y)
val x153 = foo15(x!!)
val x154 = foo15(y!!)
val x161 = foo16(x)
val x162 = foo16(y)
val x163 = foo16(x!!)
val x164 = foo16(y!!)
val x170 = foo17(x)
val x171 = foo17(y)
val x180 = Bar().<!UNRESOLVED_REFERENCE!>foo18<!>(x)
val x181 = Bar().<!UNRESOLVED_REFERENCE!>foo18<!>(y)
val x200: L = Bar().<!UNRESOLVED_REFERENCE!>foo19<!>()
val x201: L = Bar().<!UNRESOLVED_REFERENCE!>foo19<!>()
val x210 = foo21(x)
val x211 = foo21(y)
val x220 = foo22(x)
val x221 = foo22(y)
val x230 = foo23(x)
val x231 = foo23(y)
val x240 = foo24(x)
val x241 = foo24(y)
val x250 = foo25(x)
val x251 = foo25(y)
val x260 = foo26(x)
val x261 = foo26(y)
val x270 = foo27(x)
val x271 = foo27(y)
val x280 = foo28(x)
val x281 = foo28(y)
val x290 = foo29(x)
val x291 = foo29(y)
val x300 = foo30(x)
val x301 = foo30(y)
val x310 = foo31(x)
val x311 = foo31(y)
val x320 = foo32(x)
val x321 = foo32(y)
val x330 = foo33(x)
val x331 = foo33(y)
val x340 = foo34(x)
val x341 = foo34(y)
val x350 = foo35(x)
val x351 = foo35(y)
val x360 = foo36(x)
val x361 = foo36(y)
val vx01 = x.vfoo0
val vx02 = y.vfoo0
val vx11 = x.vfoo1
val vx12 = y.vfoo1
val vx21 = x.vfoo2
val vx22 = y.vfoo2
val x370 = foo37(x)
val x371 = foo37(y)
val x380 = foo38(x)
val x381 = foo38(y)
val x390 = foo39(x)
val x391 = foo39(y)
val x400 = foo40(x)
val x401 = foo40(y)
val x410 = foo41(x)
val x411 = foo41(y)
val x420 = foo42(x)
val x421 = foo42(y)
val x430 = foo43(x)
val x431 = foo43(y)
val x440 = foo44(x)
val x441 = foo44(y)
val x450 = foo45(x)
val x451 = foo45(y)
val x460 = foo46(x)
val x461 = foo46(y)
val x470 = foo47(x)
val x471 = foo47(y)
fun <R> takeLambda(block: () -> R): R = materialize()
val x480 = takeLambda { foo48 { x } }
val x481 = takeLambda { foo48 { y } }
val x482 = takeLambda { foo48 { null } }
}
fun <T : Comparable<T>> nullsLast() = null as Foo<T?>
fun <K> take(x: Foo<K>, comparator: Foo<K>): Foo<K> {}
fun <L> test() {
take(null as Foo<String?>, nullsLast())
}
class Inv1<T>
class Inv2<T>
fun <K : Comparable<K>> Inv1<K>.assertStableSorted() {}
fun <K : Comparable<K>> Inv2<K>.assertStableSorted() = Inv1<K>().assertStableSorted()
@@ -0,0 +1,278 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -CAST_NEVER_SUCCEEDS -UNUSED_VARIABLE -UNCHECKED_CAST
class Foo<T>(x: T)
class Bar<S>
class OutBar<out S>
class InBar<in S>
interface IBar<S>
interface IFoo<S>
typealias OutBarAliasUseSite<T> = Bar<out T>
typealias OutBarAliasDecSite<T> = OutBar<T>
fun <T> materialize(): T = null as T
fun <K> foo0(x: K?): Bar<K> = materialize()
fun <K> foo1(x: K?): Foo<Bar<K>> = materialize()
fun <K, T: K> foo2(x: K?): Foo<Bar<T>> = materialize()
fun <T, K: T> foo3(x: K?): Foo<Bar<T>> = materialize()
fun <K> foo4(x: K?): Foo<Bar<out K>> = materialize()
fun <K> foo5(x: K?): Bar<in K> = materialize()
fun <K> foo6(x: K?): OutBar<K> = materialize()
fun <K> foo7(x: K?): InBar<K> = materialize()
fun <T, K: T, S: K, M: S> foo8(x: T?): Foo<Bar<M>> = materialize()
fun <T, K: T, S: K, M: S> foo9(x: M?): Foo<Bar<T>> = materialize()
fun <T: J, K: T, S: K, M: S, J: L, L> foo10(x: L?, y: Foo<Bar<T>>): Bar<M> = materialize()
fun <T: J, K: T, S: K, M: S, J: L, L> foo11(x: M?, y: Foo<Bar<T>>): Bar<L> = materialize()
fun <K: Any> foo12(x: K?): Bar<K> = materialize()
class Foo13<T>(x: T) {
fun <K: T> foo1(x: K?): Bar<T> = materialize()
}
fun <K> foo14(x: K?): Bar<K> where K: Comparable<K>, K: CharSequence = materialize()
fun <K: T?, T> foo15(x: T): Bar<K> = materialize()
fun <K: T?, T> foo16(x: K): Bar<T> = materialize()
fun <K: T?, T> foo17(x: K): Bar<T> = null as Bar<T>
fun <K> foo19(x: Bar<K>): K = null as K
fun <K> Bar<K>.foo20(): K = null as K
fun <K> foo21(x: K?): Foo<Foo<OutBar<K>>> = materialize()
fun <K> foo22(x: K?): Foo<Foo<InBar<K>>> = materialize()
fun <K> foo23(x: K?): Foo<Foo<Bar<out K>>> = materialize()
fun <K> foo24(x: K?): Foo<Foo<Bar<in K>>> = materialize()
fun <K> foo25(x: K?): Bar<out K> = materialize()
fun <K> foo26(x: K?): Foo<out Foo<out Bar<out K>>> = materialize()
fun <K> foo27(x: K?): Foo<out Foo<Bar<out K>>> = materialize()
fun <K> foo28(x: K?): OutBar<OutBar<OutBar<K>>> = materialize()
fun <K> foo29(x: K?): OutBar<Bar<OutBar<K>>> = materialize()
fun <K> foo30(x: K?): OutBar<Bar<out OutBar<K>>> = materialize()
fun <K> foo31(x: K?): OutBarAliasUseSite<K> = materialize()
fun <K> foo32(x: K?): OutBarAliasDecSite<K> = materialize()
fun <K> foo33(x: K?): OutBar<InBar<OutBar<K>>> = materialize()
fun <K> foo34(x: K?): OutBar<Bar<in OutBar<K>>> = materialize()
fun <K> foo35(x: K?): InBar<K> = materialize()
fun <K> foo36(x: K?): Bar<in K> = materialize()
fun <K, T: Bar<K>> foo37(x: K?): T = materialize()
fun <K, T: Bar<S>, S: Bar<K>> foo38(x: K?): T = materialize()
fun <K, T: Bar<S>, S: Bar<K>> foo39(x: K?): Bar<T> = materialize()
fun <K, T: Bar<K>> foo40(x: K?): Bar<T> = materialize()
fun <K, T: Bar<K>> foo41(x: K?): T = materialize()
fun <K, S: K, T> foo42(x: K?): T where T: IFoo<S> = materialize()
fun <K, S: K, T> foo43(x: K?): T where T: IBar<S>, T: IFoo<S> = materialize()
fun <K, S, T: S> foo44(x: K?): T where S: IFoo<String>, S: IBar<K> = materialize()
fun <K, T: OutBar<S>, S: Bar<K>> foo45(x: K?): OutBar<T> = materialize()
fun <K, T: OutBar<S>, S: OutBar<K>> foo46(x: K?): Bar<T> = materialize()
fun <K, T: OutBar<S>, S: OutBar<K>> foo47(x: K?): OutBar<T> = materialize()
fun <U: Any> foo48(fn: Function0<U?>): Bar<U> = materialize()
val <K> K?.vfoo0: Foo<Bar<K>> get() = materialize()
val <K> K?.vfoo1: OutBar<Bar<out OutBar<K>>> get() = materialize()
val <K> K?.vfoo2: OutBar<Bar<in OutBar<K>>> get() = materialize()
class Main<L>(x: L?, y: L) {
init {
if (x != null && y != null) {
val x12 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L!! & L?")!>x<!>)<!>
val x13 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L & L!!")!>y<!>)<!>
}
if (x != null && y != null) {
val x120 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo12(x)<!>
val x121 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo12(y)<!>
}
if (x != null) {
val x137 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Foo13(y).foo1(x)<!>
}
if (y != null) {
val x138 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Foo13(x).foo1(y)<!>
}
if (x != null && y != null) {
val x153 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(<!DEBUG_INFO_SMARTCAST!>x<!>)<!>
val x154 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(<!DEBUG_INFO_SMARTCAST!>y<!>)<!>
}
if (x != null && y != null) {
val x163 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo16(<!DEBUG_INFO_SMARTCAST!>x<!>)<!>
val x164 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo16(<!DEBUG_INFO_SMARTCAST!>y<!>)<!>
}
}
val x00 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo0(x)<!>
val x01 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo0(y)<!>
val x10 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo1(x)<!>
val x11 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo1(y)<!>
val x12 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L!!")!>x!!<!>)<!>
val x13 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L!!>>")!>foo1(<!DEBUG_INFO_EXPRESSION_TYPE("L!!")!>y!!<!>)<!>
val x20 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo2(x)<!>
val x21 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo2(y)<!>
val x30 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo3(x)<!>
val x31 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo3(y)<!>
val x40 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L>>")!>foo4(x)<!>
val x41 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<out L>>")!>foo4(y)<!>
val x50 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<in L>")!>foo5(x)<!>
val x51 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<in L>")!>foo5(y)<!>
val x60 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<L!!>")!>foo6(x)<!>
val x61 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<L!!>")!>foo6(y)<!>
val x70 = <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L>")!>foo7(x)<!>
val x71 = <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L>")!>foo7(y)<!>
val x80 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo8(x)<!>
val x81 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo8(y)<!>
val x90 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo9(x)<!>
val x91 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>foo9(y)<!>
val x100 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo10(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>Foo(Bar())<!>)<!>
val x101 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo10(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>Foo(Bar())<!>)<!>
val x110 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo11(x, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>Foo(Bar())<!>)<!>
val x111 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo11(y, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>Foo(Bar())<!>)<!>
val x120 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo12(x!!)<!>
val x121 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo12(y!!)<!>
val x122 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo12(<!TYPE_MISMATCH!>x<!>)<!>
val x123 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo12(<!TYPE_MISMATCH!>y<!>)<!>
val x133 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Foo13(x).foo1(y)<!>
val x135 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Foo13(y).foo1(y)<!>
val x137 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>Foo13(y).foo1(x!!)<!>
val x138 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>Foo13(x).foo1(y!!)<!>
val x140 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<kotlin.String>")!>foo14("y")<!>
val x141 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<kotlin.String>")!>foo14("x")<!>
val x151 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(x)<!>
val x152 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(y)<!>
val x153 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(x!!)<!>
val x154 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L?>")!>foo15(y!!)<!>
val x161 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo16(x)<!>
val x162 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo16(y)<!>
val x163 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo16(x!!)<!>
val x164 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L!!>")!>foo16(y!!)<!>
val x170 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo17(x)<!>
val x171 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo17(y)<!>
val x180 = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo18<!>(x)
val x181 = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo18<!>(y)
val x200: L = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo19<!>()
val x201: L = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>()<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo19<!>()
val x210 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<OutBar<L>>>")!>foo21(x)<!>
val x211 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<OutBar<L>>>")!>foo21(y)<!>
val x220 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L>>>")!>foo22(x)<!>
val x221 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<InBar<L>>>")!>foo22(y)<!>
val x230 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L>>>")!>foo23(x)<!>
val x231 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<out L>>>")!>foo23(y)<!>
val x240 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L>>>")!>foo24(x)<!>
val x241 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Foo<Bar<in L>>>")!>foo24(y)<!>
val x250 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<out L!!>")!>foo25(x)<!>
val x251 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<out L!!>")!>foo25(y)<!>
val x260 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<out Foo<out Bar<out L!!>>>")!>foo26(x)<!>
val x261 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<out Foo<out Bar<out L!!>>>")!>foo26(y)<!>
val x270 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<out Foo<Bar<out L>>>")!>foo27(x)<!>
val x271 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<out Foo<Bar<out L>>>")!>foo27(y)<!>
val x280 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<OutBar<L!!>>>")!>foo28(x)<!>
val x281 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<OutBar<L!!>>>")!>foo28(y)<!>
val x290 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<OutBar<L>>>")!>foo29(x)<!>
val x291 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<OutBar<L>>>")!>foo29(y)<!>
val x300 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<out OutBar<L!!>>>")!>foo30(x)<!>
val x301 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<out OutBar<L!!>>>")!>foo30(y)<!>
val x310 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBarAliasUseSite<L!!> /* = Bar<out L!!> */")!>foo31(x)<!>
val x311 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBarAliasUseSite<L!!> /* = Bar<out L!!> */")!>foo31(y)<!>
val x320 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBarAliasDecSite<L!!> /* = OutBar<L!!> */")!>foo32(x)<!>
val x321 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBarAliasDecSite<L!!> /* = OutBar<L!!> */")!>foo32(y)<!>
val x330 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<InBar<OutBar<L>>>")!>foo33(x)<!>
val x331 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<InBar<OutBar<L>>>")!>foo33(y)<!>
val x340 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<in OutBar<L>>>")!>foo34(x)<!>
val x341 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<in OutBar<L>>>")!>foo34(y)<!>
val x350 = <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L>")!>foo35(x)<!>
val x351 = <!DEBUG_INFO_EXPRESSION_TYPE("InBar<L>")!>foo35(y)<!>
val x360 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<in L>")!>foo36(x)<!>
val x361 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<in L>")!>foo36(y)<!>
val vx01 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>x.vfoo0<!>
val vx02 = <!DEBUG_INFO_EXPRESSION_TYPE("Foo<Bar<L>>")!>y.vfoo0<!>
val vx11 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<out OutBar<L!!>>>")!>x.vfoo1<!>
val vx12 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<out OutBar<L!!>>>")!>y.vfoo1<!>
val vx21 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<in OutBar<L>>>")!>x.vfoo2<!>
val vx22 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<Bar<in OutBar<L>>>")!>y.vfoo2<!>
val x370 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo37(x)<!>
val x371 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo37(y)<!>
val x380 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<L>>")!>foo38(x)<!>
val x381 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<L>>")!>foo38(y)<!>
val x390 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<Bar<L>>>")!>foo39(x)<!>
val x391 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<Bar<L>>>")!>foo39(y)<!>
val x400 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<L>>")!>foo40(x)<!>
val x401 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<Bar<L>>")!>foo40(y)<!>
val x410 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo41(x)<!>
val x411 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!>foo41(y)<!>
val x420 = <!DEBUG_INFO_EXPRESSION_TYPE("IFoo<L>")!>foo42(x)<!>
val x421 = <!DEBUG_INFO_EXPRESSION_TYPE("IFoo<L>")!>foo42(y)<!>
val x430 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IFoo<L>}")!>foo43(x)<!>
val x431 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IFoo<L>}")!>foo43(y)<!>
val x440 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IBar<in L> & IFoo<String>}")!>foo44(x)<!>
val x441 = <!DEBUG_INFO_EXPRESSION_TYPE("{IBar<L> & IBar<in L> & IFoo<String>}")!>foo44(y)<!>
val x450 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<Bar<L>>>")!>foo45(x)<!>
val x451 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<Bar<L>>>")!>foo45(y)<!>
val x460 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<OutBar<OutBar<L>>>")!>foo46(x)<!>
val x461 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<OutBar<OutBar<L>>>")!>foo46(y)<!>
val x470 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<OutBar<L!!>>>")!>foo47(x)<!>
val x471 = <!DEBUG_INFO_EXPRESSION_TYPE("OutBar<OutBar<OutBar<L!!>>>")!>foo47(y)<!>
fun <R> takeLambda(block: () -> R): R = materialize()
val x480 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!><!DEBUG_INFO_LEAKING_THIS!>takeLambda<!> { foo48 { <!TYPE_MISMATCH("Any", "L"), TYPE_MISMATCH("Any", "L")!>x<!> } }<!>
val x481 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<L>")!><!DEBUG_INFO_LEAKING_THIS!>takeLambda<!> { foo48 { <!TYPE_MISMATCH("Any", "L"), TYPE_MISMATCH("Any", "L")!>y<!> } }<!>
val x482 = <!DEBUG_INFO_EXPRESSION_TYPE("Bar<kotlin.Nothing>")!><!DEBUG_INFO_LEAKING_THIS!>takeLambda<!> { foo48 { null } }<!>
}
fun <T : Comparable<T>> nullsLast() = null as Foo<T?>
fun <K> take(x: Foo<K>, comparator: Foo<K>): Foo<K> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <L> test() {
<!DEBUG_INFO_EXPRESSION_TYPE("Foo<kotlin.String?>")!>take(null as Foo<String?>, <!DEBUG_INFO_EXPRESSION_TYPE("Foo<kotlin.String?>")!>nullsLast()<!>)<!>
}
class Inv1<T>
class Inv2<T>
fun <K : Comparable<K>> Inv1<K>.assertStableSorted() {}
fun <K : Comparable<K>> Inv2<K>.assertStableSorted() = Inv1<K>().assertStableSorted()
@@ -0,0 +1,243 @@
package
public val </*0*/ K> K?.vfoo0: Foo<Bar<K>>
public val </*0*/ K> K?.vfoo1: OutBar<Bar<out OutBar<K>>>
public val </*0*/ K> K?.vfoo2: OutBar<Bar<in OutBar<K>>>
public fun </*0*/ K> foo0(/*0*/ x: K?): Bar<K>
public fun </*0*/ K> foo1(/*0*/ x: K?): Foo<Bar<K>>
public fun </*0*/ T : J, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S, /*4*/ J : L, /*5*/ L> foo10(/*0*/ x: L?, /*1*/ y: Foo<Bar<T>>): Bar<M>
public fun </*0*/ T : J, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S, /*4*/ J : L, /*5*/ L> foo11(/*0*/ x: M?, /*1*/ y: Foo<Bar<T>>): Bar<L>
public fun </*0*/ K : kotlin.Any> foo12(/*0*/ x: K?): Bar<K>
public fun </*0*/ K : kotlin.Comparable<K>> foo14(/*0*/ x: K?): Bar<K> where K : kotlin.CharSequence
public fun </*0*/ K : T?, /*1*/ T> foo15(/*0*/ x: T): Bar<K>
public fun </*0*/ K : T?, /*1*/ T> foo16(/*0*/ x: K): Bar<T>
public fun </*0*/ K : T?, /*1*/ T> foo17(/*0*/ x: K): Bar<T>
public fun </*0*/ K> foo19(/*0*/ x: Bar<K>): K
public fun </*0*/ K, /*1*/ T : K> foo2(/*0*/ x: K?): Foo<Bar<T>>
public fun </*0*/ K> foo21(/*0*/ x: K?): Foo<Foo<OutBar<K>>>
public fun </*0*/ K> foo22(/*0*/ x: K?): Foo<Foo<InBar<K>>>
public fun </*0*/ K> foo23(/*0*/ x: K?): Foo<Foo<Bar<out K>>>
public fun </*0*/ K> foo24(/*0*/ x: K?): Foo<Foo<Bar<in K>>>
public fun </*0*/ K> foo25(/*0*/ x: K?): Bar<out K>
public fun </*0*/ K> foo26(/*0*/ x: K?): Foo<out Foo<out Bar<out K>>>
public fun </*0*/ K> foo27(/*0*/ x: K?): Foo<out Foo<Bar<out K>>>
public fun </*0*/ K> foo28(/*0*/ x: K?): OutBar<OutBar<OutBar<K>>>
public fun </*0*/ K> foo29(/*0*/ x: K?): OutBar<Bar<OutBar<K>>>
public fun </*0*/ T, /*1*/ K : T> foo3(/*0*/ x: K?): Foo<Bar<T>>
public fun </*0*/ K> foo30(/*0*/ x: K?): OutBar<Bar<out OutBar<K>>>
public fun </*0*/ K> foo31(/*0*/ x: K?): OutBarAliasUseSite<K> /* = Bar<out K> */
public fun </*0*/ K> foo32(/*0*/ x: K?): OutBarAliasDecSite<K> /* = OutBar<K> */
public fun </*0*/ K> foo33(/*0*/ x: K?): OutBar<InBar<OutBar<K>>>
public fun </*0*/ K> foo34(/*0*/ x: K?): OutBar<Bar<in OutBar<K>>>
public fun </*0*/ K> foo35(/*0*/ x: K?): InBar<K>
public fun </*0*/ K> foo36(/*0*/ x: K?): Bar<in K>
public fun </*0*/ K, /*1*/ T : Bar<K>> foo37(/*0*/ x: K?): T
public fun </*0*/ K, /*1*/ T : Bar<S>, /*2*/ S : Bar<K>> foo38(/*0*/ x: K?): T
public fun </*0*/ K, /*1*/ T : Bar<S>, /*2*/ S : Bar<K>> foo39(/*0*/ x: K?): Bar<T>
public fun </*0*/ K> foo4(/*0*/ x: K?): Foo<Bar<out K>>
public fun </*0*/ K, /*1*/ T : Bar<K>> foo40(/*0*/ x: K?): Bar<T>
public fun </*0*/ K, /*1*/ T : Bar<K>> foo41(/*0*/ x: K?): T
public fun </*0*/ K, /*1*/ S : K, /*2*/ T : IFoo<S>> foo42(/*0*/ x: K?): T
public fun </*0*/ K, /*1*/ S : K, /*2*/ T : IBar<S>> foo43(/*0*/ x: K?): T where T : IFoo<S>
public fun </*0*/ K, /*1*/ S : IFoo<kotlin.String>, /*2*/ T : S> foo44(/*0*/ x: K?): T where S : IBar<K>
public fun </*0*/ K, /*1*/ T : OutBar<S>, /*2*/ S : Bar<K>> foo45(/*0*/ x: K?): OutBar<T>
public fun </*0*/ K, /*1*/ T : OutBar<S>, /*2*/ S : OutBar<K>> foo46(/*0*/ x: K?): Bar<T>
public fun </*0*/ K, /*1*/ T : OutBar<S>, /*2*/ S : OutBar<K>> foo47(/*0*/ x: K?): OutBar<T>
public fun </*0*/ U : kotlin.Any> foo48(/*0*/ fn: () -> U?): Bar<U>
public fun </*0*/ K> foo5(/*0*/ x: K?): Bar<in K>
public fun </*0*/ K> foo6(/*0*/ x: K?): OutBar<K>
public fun </*0*/ K> foo7(/*0*/ x: K?): InBar<K>
public fun </*0*/ T, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S> foo8(/*0*/ x: T?): Foo<Bar<M>>
public fun </*0*/ T, /*1*/ K : T, /*2*/ S : K, /*3*/ M : S> foo9(/*0*/ x: M?): Foo<Bar<T>>
public fun </*0*/ T> materialize(): T
public fun </*0*/ T : kotlin.Comparable<T>> nullsLast(): Foo<T?>
public fun </*0*/ K> take(/*0*/ x: Foo<K>, /*1*/ comparator: Foo<K>): Foo<K>
public fun </*0*/ L> test(): kotlin.Unit
public fun </*0*/ K : kotlin.Comparable<K>> Inv1<K>.assertStableSorted(): kotlin.Unit
public fun </*0*/ K : kotlin.Comparable<K>> Inv2<K>.assertStableSorted(): kotlin.Unit
public fun </*0*/ K> Bar<K>.foo20(): K
public final class Bar</*0*/ S> {
public constructor Bar</*0*/ S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo</*0*/ T> {
public constructor Foo</*0*/ T>(/*0*/ x: T)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Foo13</*0*/ T> {
public constructor Foo13</*0*/ T>(/*0*/ x: T)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun </*0*/ K : T> foo1(/*0*/ x: K?): Bar<T>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface IBar</*0*/ S> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface IFoo</*0*/ S> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class InBar</*0*/ in S> {
public constructor InBar</*0*/ in S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Inv1</*0*/ T> {
public constructor Inv1</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Inv2</*0*/ T> {
public constructor Inv2</*0*/ T>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Main</*0*/ L> {
public constructor Main</*0*/ L>(/*0*/ x: L?, /*1*/ y: L)
public final val vx01: Foo<Bar<L>>
public final val vx02: Foo<Bar<L>>
public final val vx11: OutBar<Bar<out OutBar<L>>>
public final val vx12: OutBar<Bar<out OutBar<L>>>
public final val vx21: OutBar<Bar<in OutBar<L>>>
public final val vx22: OutBar<Bar<in OutBar<L>>>
public final val x00: Bar<L>
public final val x01: Bar<L>
public final val x10: Foo<Bar<L>>
public final val x100: Bar<L>
public final val x101: Bar<L>
public final val x11: Foo<Bar<L>>
public final val x110: Bar<L>
public final val x111: Bar<L>
public final val x12: Foo<out Bar<out L>>
public final val x120: Bar<out L>
public final val x121: Bar<out L>
public final val x122: Bar<L>
public final val x123: Bar<L>
public final val x13: Foo<out Bar<out L>>
public final val x133: Bar<L?>
public final val x135: Bar<L>
public final val x137: Bar<L>
public final val x138: Bar<L?>
public final val x140: Bar<kotlin.String>
public final val x141: Bar<kotlin.String>
public final val x151: Bar<L?>
public final val x152: Bar<L?>
public final val x153: Bar<L?>
public final val x154: Bar<L?>
public final val x161: Bar<L>
public final val x162: Bar<L>
public final val x163: Bar<out L>
public final val x164: Bar<out L>
public final val x170: Bar<L>
public final val x171: Bar<L>
public final val x180: [ERROR : <ERROR FUNCTION RETURN TYPE>]
public final val x181: [ERROR : <ERROR FUNCTION RETURN TYPE>]
public final val x20: Foo<Bar<L>>
public final val x200: L
public final val x201: L
public final val x21: Foo<Bar<L>>
public final val x210: Foo<Foo<OutBar<L>>>
public final val x211: Foo<Foo<OutBar<L>>>
public final val x220: Foo<Foo<InBar<L>>>
public final val x221: Foo<Foo<InBar<L>>>
public final val x230: Foo<Foo<Bar<out L>>>
public final val x231: Foo<Foo<Bar<out L>>>
public final val x240: Foo<Foo<Bar<in L>>>
public final val x241: Foo<Foo<Bar<in L>>>
public final val x250: Bar<out L>
public final val x251: Bar<out L>
public final val x260: Foo<out Foo<out Bar<out L>>>
public final val x261: Foo<out Foo<out Bar<out L>>>
public final val x270: Foo<out Foo<Bar<out L>>>
public final val x271: Foo<out Foo<Bar<out L>>>
public final val x280: OutBar<OutBar<OutBar<L>>>
public final val x281: OutBar<OutBar<OutBar<L>>>
public final val x290: OutBar<Bar<OutBar<L>>>
public final val x291: OutBar<Bar<OutBar<L>>>
public final val x30: Foo<Bar<L>>
public final val x300: OutBar<Bar<out OutBar<L>>>
public final val x301: OutBar<Bar<out OutBar<L>>>
public final val x31: Foo<Bar<L>>
public final val x310: Bar<out L>
public final val x311: Bar<out L>
public final val x320: OutBar<L>
public final val x321: OutBar<L>
public final val x330: OutBar<InBar<OutBar<L>>>
public final val x331: OutBar<InBar<OutBar<L>>>
public final val x340: OutBar<Bar<in OutBar<L>>>
public final val x341: OutBar<Bar<in OutBar<L>>>
public final val x350: InBar<L>
public final val x351: InBar<L>
public final val x360: Bar<in L>
public final val x361: Bar<in L>
public final val x370: Bar<L>
public final val x371: Bar<L>
public final val x380: Bar<Bar<L>>
public final val x381: Bar<Bar<L>>
public final val x390: Bar<Bar<Bar<L>>>
public final val x391: Bar<Bar<Bar<L>>>
public final val x40: Foo<Bar<out L>>
public final val x400: Bar<Bar<L>>
public final val x401: Bar<Bar<L>>
public final val x41: Foo<Bar<out L>>
public final val x410: Bar<L>
public final val x411: Bar<L>
public final val x420: IFoo<L>
public final val x421: IFoo<L>
public final val x430: kotlin.Any
public final val x431: kotlin.Any
public final val x440: kotlin.Any
public final val x441: kotlin.Any
public final val x450: OutBar<OutBar<Bar<L>>>
public final val x451: OutBar<OutBar<Bar<L>>>
public final val x460: Bar<OutBar<OutBar<L>>>
public final val x461: Bar<OutBar<OutBar<L>>>
public final val x470: OutBar<OutBar<OutBar<L>>>
public final val x471: OutBar<OutBar<OutBar<L>>>
public final val x480: Bar<L>
public final val x481: Bar<L>
public final val x482: Bar<kotlin.Nothing>
public final val x50: Bar<in L>
public final val x51: Bar<in L>
public final val x60: OutBar<L>
public final val x61: OutBar<L>
public final val x70: InBar<L>
public final val x71: InBar<L>
public final val x80: Foo<Bar<L>>
public final val x81: Foo<Bar<L>>
public final val x90: Foo<Bar<L>>
public final val x91: Foo<Bar<L>>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun </*0*/ R> takeLambda(/*0*/ block: () -> R): R
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class OutBar</*0*/ out S> {
public constructor OutBar</*0*/ out S>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias OutBarAliasDecSite</*0*/ T> = OutBar<T>
public typealias OutBarAliasUseSite</*0*/ T> = Bar<out T>
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -UNUSED_VARIABLE
class Inv<T>(val x: T?)
@@ -21,4 +21,4 @@ fun <S> test(i: Int, s: S) {
c
takeInvInt(create(i))
}
}
@@ -1,8 +1,8 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -UNUSED_VARIABLE
class Inv<T>(val x: T?)
fun <K> create(y: K) = Inv(y)
fun <K> create(y: K) = <!DEBUG_INFO_EXPRESSION_TYPE("Inv<K>")!>Inv(y)<!>
fun <K> createPrivate(y: K) = Inv(y)
fun takeInvInt(i: Inv<Int>) {}
@@ -21,4 +21,4 @@ fun <S> test(i: Int, s: S) {
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<kotlin.Int>")!>c<!>
takeInvInt(create(i))
}
}
@@ -1,4 +1,12 @@
fun <S : Any> foo(x: Array<out S?>, y: Array<in S?>) {
fun <S : Any> foo1(x: Array<out S?>, y: Array<in S?>) {
val xo = outANullable(x)
val yo = inANullable(y)
var f: Array<S> = xo
f = yo
}
fun <S : Any> foo2(x: Array<out S>, y: Array<in S>) {
val xo = outA(x)
val yo = inA(y)
@@ -6,6 +14,18 @@ fun <S : Any> foo(x: Array<out S?>, y: Array<in S?>) {
f = yo
}
class A1<S : Any>(x: Array<out S?>, y: Array<in S?>) {
val xo = outANullable(x)
val yo = inANullable(y)
}
fun <X : Any> outA(x: Array<out X?>): Array<X> = TODO()
fun <Y : Any> inA(x: Array<in Y?>): Array<Y> = TODO()
class A2<S : Any>(x: Array<out S>, y: Array<in S>) {
val xo = outA(x)
val yo = inA(y)
}
fun <X : Any> outANullable(x: Array<out X?>): Array<X> = TODO()
fun <Y : Any> inANullable(x: Array<in Y?>): Array<Y> = TODO()
fun <X : Any> outA(x: Array<out X>): Array<X> = TODO()
fun <Y : Any> inA(x: Array<in Y>): Array<Y> = TODO()
@@ -1,11 +1,31 @@
fun <S : Any> foo(x: Array<out S?>, y: Array<in S?>) {
val xo = outA(x)
val yo = inA(y)
fun <S : Any> foo1(x: Array<out S?>, y: Array<in S?>) {
val xo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>outANullable(x)<!>
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inANullable(y)<!>
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>f<!>: Array<S> = xo
<!UNUSED_VALUE!>f =<!> yo
}
fun <S : Any> foo2(x: Array<out S>, y: Array<in S>) {
val xo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>outA(x)<!>
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inA(y)<!>
fun <X : Any> outA(<!UNUSED_PARAMETER!>x<!>: Array<out X?>): Array<X> = TODO()
fun <Y : Any> inA(<!UNUSED_PARAMETER!>x<!>: Array<in Y?>): Array<Y> = TODO()
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>f<!>: Array<S> = xo
<!UNUSED_VALUE!>f =<!> yo
}
class A1<S : Any>(x: Array<out S?>, y: Array<in S?>) {
val xo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>outANullable(x)<!>
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inANullable(y)<!>
}
class A2<S : Any>(x: Array<out S>, y: Array<in S>) {
val xo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>outA(x)<!>
val yo = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Array<S>")!>inA(y)<!>
}
fun <X : Any> outANullable(<!UNUSED_PARAMETER!>x<!>: Array<out X?>): Array<X> = TODO()
fun <Y : Any> inANullable(<!UNUSED_PARAMETER!>x<!>: Array<in Y?>): Array<Y> = TODO()
fun <X : Any> outA(<!UNUSED_PARAMETER!>x<!>: Array<out X>): Array<X> = TODO()
fun <Y : Any> inA(<!UNUSED_PARAMETER!>x<!>: Array<in Y>): Array<Y> = TODO()
@@ -1,5 +1,26 @@
package
public fun </*0*/ S : kotlin.Any> foo(/*0*/ x: kotlin.Array<out S?>, /*1*/ y: kotlin.Array<in S?>): kotlin.Unit
public fun </*0*/ Y : kotlin.Any> inA(/*0*/ x: kotlin.Array<in Y?>): kotlin.Array<Y>
public fun </*0*/ X : kotlin.Any> outA(/*0*/ x: kotlin.Array<out X?>): kotlin.Array<X>
public fun </*0*/ S : kotlin.Any> foo1(/*0*/ x: kotlin.Array<out S?>, /*1*/ y: kotlin.Array<in S?>): kotlin.Unit
public fun </*0*/ S : kotlin.Any> foo2(/*0*/ x: kotlin.Array<out S>, /*1*/ y: kotlin.Array<in S>): kotlin.Unit
public fun </*0*/ Y : kotlin.Any> inA(/*0*/ x: kotlin.Array<in Y>): kotlin.Array<Y>
public fun </*0*/ Y : kotlin.Any> inANullable(/*0*/ x: kotlin.Array<in Y?>): kotlin.Array<Y>
public fun </*0*/ X : kotlin.Any> outA(/*0*/ x: kotlin.Array<out X>): kotlin.Array<X>
public fun </*0*/ X : kotlin.Any> outANullable(/*0*/ x: kotlin.Array<out X?>): kotlin.Array<X>
public final class A1</*0*/ S : kotlin.Any> {
public constructor A1</*0*/ S : kotlin.Any>(/*0*/ x: kotlin.Array<out S?>, /*1*/ y: kotlin.Array<in S?>)
public final val xo: kotlin.Array<S>
public final val yo: kotlin.Array<S>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class A2</*0*/ S : kotlin.Any> {
public constructor A2</*0*/ S : kotlin.Any>(/*0*/ x: kotlin.Array<out S>, /*1*/ y: kotlin.Array<in S>)
public final val xo: kotlin.Array<S>
public final val yo: kotlin.Array<S>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -169,8 +169,8 @@ fun <T> case_11(y: T) {
<!DEBUG_INFO_EXPRESSION_TYPE("(T!!..T?)")!>x3<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T & T!!")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<T>")!>result_1<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(T..T?)>")!>result_2<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<out (T..T?)>")!>result_1<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<out T?>")!>result_2<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(T!!..T?)>")!>result_3<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<T>")!>result_4<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(T..T?)>")!>result_5<!>
@@ -10732,6 +10732,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/inference/constraints/constraintOnFunctionLiteral.kt");
}
@TestMetadata("definitelyNotNullTypeInArguments.kt")
public void testDefinitelyNotNullTypeInArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInArguments.kt");
}
@TestMetadata("definitelyNotNullTypeInReturnPosition.kt")
public void testDefinitelyNotNullTypeInReturnPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.kt");
}
@TestMetadata("definitelyNotNullTypeInvariantPosition.kt")
public void testDefinitelyNotNullTypeInvariantPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInvariantPosition.kt");
@@ -10727,6 +10727,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/inference/constraints/constraintOnFunctionLiteral.kt");
}
@TestMetadata("definitelyNotNullTypeInArguments.kt")
public void testDefinitelyNotNullTypeInArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInArguments.kt");
}
@TestMetadata("definitelyNotNullTypeInReturnPosition.kt")
public void testDefinitelyNotNullTypeInReturnPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInReturnPosition.kt");
}
@TestMetadata("definitelyNotNullTypeInvariantPosition.kt")
public void testDefinitelyNotNullTypeInvariantPosition() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/definitelyNotNullTypeInvariantPosition.kt");
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
import org.jetbrains.kotlin.types.checker.NewCapturedType
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
import org.jetbrains.kotlin.types.checker.NullabilityChecker
import org.jetbrains.kotlin.types.model.DefinitelyNotNullTypeMarker
@@ -150,6 +151,9 @@ fun SimpleType.makeSimpleTypeDefinitelyNotNullOrNotNull(): SimpleType =
?: makeIntersectionTypeDefinitelyNotNullOrNotNull()
?: makeNullableAsSpecified(false)
fun NewCapturedType.withNotNullProjection() =
NewCapturedType(captureStatus, constructor, lowerType, annotations, isMarkedNullable, isProjectionNotNull = true)
fun UnwrappedType.makeDefinitelyNotNullOrNotNull(): UnwrappedType =
DefinitelyNotNullType.makeDefinitelyNotNull(this)
?: makeIntersectionTypeDefinitelyNotNullOrNotNull()
@@ -405,6 +405,17 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
return this.constructor.projection
}
override fun CapturedTypeMarker.withNotNullProjection(): KotlinTypeMarker {
require(this is NewCapturedType, this::errorMessage)
return NewCapturedType(captureStatus, constructor, lowerType, annotations, isMarkedNullable, isProjectionNotNull = true)
}
override fun CapturedTypeMarker.isProjectionNotNull(): Boolean {
require(this is NewCapturedType, this::errorMessage)
return this.isProjectionNotNull
}
override fun CapturedTypeMarker.typeParameter(): TypeParameterMarker? {
require(this is NewCapturedType, this::errorMessage)
return this.constructor.typeParameter
@@ -94,7 +94,9 @@ object TypeIntersector {
* and other types is captured types or type parameters without not-null upper bound. Example: `String? & T` such types we should leave as is.
*/
val correctNullability = inputTypes.mapTo(LinkedHashSet()) {
if (resultNullability == ResultNullability.NOT_NULL) it.makeSimpleTypeDefinitelyNotNullOrNotNull() else it
if (resultNullability == ResultNullability.NOT_NULL) {
(if (it is NewCapturedType) it.withNotNullProjection() else it).makeSimpleTypeDefinitelyNotNullOrNotNull()
} else it
}
return intersectTypesWithoutIntersectionType(correctNullability)
@@ -110,7 +110,8 @@ class NewCapturedType(
override val constructor: NewCapturedTypeConstructor,
val lowerType: UnwrappedType?, // todo check lower type for nullable captured types
override val annotations: Annotations = Annotations.EMPTY,
override val isMarkedNullable: Boolean = false
override val isMarkedNullable: Boolean = false,
val isProjectionNotNull: Boolean = false
) : SimpleType(), CapturedTypeMarker {
internal constructor(
captureStatus: CaptureStatus, lowerType: UnwrappedType?, projection: TypeProjection, typeParameter: TypeParameterDescriptor
@@ -508,6 +508,9 @@ object AbstractNullabilityChecker {
// i.e. subType is definitely not null
if (subType.isDefinitelyNotNullType()) return true
// i.e. subType is captured type, projection of which is marked not-null
if (subType is CapturedTypeMarker && subType.isProjectionNotNull()) return true
// i.e. subType is not-nullable
if (hasNotNullSupertype(subType, SupertypesPolicy.LowerIfFlexible)) return true
@@ -154,6 +154,7 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
fun CapturedTypeMarker.typeConstructorProjection(): TypeArgumentMarker
fun CapturedTypeMarker.typeParameter(): TypeParameterMarker?
fun CapturedTypeMarker.withNotNullProjection(): KotlinTypeMarker
fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker
@@ -200,6 +201,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
fun CapturedTypeMarker.typeConstructor(): CapturedTypeConstructorMarker
fun CapturedTypeMarker.captureStatus(): CaptureStatus
fun CapturedTypeMarker.isProjectionNotNull(): Boolean
fun CapturedTypeConstructorMarker.projection(): TypeArgumentMarker
fun KotlinTypeMarker.argumentsCount(): Int