diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.kt new file mode 100644 index 00000000000..5fc5b471f4e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -NOTHING_TO_INLINE + +inline fun f(): Unit = g() + +inline fun g(): Unit = h() + +inline fun h(): Unit = f() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.txt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.txt new file mode 100644 index 00000000000..d030d4c9893 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.txt @@ -0,0 +1,5 @@ +package + +kotlin.inline() internal fun f(): kotlin.Unit +kotlin.inline() internal fun g(): kotlin.Unit +kotlin.inline() internal fun h(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.kt new file mode 100644 index 00000000000..291546e9991 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -NOTHING_TO_INLINE + +inline fun f(): Unit = g() + +inline fun g(): Unit = h { f() } + +inline fun h(fn: ()->Unit): Unit = fn() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.txt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.txt new file mode 100644 index 00000000000..a83914ab7c3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.txt @@ -0,0 +1,5 @@ +package + +kotlin.inline() internal fun f(): kotlin.Unit +kotlin.inline() internal fun g(): kotlin.Unit +kotlin.inline() internal fun h(/*0*/ fn: () -> kotlin.Unit): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.kt new file mode 100644 index 00000000000..028f6f03ace --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -NOTHING_TO_INLINE + +public inline fun f():Unit = g() + +public inline fun g(): Unit = h() + +public inline fun h(): Unit = f() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.txt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.txt new file mode 100644 index 00000000000..bd63167c395 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.txt @@ -0,0 +1,5 @@ +package + +kotlin.inline() public fun f(): kotlin.Unit +kotlin.inline() public fun g(): kotlin.Unit +kotlin.inline() public fun h(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.kt new file mode 100644 index 00000000000..5e9896c1f1f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.kt @@ -0,0 +1,6 @@ +// !DIAGNOSTICS: -NOTHING_TO_INLINE + +inline fun f(): Unit = g() + +inline fun g(): Unit = run { f() } + diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.txt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.txt new file mode 100644 index 00000000000..00ad805b14b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.txt @@ -0,0 +1,4 @@ +package + +kotlin.inline() internal fun f(): kotlin.Unit +kotlin.inline() internal fun g(): kotlin.Unit diff --git a/compiler/tests/compiler-tests.iml b/compiler/tests/compiler-tests.iml index a55aff78130..a9a60a5d830 100644 --- a/compiler/tests/compiler-tests.iml +++ b/compiler/tests/compiler-tests.iml @@ -25,5 +25,6 @@ + \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLib.java b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLib.java index 5da39652045..eb403992363 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLib.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLib.java @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration; import org.jetbrains.kotlin.context.GlobalContext; import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl; import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS; +import org.jetbrains.kotlin.js.config.Config; import org.jetbrains.kotlin.js.config.EcmaVersion; import org.jetbrains.kotlin.js.config.LibrarySourcesConfig; import org.jetbrains.kotlin.js.config.LibrarySourcesConfigWithCaching; @@ -93,4 +94,8 @@ public abstract class AbstractJetDiagnosticsTestWithJsStdLib extends AbstractJet return module; } + + protected Config getConfig() { + return config; + } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation.kt b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation.kt new file mode 100644 index 00000000000..74e75aaed86 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2015 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.checkers + +import org.jetbrains.kotlin.context.GlobalContext +import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl +import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS +import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult +import org.jetbrains.kotlin.js.facade.K2JSTranslator +import org.jetbrains.kotlin.js.facade.MainCallParameters +import org.jetbrains.kotlin.js.facade.exceptions.TranslationException +import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics + +import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.hasError + +public abstract class AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation : AbstractJetDiagnosticsTestWithJsStdLib() { + override fun analyzeModuleContents( + context: GlobalContext, + jetFiles: List, + module: ModuleDescriptorImpl, + moduleTrace: BindingTrace + ) { + val analysisResult = TopDownAnalyzerFacadeForJS.analyzeFilesWithGivenTrace(jetFiles, moduleTrace, module, getConfig()) + val diagnostics = analysisResult.bindingTrace.getBindingContext().getDiagnostics() + + if (!hasError(diagnostics)) { + val translator = K2JSTranslator(getConfig()) + translator.translate(jetFiles, MainCallParameters.noCall(), analysisResult) + } + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated.java new file mode 100644 index 00000000000..0ba0bd2d9a6 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2015 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.checkers; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.InnerTestClasses; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.JetTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation") +@TestDataPath("$PROJECT_ROOT") +@InnerTestClasses({ + JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated.Inline.class, +}) +@RunWith(JUnit3RunnerWithInners.class) +public class JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated extends AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation { + public void testAllFilesPresentInTestsWithJsStdLibAndBackendCompilation() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation { + public void testAllFilesPresentInInline() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("recursionCycle.kt") + public void testRecursionCycle() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.kt"); + doTest(fileName); + } + + @TestMetadata("recursionCycleLambda.kt") + public void testRecursionCycleLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.kt"); + doTest(fileName); + } + + @TestMetadata("recursionCycleWithPublicFun.kt") + public void testRecursionCycleWithPublicFun() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.kt"); + doTest(fileName); + } + + @TestMetadata("recursionCycleWithStdlibCall.kt") + public void testRecursionCycleWithStdlibCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.kt"); + doTest(fileName); + } + } +} diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 575b0b487fe..cc28f452942 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -135,6 +135,10 @@ fun main(args: Array) { model("diagnostics/testsWithJsStdLib") } + testClass(javaClass()) { + model("diagnostics/testsWithJsStdLibAndBackendCompilation") + } + testClass(javaClass()) { model("resolve", extension = "resolve") }