Write enclosing method info for transformed objects

This commit is contained in:
Michael Bogdanov
2016-01-08 12:51:42 +03:00
parent 8ab1190082
commit 657b9ff808
20 changed files with 348 additions and 51 deletions
@@ -97,21 +97,6 @@ public class AnonymousObjectTransformer {
innerClassNodes.add(new InnerClassNode(name, outerName, innerName, access)); 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 @Override
public MethodVisitor visitMethod( public MethodVisitor visitMethod(
int access, @NotNull String name, @NotNull String desc, String signature, String[] exceptions int access, @NotNull String name, @NotNull String desc, String signature, String[] exceptions
@@ -202,16 +187,24 @@ public class AnonymousObjectTransformer {
SourceMapper.Companion.flushToClassBuilder(sourceMapper, classBuilder); SourceMapper.Companion.flushToClassBuilder(sourceMapper, classBuilder);
ClassVisitor visitor = classBuilder.getVisitor();
for (InnerClassNode node : innerClassNodes) { 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(); classBuilder.done();
anonymousObjectGen.setNewLambdaType(newLambdaType); anonymousObjectGen.setNewLambdaType(newLambdaType);
return transformationResult; return transformationResult;
} }
private void writeOuterInfo(@NotNull ClassVisitor visitor) {
InlineCallSiteInfo info = inliningContext.getCallSiteInfo();
visitor.visitOuterClass(info.getOwnerClassName(), info.getFunctionName(), info.getFunctionDesc());
}
@NotNull @NotNull
private InlineResult inlineMethodAndUpdateGlobalResult( private InlineResult inlineMethodAndUpdateGlobalResult(
@NotNull AnonymousObjectGeneration anonymousObjectGen, @NotNull AnonymousObjectGeneration anonymousObjectGen,
@@ -244,9 +237,20 @@ public class AnonymousObjectTransformer {
parameters, anonymousObjectGen.getCapturedLambdasToInline(), parameters, anonymousObjectGen.getCapturedLambdasToInline(),
parentRemapper, isConstructor); parentRemapper, isConstructor);
MethodInliner inliner = new MethodInliner(sourceNode, parameters, inliningContext.subInline(inliningContext.nameGenerator.subGenerator("lambda")), MethodInliner inliner =
remapper, isSameModule, "Transformer for " + anonymousObjectGen.getOwnerInternalName(), new MethodInliner(
sourceMapper); 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); InlineResult result = inliner.doInline(deferringVisitor, new LocalVarRemapper(parameters, 0), false, LabelOwner.NOT_APPLICABLE);
result.getReifiedTypeParametersUsages().mergeAll(typeParametersToReify); result.getReifiedTypeParametersUsages().mergeAll(typeParametersToReify);
@@ -285,6 +289,8 @@ public class AnonymousObjectTransformer {
} }
String constructorDescriptor = Type.getMethodDescriptor(Type.VOID_TYPE, descTypes.toArray(new Type[descTypes.size()])); 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, MethodVisitor constructorVisitor = classBuilder.newMethod(NO_ORIGIN,
AsmUtil.NO_FLAG_PACKAGE_PRIVATE, AsmUtil.NO_FLAG_PACKAGE_PRIVATE,
"<init>", constructorDescriptor, "<init>", constructorDescriptor,
@@ -325,8 +331,6 @@ public class AnonymousObjectTransformer {
inlineMethodAndUpdateGlobalResult(anonymousObjectGen, parentRemapper, capturedFieldInitializer, constructor, constructorInlineBuilder, true); inlineMethodAndUpdateGlobalResult(anonymousObjectGen, parentRemapper, capturedFieldInitializer, constructor, constructorInlineBuilder, true);
constructorVisitor.visitEnd(); constructorVisitor.visitEnd();
AsmUtil.genClosureFields(TransformationUtilsKt.toNameTypePair(TransformationUtilsKt.filterSkipped(newFieldsWithSkipped)), classBuilder); AsmUtil.genClosureFields(TransformationUtilsKt.toNameTypePair(TransformationUtilsKt.filterSkipped(newFieldsWithSkipped)), classBuilder);
//TODO for inline method make public class
anonymousObjectGen.setNewConstructorDescriptor(constructorDescriptor);
} }
@NotNull @NotNull
@@ -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?)
@@ -269,12 +269,12 @@ public class InlineCodegen extends CallGenerator {
.subGenerator(functionDescriptor.getName().asString()), .subGenerator(functionDescriptor.getName().asString()),
codegen.getContext(), codegen.getContext(),
callElement, callElement,
codegen.getParentCodegen().getClassName(), reifiedTypeInliner, getInlineCallSiteInfo(), reifiedTypeInliner,
typeParameterMappings); typeParameterMappings);
MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule, MethodInliner inliner = new MethodInliner(node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
"Method inlining " + callElement.getText(), "Method inlining " + callElement.getText(),
createNestedSourceMapper(nodeAndSmap)); //with captured createNestedSourceMapper(nodeAndSmap), info.getCallSiteInfo()); //with captured
LocalVarRemapper remapper = new LocalVarRemapper(parameters, initialFrameSize); LocalVarRemapper remapper = new LocalVarRemapper(parameters, initialFrameSize);
@@ -306,6 +306,13 @@ public class InlineCodegen extends CallGenerator {
return result; 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() { private void generateClosuresBodies() {
for (LambdaInfo info : expressionMap.values()) { for (LambdaInfo info : expressionMap.values()) {
info.setNode(generateLambdaBody(info)); info.setNode(generateLambdaBody(info));
@@ -73,17 +73,18 @@ public class InliningContext {
return subInline(nameGenerator.subGenerator("lambda"), map, true); return subInline(nameGenerator.subGenerator("lambda"), map, true);
} }
public InliningContext subInline(NameGenerator generator, Map<String, String> additionalTypeMappings) { private InliningContext subInline(NameGenerator generator, Map<String, String> additionalTypeMappings) {
return subInline(generator, additionalTypeMappings, isInliningLambda); return subInline(generator, additionalTypeMappings, isInliningLambda);
} }
public InliningContext subInlineWithClassRegeneration(@NotNull NameGenerator generator, public InliningContext subInlineWithClassRegeneration(@NotNull NameGenerator generator,
@NotNull Map<String, String> newTypeMappings, @NotNull Map<String, String> newTypeMappings,
@NotNull AnonymousObjectGeneration anonymousObjectGeneration @NotNull AnonymousObjectGeneration anonymousObjectGeneration,
@NotNull InlineCallSiteInfo callSiteInfo
) { ) {
return new RegeneratedClassContext(this, expressionMap, state, generator, return new RegeneratedClassContext(this, expressionMap, state, generator,
TypeRemapper.createFrom(typeRemapper, newTypeMappings), TypeRemapper.createFrom(typeRemapper, newTypeMappings),
reifedTypeInliner, isInliningLambda, anonymousObjectGeneration); reifedTypeInliner, isInliningLambda, anonymousObjectGeneration, callSiteInfo);
} }
public InliningContext subInline(NameGenerator generator, Map<String, String> additionalTypeMappings, boolean isInliningLambda) { public InliningContext subInline(NameGenerator generator, Map<String, String> additionalTypeMappings, boolean isInliningLambda) {
@@ -131,8 +132,8 @@ public class InliningContext {
return isInliningLambda && !getParent().isInliningLambda; return isInliningLambda && !getParent().isInliningLambda;
} }
public String getClassNameToInline() { public InlineCallSiteInfo getCallSiteInfo() {
assert parent != null : "At least root context should return proper value"; assert parent != null : "At least root context should return proper value";
return parent.getClassNameToInline(); return parent.getCallSiteInfo();
} }
} }
@@ -55,6 +55,8 @@ public class MethodInliner {
private final SourceMapper sourceMapper; private final SourceMapper sourceMapper;
private final InlineCallSiteInfo inlineCallSiteInfo;
private final JetTypeMapper typeMapper; private final JetTypeMapper typeMapper;
private final List<InvokeCall> invokeCalls = new ArrayList<InvokeCall>(); private final List<InvokeCall> invokeCalls = new ArrayList<InvokeCall>();
@@ -82,7 +84,8 @@ public class MethodInliner {
@NotNull FieldRemapper nodeRemapper, @NotNull FieldRemapper nodeRemapper,
boolean isSameModule, boolean isSameModule,
@NotNull String errorPrefix, @NotNull String errorPrefix,
@NotNull SourceMapper sourceMapper @NotNull SourceMapper sourceMapper,
@NotNull InlineCallSiteInfo inlineCallSiteInfo
) { ) {
this.node = node; this.node = node;
this.parameters = parameters; this.parameters = parameters;
@@ -91,6 +94,7 @@ public class MethodInliner {
this.isSameModule = isSameModule; this.isSameModule = isSameModule;
this.errorPrefix = errorPrefix; this.errorPrefix = errorPrefix;
this.sourceMapper = sourceMapper; this.sourceMapper = sourceMapper;
this.inlineCallSiteInfo = inlineCallSiteInfo;
this.typeMapper = inliningContext.state.getTypeMapper(); this.typeMapper = inliningContext.state.getTypeMapper();
this.result = InlineResult.create(); this.result = InlineResult.create();
} }
@@ -145,7 +149,7 @@ public class MethodInliner {
return result; return result;
} }
private MethodNode doInline(MethodNode node) { private MethodNode doInline(final MethodNode node) {
final Deque<InvokeCall> currentInvokes = new LinkedList<InvokeCall>(invokeCalls); final Deque<InvokeCall> currentInvokes = new LinkedList<InvokeCall>(invokeCalls);
@@ -179,7 +183,8 @@ public class MethodInliner {
.subInlineWithClassRegeneration( .subInlineWithClassRegeneration(
inliningContext.nameGenerator, inliningContext.nameGenerator,
currentTypeMapping, currentTypeMapping,
anonymousObjectGen), anonymousObjectGen,
inlineCallSiteInfo),
isSameModule, Type.getObjectType(newClassName) isSameModule, Type.getObjectType(newClassName)
); );
@@ -243,7 +248,7 @@ public class MethodInliner {
inliningContext.subInlineLambda(info), inliningContext.subInlineLambda(info),
newCapturedRemapper, true /*cause all calls in same module as lambda*/, newCapturedRemapper, true /*cause all calls in same module as lambda*/,
"Lambda inlining " + info.getLambdaClassType().getInternalName(), "Lambda inlining " + info.getLambdaClassType().getInternalName(),
mapper); mapper, inlineCallSiteInfo);
LocalVarRemapper remapper = new LocalVarRemapper(lambdaParameters, valueParamShift); LocalVarRemapper remapper = new LocalVarRemapper(lambdaParameters, valueParamShift);
InlineResult lambdaResult = inliner.doInline(this.mv, remapper, true, info, invokeCall.finallyDepthShift);//TODO add skipped this and receiver 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) { if (finallyDeepShift == 0) {
return; return;
} }
@@ -24,6 +24,7 @@ import java.util.Map;
public class RegeneratedClassContext extends InliningContext { public class RegeneratedClassContext extends InliningContext {
private final AnonymousObjectGeneration anonymousObjectGeneration; private final AnonymousObjectGeneration anonymousObjectGeneration;
private InlineCallSiteInfo callSiteInfo;
public RegeneratedClassContext( public RegeneratedClassContext(
@Nullable InliningContext parent, @Nullable InliningContext parent,
@@ -33,14 +34,15 @@ public class RegeneratedClassContext extends InliningContext {
@NotNull TypeRemapper typeRemapper, @NotNull TypeRemapper typeRemapper,
@NotNull ReifiedTypeInliner reifiedTypeInliner, @NotNull ReifiedTypeInliner reifiedTypeInliner,
boolean isInliningLambda, boolean isInliningLambda,
@NotNull AnonymousObjectGeneration anonymousObjectGeneration @NotNull AnonymousObjectGeneration anonymousObjectGeneration,
@NotNull InlineCallSiteInfo callSiteInfo
) { ) {
super(parent, map, state, nameGenerator, typeRemapper, reifiedTypeInliner, isInliningLambda, true); super(parent, map, state, nameGenerator, typeRemapper, reifiedTypeInliner, isInliningLambda, true);
this.anonymousObjectGeneration = anonymousObjectGeneration; this.anonymousObjectGeneration = anonymousObjectGeneration;
this.callSiteInfo = callSiteInfo;
} }
@Override public InlineCallSiteInfo getCallSiteInfo() {
public String getClassNameToInline() { return callSiteInfo;
return anonymousObjectGeneration.getOwnerInternalName();
} }
} }
@@ -26,7 +26,7 @@ import java.util.Map;
public class RootInliningContext extends InliningContext { public class RootInliningContext extends InliningContext {
public final CodegenContext startContext; public final CodegenContext startContext;
private final String classNameToInline; private final InlineCallSiteInfo inlineCallSiteInfo;
public final TypeParameterMappings typeParameterMappings; public final TypeParameterMappings typeParameterMappings;
public final KtElement callElement; public final KtElement callElement;
@@ -36,20 +36,19 @@ public class RootInliningContext extends InliningContext {
@NotNull NameGenerator nameGenerator, @NotNull NameGenerator nameGenerator,
@NotNull CodegenContext startContext, @NotNull CodegenContext startContext,
@NotNull KtElement callElement, @NotNull KtElement callElement,
@NotNull String classNameToInline, @NotNull InlineCallSiteInfo classNameToInline,
@NotNull ReifiedTypeInliner inliner, @NotNull ReifiedTypeInliner inliner,
@Nullable TypeParameterMappings typeParameterMappings @Nullable TypeParameterMappings typeParameterMappings
) { ) {
super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false); super(null, map, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), inliner, false, false);
this.callElement = callElement; this.callElement = callElement;
this.startContext = startContext; this.startContext = startContext;
this.classNameToInline = classNameToInline; this.inlineCallSiteInfo = classNameToInline;
this.typeParameterMappings = typeParameterMappings; this.typeParameterMappings = typeParameterMappings;
} }
@Override @Override
@NotNull public InlineCallSiteInfo getCallSiteInfo() {
public String getClassNameToInline() { return inlineCallSiteInfo;
return classNameToInline;
} }
} }
@@ -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"
}
@@ -0,0 +1,10 @@
package test
interface Z {
fun a(): String
}
inline fun test(crossinline z: () -> String) =
object : Z {
override fun a() = z()
}
@@ -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<String>)()
}
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()
}
@@ -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
}
@@ -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()
}
@@ -0,0 +1,18 @@
package test
interface Z<T> {
fun a() : T
}
inline fun test(crossinline z: () -> String) =
object : Z<Z<String>> {
val p: Z<String> = object : Z<String> {
val p2 = z()
override fun a() = p2
}
override fun a() = p
}
@@ -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<String>)()
}
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()
}
@@ -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<T> call(crossinline z: () -> T) = z()
@@ -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"
}
@@ -0,0 +1,12 @@
package test
open class Test {
inline fun <Y> test(z: () -> () -> Y) = z()
fun <T> callInline(p: T) = test<T> {
{
p
}
}
}
@@ -96,21 +96,21 @@ public class OuterClassGenTest extends CodegenTestCase {
} }
public void testLocalObjectInlined() throws Exception { 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"); doCustomTest("foo/Bar\\$callToInline\\$\\$inlined\\$inlineFoo\\$1", expectedInfo, "inlineObject");
} }
public void testLocalObjectInInlineLambda() throws Exception { 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"); doCustomTest("foo/Bar\\$objectInInlineLambda\\$\\$inlined\\$simpleFoo\\$lambda\\$1", expectedInfo, "inlineObject");
} }
public void testLocalObjectInLambdaInlinedIntoObject() throws Exception { 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"); 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", doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$lambda\\$lambda\\$1",
objectInLambda, "inlineObject"); objectInLambda, "inlineObject");
} }
@@ -121,21 +121,21 @@ public class OuterClassGenTest extends CodegenTestCase {
} }
public void testLambdaInlined() throws Exception { 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"); doCustomTest("foo/Bar\\$callToInline\\$\\$inlined\\$inlineFoo\\$1", expectedInfo, "inlineLambda");
} }
public void testLambdaInInlineLambda() throws Exception { 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"); doCustomTest("foo/Bar\\$objectInInlineLambda\\$\\$inlined\\$simpleFoo\\$lambda\\$1", expectedInfo, "inlineLambda");
} }
public void testLambdaInLambdaInlinedIntoObject() throws Exception { 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"); 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", doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$lambda\\$lambda\\$1",
objectInLambda, "inlineLambda"); objectInLambda, "inlineLambda");
} }
@@ -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") @TestMetadata("compiler/testData/codegen/boxInline/functionExpression")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
@@ -1402,6 +1435,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
doTestMultiFileWithInlineCheck(fileName); 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") @TestMetadata("typeParametersSubstitution.1.kt")
public void testTypeParametersSubstitution() throws Exception { public void testTypeParametersSubstitution() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt");
@@ -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") @TestMetadata("compiler/testData/codegen/boxInline/functionExpression")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
@@ -1402,6 +1435,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
doBoxTestWithInlineCheck(fileName); 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") @TestMetadata("typeParametersSubstitution.1.kt")
public void testTypeParametersSubstitution() throws Exception { public void testTypeParametersSubstitution() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParametersSubstitution.1.kt");