diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt index 5456bbdb1d2..5bfbcb29592 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt @@ -859,7 +859,7 @@ class MethodInliner( needReification: Boolean, capturesAnonymousObjectThatMustBeRegenerated: Boolean ): AnonymousObjectTransformationInfo { - // In objects inside non-default lambdas, all reified type parameters are free (not from the function + // In objects inside non-default inline lambdas, all reified type parameters are free (not from the function // we're inlining into) so there's nothing to reify: // // inline fun f(x: () -> KClass = { { T::class }() }) = x() @@ -867,8 +867,8 @@ class MethodInliner( // fun b() = f { { Int::class }() } // non-default lambda // inline fun c() = f { { V::class }() } // - // -- in a(), the default lambda captures T so a regeneration is needed; but in b() and c(), the non-default - // lambda cannot possibly reference it, while V is not yet bound so regenerating the object while inlining + // -- in a(), the default inline lambda captures T so a regeneration is needed; but in b() and c(), the non-default + // inline lambda cannot possibly reference it, while V is not yet bound so regenerating the object while inlining // the lambda into f() is pointless. val inNonDefaultLambda = inliningContext.isInliningLambda && inliningContext.lambdaInfo !is DefaultLambda val info = AnonymousObjectTransformationInfo( diff --git a/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.kt b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.kt index 5a19cee2ef5..4114e549557 100644 --- a/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.kt +++ b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.kt @@ -1,3 +1,4 @@ +// CHECK_BYTECODE_LISTING // FILE: 1.kt package test diff --git a/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.txt b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.txt new file mode 100644 index 00000000000..ca136207bf4 --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda.txt @@ -0,0 +1,24 @@ +@kotlin.Metadata +public final class _2Kt$box$$inlined$complicatedCast$1 { + inner class _2Kt$box$$inlined$complicatedCast$1 + public method (): void + public final method f(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class _2Kt$complicatedCast$1$1 { + inner class _2Kt$complicatedCast$1$1 + public method (): void + public final method f(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class _2Kt { + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public synthetic final static method complicatedCast(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class test/_1Kt { + public final static method myRun(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object +} diff --git a/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda_ir.txt b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda_ir.txt new file mode 100644 index 00000000000..ca136207bf4 --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/nonCapturingObjectInLambda_ir.txt @@ -0,0 +1,24 @@ +@kotlin.Metadata +public final class _2Kt$box$$inlined$complicatedCast$1 { + inner class _2Kt$box$$inlined$complicatedCast$1 + public method (): void + public final method f(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class _2Kt$complicatedCast$1$1 { + inner class _2Kt$complicatedCast$1$1 + public method (): void + public final method f(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class _2Kt { + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String + public synthetic final static method complicatedCast(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class test/_1Kt { + public final static method myRun(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object +}