From 4b15023aeceb98745d63b4530a5451e7847aa02a Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 2 Jul 2012 17:28:27 +0400 Subject: [PATCH] Turn off inlining. May be it'll help with KT-2314. --- .../k2js/test/semantics/InlineTest.java | 6 ++++- .../k2js/test/semantics/MiscTest.java | 4 +++ .../InlinedCallExpressionTranslator.java | 16 ++++++------ .../expression/misc/cases/KT-2314.kt | 25 +++++++++++++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 js/js.translator/testFiles/expression/misc/cases/KT-2314.kt diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java index 85705c2da0e..978fe5ee867 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java @@ -26,7 +26,11 @@ import java.io.File; /** * @author Pavel Talanov */ -public final class InlineTest extends SingleFileTranslationTest { + +//TODO: +//Inlining turned off +@SuppressWarnings("UnusedDeclaration") +public abstract class InlineTest extends SingleFileTranslationTest { public InlineTest() { super("inline/"); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java index f98cf55b87e..dec1d4b0ecd 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java @@ -61,6 +61,10 @@ public final class MiscTest extends AbstractExpressionTest { checkFooBoxIsTrue("KT-1052-2.kt", EcmaVersion.all()); } + public void testKt2314() throws Exception { + checkFooBoxIsTrue("KT-2314.kt", EcmaVersion.all()); + } + public void testKt1052() throws Exception { checkOutput("KT-1052.kt", "true\n"); } diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/reference/InlinedCallExpressionTranslator.java b/js/js.translator/src/org/jetbrains/k2js/translate/reference/InlinedCallExpressionTranslator.java index d87781c06d4..699aa3bd411 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/reference/InlinedCallExpressionTranslator.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/reference/InlinedCallExpressionTranslator.java @@ -29,7 +29,6 @@ import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.psi.JetCallExpression; import org.jetbrains.jet.lang.psi.JetFunction; -import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.ResolvedValueArgument; import org.jetbrains.k2js.translate.context.TemporaryVariable; import org.jetbrains.k2js.translate.context.TranslationContext; @@ -42,22 +41,23 @@ import java.util.Map; import static org.jetbrains.k2js.translate.reference.CallParametersResolver.resolveCallParameters; import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionForDescriptor; -import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCallForCallExpression; +import static org.jetbrains.k2js.translate.utils.FunctionBodyTranslator.translateFunctionBody; import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.getExpectedReceiverDescriptor; import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.getExpectedThisDescriptor; -import static org.jetbrains.k2js.translate.utils.FunctionBodyTranslator.translateFunctionBody; /** * @author Pavel Talanov */ public final class InlinedCallExpressionTranslator extends AbstractCallExpressionTranslator { + @SuppressWarnings("UnusedParameters") public static boolean shouldBeInlined(@NotNull JetCallExpression expression, @NotNull TranslationContext context) { - ResolvedCall resolvedCall = getResolvedCallForCallExpression(context.bindingContext(), expression); - CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor(); - if (descriptor instanceof SimpleFunctionDescriptor) { - return ((SimpleFunctionDescriptor)descriptor).isInline(); - } + //TODO: inlining turned off + //ResolvedCall resolvedCall = getResolvedCallForCallExpression(context.bindingContext(), expression); + //CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor(); + //if (descriptor instanceof SimpleFunctionDescriptor) { + // return ((SimpleFunctionDescriptor)descriptor).isInline(); + //} return false; } diff --git a/js/js.translator/testFiles/expression/misc/cases/KT-2314.kt b/js/js.translator/testFiles/expression/misc/cases/KT-2314.kt new file mode 100644 index 00000000000..040df59e237 --- /dev/null +++ b/js/js.translator/testFiles/expression/misc/cases/KT-2314.kt @@ -0,0 +1,25 @@ +package foo + +import java.util.* + +fun box(): Boolean { + val data = arrayList("foo", "bar") + if (data.head != "foo") { + return false + } + return true +} + + +public inline fun arrayList(vararg values: T) : ArrayList { + val c = ArrayList() + for (v in values) { + c.add(v) + } + return c +} + +public inline val ArrayList.head : T + get() { + return get(0) + } \ No newline at end of file