From 124a14c8dfb6a9a5e25f7386d4be854db96d5dd1 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 2 Jun 2021 12:16:22 +0300 Subject: [PATCH] Use separate constraint position during call substitution as part of inferring postponed type variables ^KT-47052 Fixed ^KT-47082 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 + .../runners/ir/Fir2IrTextTestGenerated.java | 6 + .../DiagnosticReporterByTrackingStrategy.kt | 155 +++++++++--------- .../inference/BuilderInferenceSession.kt | 30 +++- .../model/ConstraintPositionAndErrors.kt | 6 + .../model/ConstraintPositionAndErrorsImpl.kt | 6 + .../box/inference/builderInference/kt47052.kt | 12 ++ .../testData/ir/irText/expressions/kt47082.kt | 18 ++ .../ir/irText/expressions/kt47082.kt.txt | 30 ++++ .../ir/irText/expressions/kt47082.txt | 88 ++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + .../test/runners/ir/IrTextTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + .../IrJsCodegenBoxES6TestGenerated.java | 5 + .../IrJsCodegenBoxTestGenerated.java | 5 + .../semantics/JsCodegenBoxTestGenerated.java | 5 + 17 files changed, 314 insertions(+), 81 deletions(-) create mode 100644 compiler/testData/codegen/box/inference/builderInference/kt47052.kt create mode 100644 compiler/testData/ir/irText/expressions/kt47082.kt create mode 100644 compiler/testData/ir/irText/expressions/kt47082.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/kt47082.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index e696c30ccb8..4230355d0c6 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -17665,6 +17665,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @Test + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @Test @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 31b8a84a015..7161265a47e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -1400,6 +1400,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); } + @Test + @TestMetadata("kt47082.kt") + public void testKt47082() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt47082.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index e15a2c071f6..ea4b8224f7d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -344,84 +344,91 @@ class DiagnosticReporterByTrackingStrategy( ) } + private fun reportConstraintErrorByPosition(error: NewConstraintError, position: ConstraintPosition) { + val argument = when (position) { + is ArgumentConstraintPositionImpl -> position.argument + is ReceiverConstraintPositionImpl -> position.argument + is LHSArgumentConstraintPositionImpl -> position.argument + is LambdaArgumentConstraintPositionImpl -> position.lambda.atom + else -> null + } + val typeMismatchDiagnostic = if (error.isWarning) TYPE_MISMATCH_WARNING else TYPE_MISMATCH + val report = if (error.isWarning) trace::reportDiagnosticOnce else trace::report + + argument?.let { + it.safeAs()?.let lambda@{ lambda -> + val parameterTypes = lambda.parametersTypes?.toList() ?: return@lambda + val index = parameterTypes.indexOf(error.upperKotlinType.unwrap()) + val lambdaExpression = lambda.psiExpression as? KtLambdaExpression ?: return@lambda + val parameter = lambdaExpression.valueParameters.getOrNull(index) ?: return@lambda + val diagnosticFactory = + if (error.isWarning) EXPECTED_PARAMETER_TYPE_MISMATCH_WARNING else EXPECTED_PARAMETER_TYPE_MISMATCH + report(diagnosticFactory.on(parameter, error.upperKotlinType)) + return + } + + val expression = it.psiExpression ?: return + val deparenthesized = KtPsiUtil.safeDeparenthesize(expression) + if (reportConstantTypeMismatch(error, deparenthesized)) return + + val compileTimeConstant = trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized] as? TypedCompileTimeConstant + if (compileTimeConstant != null) { + val expressionType = trace[BindingContext.EXPRESSION_TYPE_INFO, expression]?.type + if (expressionType != null && + !UnsignedTypes.isUnsignedType(compileTimeConstant.type) && UnsignedTypes.isUnsignedType(expressionType) + ) { + return + } + } + report(typeMismatchDiagnostic.on(deparenthesized, error.upperKotlinType, error.lowerKotlinType)) + } + + (position as? ExpectedTypeConstraintPositionImpl)?.let { + val call = it.topLevelCall.psiKotlinCall.psiCall.callElement.safeAs() + val inferredType = + if (!error.lowerKotlinType.isNullableNothing()) error.lowerKotlinType + else error.upperKotlinType.makeNullable() + if (call != null) { + report(typeMismatchDiagnostic.on(call, error.upperKotlinType, inferredType)) + } + } + + (position as? BuilderInferenceExpectedTypeConstraintPosition)?.let { + val inferredType = + if (!error.lowerKotlinType.isNullableNothing()) error.lowerKotlinType + else error.upperKotlinType.makeNullable() + trace.report(TYPE_MISMATCH.on(it.topLevelCall, error.upperKotlinType, inferredType)) + } + + (position as? BuilderInferenceSubstitutionConstraintPositionImpl)?.let { + reportConstraintErrorByPosition(error, it.initialConstraint.position) + } + + (position as? ExplicitTypeParameterConstraintPositionImpl)?.let { + val typeArgumentReference = (it.typeArgument as SimpleTypeArgumentImpl).typeReference + val diagnosticFactory = if (error.isWarning) UPPER_BOUND_VIOLATED_WARNING else UPPER_BOUND_VIOLATED + report(diagnosticFactory.on(typeArgumentReference, error.upperKotlinType, error.lowerKotlinType)) + } + + (position as? FixVariableConstraintPositionImpl)?.let { + val morePreciseDiagnosticExists = allDiagnostics.any { other -> + val otherError = other.constraintSystemError ?: return@any false + otherError is NewConstraintError && otherError.position.from !is FixVariableConstraintPositionImpl + } + if (morePreciseDiagnosticExists) return + + val call = it.resolvedAtom?.atom?.safeAs()?.psiCall ?: call + val expression = call.calleeExpression ?: return + + trace.reportDiagnosticOnce(typeMismatchDiagnostic.on(expression, error.upperKotlinType, error.lowerKotlinType)) + } + } + override fun constraintError(error: ConstraintSystemError) { when (error.javaClass) { NewConstraintError::class.java -> { error as NewConstraintError - val position = error.position.from - val argument = - when (position) { - is ArgumentConstraintPositionImpl -> position.argument - is ReceiverConstraintPositionImpl -> position.argument - is LHSArgumentConstraintPositionImpl -> position.argument - is LambdaArgumentConstraintPositionImpl -> position.lambda.atom - else -> null - } - val typeMismatchDiagnostic = if (error.isWarning) TYPE_MISMATCH_WARNING else TYPE_MISMATCH - val report = if (error.isWarning) trace::reportDiagnosticOnce else trace::report - argument?.let { - it.safeAs()?.let lambda@{ lambda -> - val parameterTypes = lambda.parametersTypes?.toList() ?: return@lambda - val index = parameterTypes.indexOf(error.upperKotlinType.unwrap()) - val lambdaExpression = lambda.psiExpression as? KtLambdaExpression ?: return@lambda - val parameter = lambdaExpression.valueParameters.getOrNull(index) ?: return@lambda - val diagnosticFactory = - if (error.isWarning) EXPECTED_PARAMETER_TYPE_MISMATCH_WARNING else EXPECTED_PARAMETER_TYPE_MISMATCH - report(diagnosticFactory.on(parameter, error.upperKotlinType)) - return - } - - val expression = it.psiExpression ?: return - val deparenthesized = KtPsiUtil.safeDeparenthesize(expression) - if (reportConstantTypeMismatch(error, deparenthesized)) return - - val compileTimeConstant = trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized] as? TypedCompileTimeConstant - if (compileTimeConstant != null) { - val expressionType = trace[BindingContext.EXPRESSION_TYPE_INFO, expression]?.type - if (expressionType != null && - !UnsignedTypes.isUnsignedType(compileTimeConstant.type) && UnsignedTypes.isUnsignedType(expressionType) - ) { - return - } - } - report(typeMismatchDiagnostic.on(deparenthesized, error.upperKotlinType, error.lowerKotlinType)) - } - - (position as? ExpectedTypeConstraintPositionImpl)?.let { - val call = it.topLevelCall.psiKotlinCall.psiCall.callElement.safeAs() - val inferredType = - if (!error.lowerKotlinType.isNullableNothing()) error.lowerKotlinType - else error.upperKotlinType.makeNullable() - if (call != null) { - report(typeMismatchDiagnostic.on(call, error.upperKotlinType, inferredType)) - } - } - - (position as? BuilderInferenceExpectedTypeConstraintPosition)?.let { - val inferredType = - if (!error.lowerKotlinType.isNullableNothing()) error.lowerKotlinType - else error.upperKotlinType.makeNullable() - trace.report(TYPE_MISMATCH.on(it.topLevelCall, error.upperKotlinType, inferredType)) - } - - (position as? ExplicitTypeParameterConstraintPositionImpl)?.let { - val typeArgumentReference = (it.typeArgument as SimpleTypeArgumentImpl).typeReference - val diagnosticFactory = if (error.isWarning) UPPER_BOUND_VIOLATED_WARNING else UPPER_BOUND_VIOLATED - report(diagnosticFactory.on(typeArgumentReference, error.upperKotlinType, error.lowerKotlinType)) - } - - (position as? FixVariableConstraintPositionImpl)?.let { - val morePreciseDiagnosticExists = allDiagnostics.any { other -> - val otherError = other.constraintSystemError ?: return@any false - otherError is NewConstraintError && otherError.position.from !is FixVariableConstraintPositionImpl - } - if (morePreciseDiagnosticExists) return - - val call = it.resolvedAtom?.atom?.safeAs()?.psiCall ?: call - val expression = call.calleeExpression ?: return - - trace.reportDiagnosticOnce(typeMismatchDiagnostic.on(expression, error.upperKotlinType, error.lowerKotlinType)) - } + reportConstraintErrorByPosition(error, error.position.from) } CapturedTypeFromSubtyping::class.java -> { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt index 57eae9bf3d4..c2bbd8fa71d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt @@ -329,22 +329,24 @@ class BuilderInferenceSession( val callSubstitutor = storage.buildResultingSubstitutor(commonSystem, transformTypeVariablesToErrorTypes = false) for (initialConstraint in storage.initialConstraints) { - val lowerCallSubstituted = callSubstitutor.safeSubstitute(initialConstraint.a as UnwrappedType) - val upperCallSubstituted = callSubstitutor.safeSubstitute(initialConstraint.b as UnwrappedType) - - val (lower, upper) = substituteNotFixedVariables(lowerCallSubstituted, upperCallSubstituted, nonFixedToVariablesSubstitutor) + val substitutedConstraint = initialConstraint.substitute(callSubstitutor) + val (lower, upper) = substituteNotFixedVariables( + substitutedConstraint.a as KotlinType, + substitutedConstraint.b as KotlinType, + nonFixedToVariablesSubstitutor + ) if (commonSystem.isProperType(lower) && commonSystem.isProperType(upper)) continue when (initialConstraint.constraintKind) { ConstraintKind.LOWER -> error("LOWER constraint shouldn't be used, please use UPPER") - ConstraintKind.UPPER -> commonSystem.addSubtypeConstraint(lower, upper, initialConstraint.position) + ConstraintKind.UPPER -> commonSystem.addSubtypeConstraint(lower, upper, substitutedConstraint.position) ConstraintKind.EQUALITY -> with(commonSystem) { - addSubtypeConstraint(lower, upper, initialConstraint.position) - addSubtypeConstraint(upper, lower, initialConstraint.position) + addSubtypeConstraint(lower, upper, substitutedConstraint.position) + addSubtypeConstraint(upper, lower, substitutedConstraint.position) } } } @@ -542,6 +544,20 @@ class BuilderInferenceSession( } } + private fun InitialConstraint.substitute(substitutor: NewTypeSubstitutor): InitialConstraint { + val lowerSubstituted = substitutor.safeSubstitute(a as UnwrappedType) + val upperSubstituted = substitutor.safeSubstitute(b as UnwrappedType) + + if (lowerSubstituted == a && upperSubstituted == b) return this + + return InitialConstraint( + lowerSubstituted, + upperSubstituted, + constraintKind, + BuilderInferenceSubstitutionConstraintPositionImpl(lambdaArgument, this) + ) + } + companion object { private fun BuilderInferenceSession.updateCalls( lambda: ResolvedLambdaAtom, diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt index e242e7c734c..9b37837c67e 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrors.kt @@ -23,6 +23,12 @@ abstract class InjectedAnotherStubTypeConstraintPosition(private val builderI override fun toString(): String = "Injected from $builderInferenceLambdaOfInjectedStubType builder inference call" } +abstract class BuilderInferenceSubstitutionConstraintPosition(private val builderInferenceLambda: L, val initialConstraint: I) : + ConstraintPosition(), OnlyInputTypeConstraintPosition { + override fun toString(): String = "Incorporated builder inference constraint $initialConstraint " + + "into $builderInferenceLambda call" +} + abstract class ExpectedTypeConstraintPosition(val topLevelCall: T) : ConstraintPosition(), OnlyInputTypeConstraintPosition { override fun toString(): String = "ExpectedType for call $topLevelCall" } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrorsImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrorsImpl.kt index 07cdbaa2917..721314f16d6 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrorsImpl.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/ConstraintPositionAndErrorsImpl.kt @@ -18,6 +18,12 @@ class ExplicitTypeParameterConstraintPositionImpl( class InjectedAnotherStubTypeConstraintPositionImpl(builderInferenceLambdaOfInjectedStubType: LambdaKotlinCallArgument) : InjectedAnotherStubTypeConstraintPosition(builderInferenceLambdaOfInjectedStubType) +class BuilderInferenceSubstitutionConstraintPositionImpl( + builderInferenceLambda: LambdaKotlinCallArgument, initialConstraint: InitialConstraint +) : BuilderInferenceSubstitutionConstraintPosition( + builderInferenceLambda, initialConstraint +) + class ExpectedTypeConstraintPositionImpl(topLevelCall: KotlinCall) : ExpectedTypeConstraintPosition(topLevelCall) class DeclaredUpperBoundConstraintPositionImpl( diff --git a/compiler/testData/codegen/box/inference/builderInference/kt47052.kt b/compiler/testData/codegen/box/inference/builderInference/kt47052.kt new file mode 100644 index 00000000000..d4debffc63e --- /dev/null +++ b/compiler/testData/codegen/box/inference/builderInference/kt47052.kt @@ -0,0 +1,12 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WITH_RUNTIME + +public inline fun > flatMapTo1(destination: C, transform: (List) -> Iterable) {} + +@OptIn(ExperimentalStdlibApi::class) +fun box(): String { + buildSet { // NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER is reported + flatMapTo1(this) { it } + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/kt47082.kt b/compiler/testData/ir/irText/expressions/kt47082.kt new file mode 100644 index 00000000000..7b4c5ff1f48 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt47082.kt @@ -0,0 +1,18 @@ +// WITH_RUNTIME +// !USE_EXPERIMENTAL: kotlin.experimental.ExperimentalTypeInference + +import kotlin.experimental.ExperimentalTypeInference + +fun produce(@BuilderInference block: Derived.() -> Unit): E = null as E + +interface Derived : Base + +interface Base + +interface Receiver + +fun > Receiver.toChannel(destination: C): C = null as C + +fun foo(r: Receiver): R = produce { r.toChannel(this) } + +fun box() = "OK" diff --git a/compiler/testData/ir/irText/expressions/kt47082.kt.txt b/compiler/testData/ir/irText/expressions/kt47082.kt.txt new file mode 100644 index 00000000000..54f5d73be76 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt47082.kt.txt @@ -0,0 +1,30 @@ +fun produce(@BuilderInference block: @ExtensionFunctionType Function1, Unit>): E { + return null as E +} + +interface Derived : Base { + +} + +interface Base { + +} + +interface Receiver { + +} + +fun > Receiver.toChannel(destination: C): C { + return null as C +} + +fun foo(r: Receiver): R { + return produce(block = local fun Derived.() { + r.toChannel>(destination = $this$produce) /*~> Unit */ + } +) +} + +fun box(): String { + return "OK" +} diff --git a/compiler/testData/ir/irText/expressions/kt47082.txt b/compiler/testData/ir/irText/expressions/kt47082.txt new file mode 100644 index 00000000000..50eaf4b5375 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt47082.txt @@ -0,0 +1,88 @@ +FILE fqName: fileName:/kt47082.kt + FUN name:produce visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.Function1<.Derived.produce>, kotlin.Unit>) returnType:E of .produce + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.Function1<.Derived.produce>, kotlin.Unit> + annotations: + BuilderInference + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun produce (block: @[ExtensionFunctionType] kotlin.Function1<.Derived.produce>, kotlin.Unit>): E of .produce declared in ' + TYPE_OP type=E of .produce origin=CAST typeOperand=E of .produce + CONST Null type=kotlin.Nothing? value=null + CLASS INTERFACE name:Derived modality:ABSTRACT visibility:public superTypes:[.Base.Derived>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived.Derived> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Base + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base.Base> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Receiver modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Receiver.Receiver> + TYPE_PARAMETER name:E index:0 variance:out superTypes:[kotlin.Any?] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:toChannel visibility:public modality:FINAL ($receiver:.Receiver.toChannel>, destination:C of .toChannel) returnType:C of .toChannel + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:C index:1 variance: superTypes:[.Base.toChannel>] + $receiver: VALUE_PARAMETER name: type:.Receiver.toChannel> + VALUE_PARAMETER name:destination index:0 type:C of .toChannel + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun toChannel (destination: C of .toChannel): C of .toChannel declared in ' + TYPE_OP type=C of .toChannel origin=CAST typeOperand=C of .toChannel + CONST Null type=kotlin.Nothing? value=null + FUN name:foo visibility:public modality:FINAL (r:.Receiver.foo>) returnType:R of .foo + TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:r index:0 type:.Receiver.foo> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (r: .Receiver.foo>): R of .foo declared in ' + CALL 'public final fun produce (block: @[ExtensionFunctionType] kotlin.Function1<.Derived.produce>, kotlin.Unit>): E of .produce declared in ' type=R of .foo origin=null + : R of .foo + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Derived.foo>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Derived.foo>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$produce type:.Derived.foo> + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun toChannel (destination: C of .toChannel): C of .toChannel declared in ' type=.Derived.foo> origin=null + : R of .foo + : .Derived.foo> + $receiver: GET_VAR 'r: .Receiver.foo> declared in .foo' type=.Receiver.foo> origin=null + destination: GET_VAR '$this$produce: .Derived.foo> declared in .foo.' type=.Derived.foo> origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index b5f3e2403b0..44ef2e2a51b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -17635,6 +17635,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @Test + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @Test @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index d65c5afc93b..14a317a9ce8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -17665,6 +17665,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @Test + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @Test @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index b6cd8f7f18d..f6647e8994b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -1400,6 +1400,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); } + @Test + @TestMetadata("kt47082.kt") + public void testKt47082() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt47082.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 14c8330899a..4d0fd476da4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -14606,6 +14606,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/labaledCall.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 8b9632eaef0..cc29bf6fc6d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12765,6 +12765,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/labaledCall.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 64a2ea02df0..4263818a463 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12171,6 +12171,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/labaledCall.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 3ace06aa4a1..d5fe5c18178 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -12236,6 +12236,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/builderInference/kt41164.kt"); } + @TestMetadata("kt47052.kt") + public void testKt47052() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/kt47052.kt"); + } + @TestMetadata("labaledCall.kt") public void testLabaledCall() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/labaledCall.kt");