diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java index 64546d01cf3..cdef57cab81 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java @@ -97,21 +97,6 @@ public class AnonymousObjectTransformer { innerClassNodes.add(new InnerClassNode(name, outerName, innerName, access)); } - @Override - public void visitOuterClass(@NotNull String owner, String name, String desc) { - InliningContext parent = inliningContext.getParent(); - assert parent != null : "Context for transformer should have parent one: " + inliningContext; - - //we don't write owner info for lamdbas and SAMs just only for objects - if (parent.isRoot() || parent.isInliningLambdaRootContext()) { - //TODO: think about writing method info - there is some problem with new constructor desc calculation - super.visitOuterClass(inliningContext.getParent().getClassNameToInline(), null, null); - return; - } - - super.visitOuterClass(owner, name, desc); - } - @Override public MethodVisitor visitMethod( int access, @NotNull String name, @NotNull String desc, String signature, String[] exceptions @@ -202,16 +187,24 @@ public class AnonymousObjectTransformer { SourceMapper.Companion.flushToClassBuilder(sourceMapper, classBuilder); + ClassVisitor visitor = classBuilder.getVisitor(); for (InnerClassNode node : innerClassNodes) { - classBuilder.getVisitor().visitInnerClass(node.name, node.outerName, node.innerName, node.access); + visitor.visitInnerClass(node.name, node.outerName, node.innerName, node.access); } + writeOuterInfo(visitor); + classBuilder.done(); anonymousObjectGen.setNewLambdaType(newLambdaType); return transformationResult; } + private void writeOuterInfo(@NotNull ClassVisitor visitor) { + InlineCallSiteInfo info = inliningContext.getCallSiteInfo(); + visitor.visitOuterClass(info.getOwnerClassName(), info.getFunctionName(), info.getFunctionDesc()); + } + @NotNull private InlineResult inlineMethodAndUpdateGlobalResult( @NotNull AnonymousObjectGeneration anonymousObjectGen, @@ -244,9 +237,20 @@ public class AnonymousObjectTransformer { parameters, anonymousObjectGen.getCapturedLambdasToInline(), parentRemapper, isConstructor); - MethodInliner inliner = new MethodInliner(sourceNode, parameters, inliningContext.subInline(inliningContext.nameGenerator.subGenerator("lambda")), - remapper, isSameModule, "Transformer for " + anonymousObjectGen.getOwnerInternalName(), - sourceMapper); + MethodInliner inliner = + new MethodInliner( + sourceNode, + parameters, + inliningContext.subInline(inliningContext.nameGenerator.subGenerator("lambda")), + remapper, + isSameModule, + "Transformer for " + anonymousObjectGen.getOwnerInternalName(), + sourceMapper, + new InlineCallSiteInfo( + anonymousObjectGen.getOwnerInternalName(), + sourceNode.name, + isConstructor ? anonymousObjectGen.getNewConstructorDescriptor() : sourceNode.desc) + ); InlineResult result = inliner.doInline(deferringVisitor, new LocalVarRemapper(parameters, 0), false, LabelOwner.NOT_APPLICABLE); result.getReifiedTypeParametersUsages().mergeAll(typeParametersToReify); @@ -285,6 +289,8 @@ public class AnonymousObjectTransformer { } String constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, descTypes.toArray(new Type[descTypes.size()])); + //TODO for inline method make public class + anonymousObjectGen.setNewConstructorDescriptor(constructorDescriptor); MethodVisitor constructorVisitor = classBuilder.newMethod(NO_ORIGIN, AsmUtil.NO_FLAG_PACKAGE_PRIVATE, "", constructorDescriptor, @@ -325,8 +331,6 @@ public class AnonymousObjectTransformer { inlineMethodAndUpdateGlobalResult(anonymousObjectGen, parentRemapper, capturedFieldInitializer, constructor, constructorInlineBuilder, true); constructorVisitor.visitEnd(); AsmUtil.genClosureFields(TransformationUtilsKt.toNameTypePair(TransformationUtilsKt.filterSkipped(newFieldsWithSkipped)), classBuilder); - //TODO for inline method make public class - anonymousObjectGen.setNewConstructorDescriptor(constructorDescriptor); } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCallSiteInfo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCallSiteInfo.kt new file mode 100644 index 00000000000..0e62df11b39 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCallSiteInfo.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.inline + +class InlineCallSiteInfo(val ownerClassName: String, val functionName: String?, val functionDesc: String?) \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java index a3edccd9b30..bd0514f5c00 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.java @@ -269,12 +269,12 @@ public class InlineCodegen extends CallGenerator { .subGenerator(functionDescriptor.getName().asString()), codegen.getContext(), callElement, - codegen.getParentCodegen().getClassName(), reifiedTypeInliner, + getInlineCallSiteInfo(), reifiedTypeInliner, typeParameterMappings); MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule, "Method inlining " + callElement.getText(), - createNestedSourceMapper(nodeAndSmap)); //with captured + createNestedSourceMapper(nodeAndSmap), info.getCallSiteInfo()); //with captured LocalVarRemapper remapper = new LocalVarRemapper(parameters, initialFrameSize); @@ -306,6 +306,13 @@ public class InlineCodegen extends CallGenerator { return result; } + private InlineCallSiteInfo getInlineCallSiteInfo() { + MemberCodegen parentCodegen = codegen.getParentCodegen(); + MethodContext context = codegen.getContext(); + JvmMethodSignature signature = typeMapper.mapSignature(context.getFunctionDescriptor(), context.getContextKind()); + return new InlineCallSiteInfo(parentCodegen.getClassName(), signature.getAsmMethod().getName(), signature.getAsmMethod().getDescriptor()); + } + private void generateClosuresBodies() { for (LambdaInfo info : expressionMap.values()) { info.setNode(generateLambdaBody(info)); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InliningContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InliningContext.java index d06db34044e..3de46ffecc9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InliningContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InliningContext.java @@ -73,17 +73,18 @@ public class InliningContext { return subInline(nameGenerator.subGenerator("lambda"), map, true); } - public InliningContext subInline(NameGenerator generator, Map additionalTypeMappings) { + private InliningContext subInline(NameGenerator generator, Map additionalTypeMappings) { return subInline(generator, additionalTypeMappings, isInliningLambda); } public InliningContext subInlineWithClassRegeneration(@NotNull NameGenerator generator, @NotNull Map newTypeMappings, - @NotNull AnonymousObjectGeneration anonymousObjectGeneration + @NotNull AnonymousObjectGeneration anonymousObjectGeneration, + @NotNull InlineCallSiteInfo callSiteInfo ) { return new RegeneratedClassContext(this, expressionMap, state, generator, TypeRemapper.createFrom(typeRemapper, newTypeMappings), - reifedTypeInliner, isInliningLambda, anonymousObjectGeneration); + reifedTypeInliner, isInliningLambda, anonymousObjectGeneration, callSiteInfo); } public InliningContext subInline(NameGenerator generator, Map additionalTypeMappings, boolean isInliningLambda) { @@ -131,8 +132,8 @@ public class InliningContext { return isInliningLambda && !getParent().isInliningLambda; } - public String getClassNameToInline() { + public InlineCallSiteInfo getCallSiteInfo() { assert parent != null : "At least root context should return proper value"; - return parent.getClassNameToInline(); + return parent.getCallSiteInfo(); } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java index 81b608b6e9f..f8bb0885bbb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java @@ -55,6 +55,8 @@ public class MethodInliner { private final SourceMapper sourceMapper; + private final InlineCallSiteInfo inlineCallSiteInfo; + private final JetTypeMapper typeMapper; private final List invokeCalls = new ArrayList(); @@ -82,7 +84,8 @@ public class MethodInliner { @NotNull FieldRemapper nodeRemapper, boolean isSameModule, @NotNull String errorPrefix, - @NotNull SourceMapper sourceMapper + @NotNull SourceMapper sourceMapper, + @NotNull InlineCallSiteInfo inlineCallSiteInfo ) { this.node = node; this.parameters = parameters; @@ -91,6 +94,7 @@ public class MethodInliner { this.isSameModule = isSameModule; this.errorPrefix = errorPrefix; this.sourceMapper = sourceMapper; + this.inlineCallSiteInfo = inlineCallSiteInfo; this.typeMapper = inliningContext.state.getTypeMapper(); this.result = InlineResult.create(); } @@ -145,7 +149,7 @@ public class MethodInliner { return result; } - private MethodNode doInline(MethodNode node) { + private MethodNode doInline(final MethodNode node) { final Deque currentInvokes = new LinkedList(invokeCalls); @@ -179,7 +183,8 @@ public class MethodInliner { .subInlineWithClassRegeneration( inliningContext.nameGenerator, currentTypeMapping, - anonymousObjectGen), + anonymousObjectGen, + inlineCallSiteInfo), isSameModule, Type.getObjectType(newClassName) ); @@ -243,7 +248,7 @@ public class MethodInliner { inliningContext.subInlineLambda(info), newCapturedRemapper, true /*cause all calls in same module as lambda*/, "Lambda inlining " + info.getLambdaClassType().getInternalName(), - mapper); + mapper, inlineCallSiteInfo); LocalVarRemapper remapper = new LocalVarRemapper(lambdaParameters, valueParamShift); InlineResult lambdaResult = inliner.doInline(this.mv, remapper, true, info, invokeCall.finallyDepthShift);//TODO add skipped this and receiver @@ -639,7 +644,7 @@ public class MethodInliner { } } - private void transformFinallyDeepIndex(@NotNull MethodNode node, int finallyDeepShift) { + private static void transformFinallyDeepIndex(@NotNull MethodNode node, int finallyDeepShift) { if (finallyDeepShift == 0) { return; } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RegeneratedClassContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RegeneratedClassContext.java index 4a3bbfa48f0..1e0f1bfd750 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RegeneratedClassContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RegeneratedClassContext.java @@ -24,6 +24,7 @@ import java.util.Map; public class RegeneratedClassContext extends InliningContext { private final AnonymousObjectGeneration anonymousObjectGeneration; + private InlineCallSiteInfo callSiteInfo; public RegeneratedClassContext( @Nullable InliningContext parent, @@ -33,14 +34,15 @@ public class RegeneratedClassContext extends InliningContext { @NotNull TypeRemapper typeRemapper, @NotNull ReifiedTypeInliner reifiedTypeInliner, boolean isInliningLambda, - @NotNull AnonymousObjectGeneration anonymousObjectGeneration + @NotNull AnonymousObjectGeneration anonymousObjectGeneration, + @NotNull InlineCallSiteInfo callSiteInfo ) { super(parent, map, state, nameGenerator, typeRemapper, reifiedTypeInliner, isInliningLambda, true); this.anonymousObjectGeneration = anonymousObjectGeneration; + this.callSiteInfo = callSiteInfo; } - @Override - public String getClassNameToInline() { - return anonymousObjectGeneration.getOwnerInternalName(); + public InlineCallSiteInfo getCallSiteInfo() { + return callSiteInfo; } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java index 6f6341a56a8..194a787ee4e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/RootInliningContext.java @@ -26,7 +26,7 @@ import java.util.Map; public class RootInliningContext extends InliningContext { public final CodegenContext startContext; - private final String classNameToInline; + private final InlineCallSiteInfo inlineCallSiteInfo; public final TypeParameterMappings typeParameterMappings; public final KtElement callElement; @@ -36,20 +36,19 @@ public class RootInliningContext extends InliningContext { @NotNull NameGenerator nameGenerator, @NotNull CodegenContext startContext, @NotNull KtElement callElement, - @NotNull String classNameToInline, + @NotNull InlineCallSiteInfo classNameToInline, @NotNull ReifiedTypeInliner inliner, @Nullable TypeParameterMappings typeParameterMappings ) { super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false); this.callElement = callElement; this.startContext = startContext; - this.classNameToInline = classNameToInline; + this.inlineCallSiteInfo = classNameToInline; this.typeParameterMappings = typeParameterMappings; } @Override - @NotNull - public String getClassNameToInline() { - return classNameToInline; + public InlineCallSiteInfo getCallSiteInfo() { + return inlineCallSiteInfo; } } diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.1.kt b/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.1.kt new file mode 100644 index 00000000000..1e8c4dc4aa9 --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.1.kt @@ -0,0 +1,15 @@ +import test.* + +fun box(): String { + val res = test { + "OK" + } + + val enclosingMethod = res.javaClass.enclosingMethod + if (enclosingMethod?.name != "box") return "fail 1: ${enclosingMethod?.name}" + + val enclosingClass = res.javaClass.enclosingClass + if (enclosingClass?.name != "ObjectInInlineFun_1Kt") return "fail 2: ${enclosingClass?.name}" + + return "OK" +} diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.2.kt b/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.2.kt new file mode 100644 index 00000000000..087f4f14757 --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.2.kt @@ -0,0 +1,10 @@ +package test + +interface Z { + fun a(): String +} + +inline fun test(crossinline z: () -> String) = + object : Z { + override fun a() = z() + } diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.1.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.1.kt new file mode 100644 index 00000000000..9bec05970ba --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.1.kt @@ -0,0 +1,23 @@ +import test.* + +fun box(): String { + /*This captured parameter would be added to object constructor*/ + val captured = "OK"; + var z: Any = "fail" + val res = test { + + z = { + captured + } + (z as Function0)() + } + + + val enclosingConstructor = z.javaClass.enclosingConstructor + if (enclosingConstructor?.name != "TransformedConstructor_1Kt\$box$\$inlined\$test$1") return "fail 1: ${enclosingConstructor?.name}" + + val enclosingClass = z.javaClass.enclosingClass + if (enclosingClass?.name != "TransformedConstructor_1Kt\$box$\$inlined\$test$1") return "fail 2: ${enclosingClass?.name}" + + return res.a() +} diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.2.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.2.kt new file mode 100644 index 00000000000..74cb6e99e7f --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.2.kt @@ -0,0 +1,13 @@ +package test + +interface Z { + fun a() : String +} + +inline fun test(crossinline z: () -> String) = + object : Z { + + val p = z() + + override fun a() = p + } diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.1.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.1.kt new file mode 100644 index 00000000000..ed928ad306d --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.1.kt @@ -0,0 +1,28 @@ +import test.* + +fun box(): String { + var z = "OK" + val res = test { + z + } + + + val javaClass1 = res.javaClass + val enclosingMethod = javaClass1.enclosingMethod + if (enclosingMethod?.name != "box") return "fail 1: ${enclosingMethod?.name}" + + val enclosingClass = javaClass1.enclosingClass + if (enclosingClass?.name != "TransformedConstructorWithAdditionalObject_1Kt") return "fail 2: ${enclosingClass?.name}" + + + val res2 = res.a() + val enclosingConstructor = res2.javaClass.enclosingConstructor + if (enclosingConstructor?.name != javaClass1.name) return "fail 3: ${enclosingConstructor?.name} != ${javaClass1.name}" + + val enclosingClass2 = res2.javaClass.enclosingClass + if (enclosingClass2?.name != javaClass1.name) return "fail 4: ${enclosingClass2?.name} != ${javaClass1.name}" + + + + return res2.a() +} diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.2.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.2.kt new file mode 100644 index 00000000000..9dfa395390b --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.2.kt @@ -0,0 +1,18 @@ +package test + +interface Z { + fun a() : T +} + +inline fun test(crossinline z: () -> String) = + object : Z> { + + val p: Z = object : Z { + + val p2 = z() + + override fun a() = p2 + } + + override fun a() = p + } diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.1.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.1.kt new file mode 100644 index 00000000000..e6e3876e39c --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.1.kt @@ -0,0 +1,26 @@ +import test.* + +fun box(): String { + /*This captured parameter would be added to object constructor*/ + val captured = "OK"; + var z: Any = "fail" + val res = test { + + call { + z = { + captured + } + } + + (z as Function0)() + } + + + val enclosingConstructor = z.javaClass.enclosingConstructor + if (enclosingConstructor?.name != "TransformedConstructorWithNestedInline_1Kt\$box$\$inlined\$test$1") return "fail 1: ${enclosingConstructor?.name}" + + val enclosingClass = z.javaClass.enclosingClass + if (enclosingClass?.name != "TransformedConstructorWithNestedInline_1Kt\$box$\$inlined\$test$1") return "fail 2: ${enclosingClass?.name}" + + return res.a() +} diff --git a/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.2.kt b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.2.kt new file mode 100644 index 00000000000..dfb5b81869a --- /dev/null +++ b/compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.2.kt @@ -0,0 +1,16 @@ +package test + +interface Z { + fun a() : String +} + +inline fun test(crossinline z: () -> String) = + object : Z { + + val p = z() + + override fun a() = p + } + + +inline fun call(crossinline z: () -> T) = z() \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt b/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt new file mode 100644 index 00000000000..dfc824037cb --- /dev/null +++ b/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt @@ -0,0 +1,21 @@ +// NO_CHECK_LAMBDA_INLINING +// FULL_JDK + +import test.* +import java.util.* + + +fun box(): String { + val result = Test().callInline("test") + + val method = result.javaClass.getMethod("invoke") + val genericReturnType = method.genericReturnType + if (genericReturnType.toString() != "T") return "fail 1: $genericReturnType" + + val method2 = Test::class.java.getMethod("callInline", Any::class.java) + val genericParameterType = method2.genericParameterTypes.firstOrNull() + + if (genericParameterType != genericReturnType) return "fail 2: $genericParameterType != $genericReturnType" + + return "OK" +} diff --git a/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.2.kt b/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.2.kt new file mode 100644 index 00000000000..5a446443d3a --- /dev/null +++ b/compiler/testData/codegen/boxInline/signature/typeParameterInLambda.2.kt @@ -0,0 +1,12 @@ +package test + +open class Test { + + inline fun test(z: () -> () -> Y) = z() + + fun callInline(p: T) = test { + { + p + } + } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/OuterClassGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/OuterClassGenTest.java index 6c4c0a6d936..81577401d8c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/OuterClassGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/OuterClassGenTest.java @@ -96,21 +96,21 @@ public class OuterClassGenTest extends CodegenTestCase { } public void testLocalObjectInlined() throws Exception { - OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", "callToInline", "()V"); doCustomTest("foo/Bar\\$callToInline\\$\\$inlined\\$inlineFoo\\$1", expectedInfo, "inlineObject"); } public void testLocalObjectInInlineLambda() throws Exception { - OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", "objectInInlineLambda", "()V"); doCustomTest("foo/Bar\\$objectInInlineLambda\\$\\$inlined\\$simpleFoo\\$lambda\\$1", expectedInfo, "inlineObject"); } public void testLocalObjectInLambdaInlinedIntoObject() throws Exception { - OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V"); doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineObject"); - OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", null, null); + OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "run", "()V"); doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$lambda\\$lambda\\$1", objectInLambda, "inlineObject"); } @@ -121,21 +121,21 @@ public class OuterClassGenTest extends CodegenTestCase { } public void testLambdaInlined() throws Exception { - OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", "callToInline", "()V"); doCustomTest("foo/Bar\\$callToInline\\$\\$inlined\\$inlineFoo\\$1", expectedInfo, "inlineLambda"); } public void testLambdaInInlineLambda() throws Exception { - OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo expectedInfo = new OuterClassInfo("foo/Bar", "objectInInlineLambda", "()V"); doCustomTest("foo/Bar\\$objectInInlineLambda\\$\\$inlined\\$simpleFoo\\$lambda\\$1", expectedInfo, "inlineLambda"); } public void testLambdaInLambdaInlinedIntoObject() throws Exception { - OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", null, null); + OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V"); doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineLambda"); - OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", null, null); + OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "invoke", "()V"); doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$lambda\\$lambda\\$1", objectInLambda, "inlineLambda"); } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java index 75476e8a128..8a39cbed71c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java @@ -587,6 +587,39 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo } } + @TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnclosingInfo extends AbstractBlackBoxInlineCodegenTest { + public void testAllFilesPresentInEnclosingInfo() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/enclosingInfo"), Pattern.compile("^(.+)\\.1.kt$"), true); + } + + @TestMetadata("objectInInlineFun.1.kt") + public void testObjectInInlineFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructor.1.kt") + public void testTransformedConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructorWithAdditionalObject.1.kt") + public void testTransformedConstructorWithAdditionalObject() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructorWithNestedInline.1.kt") + public void testTransformedConstructorWithNestedInline() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/functionExpression") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1402,6 +1435,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo doTestMultiFileWithInlineCheck(fileName); } + @TestMetadata("typeParameterInLambda.1.kt") + public void testTypeParameterInLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + @TestMetadata("typeParametersSubstitution.1.kt") public void testTypeParametersSubstitution() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java index 11e1338ef50..39411070e07 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -587,6 +587,39 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi } } + @TestMetadata("compiler/testData/codegen/boxInline/enclosingInfo") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class EnclosingInfo extends AbstractCompileKotlinAgainstInlineKotlinTest { + public void testAllFilesPresentInEnclosingInfo() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/enclosingInfo"), Pattern.compile("^(.+)\\.1.kt$"), true); + } + + @TestMetadata("objectInInlineFun.1.kt") + public void testObjectInInlineFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/objectInInlineFun.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructor.1.kt") + public void testTransformedConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructor.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructorWithAdditionalObject.1.kt") + public void testTransformedConstructorWithAdditionalObject() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithAdditionalObject.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("transformedConstructorWithNestedInline.1.kt") + public void testTransformedConstructorWithNestedInline() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/enclosingInfo/transformedConstructorWithNestedInline.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxInline/functionExpression") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1402,6 +1435,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi doBoxTestWithInlineCheck(fileName); } + @TestMetadata("typeParameterInLambda.1.kt") + public void testTypeParameterInLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + @TestMetadata("typeParametersSubstitution.1.kt") public void testTypeParametersSubstitution() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt");