Make stdlib work with -Xmultifile-package-facades.

Fixed wrong owner mapping in presence of -Xmultifile-package-facades.
Fixed backing field mapping issue.
Added more tests.
This commit is contained in:
Dmitry Petrov
2015-09-11 19:14:10 +03:00
parent 838433ba8a
commit 1586a2df8e
43 changed files with 363 additions and 90 deletions
@@ -40,4 +40,10 @@ public class BytecodeTextMultifileTestGenerated extends AbstractBytecodeTextTest
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeTextMultifile/partMembersCall/");
doTestMultiFile(fileName);
}
@TestMetadata("partMembersInline")
public void testPartMembersInline() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeTextMultifile/partMembersInline/");
doTestMultiFile(fileName);
}
}
@@ -34,11 +34,13 @@ import kotlin.properties.Delegates
public object InlineTestUtil {
public val INLINE_ANNOTATION_CLASS: String = "kotlin/inline"
private val KOTLIN_PACKAGE_DESC = "L" + AsmUtil.internalNameByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_PACKAGE) + ";"
private val KOTLIN_MULTIFILE_CLASS_DESC = "L" + AsmUtil.internalNameByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_MULTIFILE_CLASS) + ";"
public fun checkNoCallsToInline(files: Iterable<OutputFile>, sourceFiles: List<JetFile>) {
val inlineInfo = obtainInlineInfo(files)
val inlineMethods = inlineInfo.inlineMethods
assert(!inlineMethods.isEmpty(), "There are no inline methods")
assert(!inlineMethods.isEmpty()) { "There are no inline methods" }
val notInlinedCalls = checkInlineMethodNotInvoked(files, inlineMethods)
assert(notInlinedCalls.isEmpty()) { "All inline methods should be inlined but:\n" + notInlinedCalls.joinToString("\n") }
@@ -94,7 +96,7 @@ public object InlineTestUtil {
private var skipMethodsOfThisClass = false
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
if (desc.endsWith("KotlinPackage;") || desc.endsWith("KotlinMultifileClass;")) {
if (desc == KOTLIN_PACKAGE_DESC || desc == KOTLIN_MULTIFILE_CLASS_DESC) {
skipMethodsOfThisClass = true
}
return null
@@ -53,6 +53,12 @@ public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodeg
doTestMultiFile(fileName);
}
@TestMetadata("inlineMultifileClassMemberFromOtherPackage")
public void testInlineMultifileClassMemberFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/inlineMultifileClassMemberFromOtherPackage/");
doTestMultiFile(fileName);
}
@TestMetadata("internalVisibility")
public void testInternalVisibility() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/internalVisibility/");
@@ -89,6 +95,12 @@ public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodeg
doTestMultiFile(fileName);
}
@TestMetadata("multifileClassPartsInitialization")
public void testMultifileClassPartsInitialization() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/multifileClassPartsInitialization/");
doTestMultiFile(fileName);
}
@TestMetadata("packageLocalClassNotImportedWithDefaultImport")
public void testPackageLocalClassNotImportedWithDefaultImport() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/packageLocalClassNotImportedWithDefaultImport/");
@@ -35,6 +35,21 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class AgainstMultifileStdlib extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInAgainstMultifileStdlib() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("useStdlib.kt")
public void testUseStdlib() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib/useStdlib.kt");
doTestWithStdlib(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/annotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -0,0 +1,30 @@
/*
* 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.jvm.compiler
import org.jetbrains.kotlin.codegen.generated.AbstractBlackBoxCodegenTest
import java.io.File
public abstract class AbstractBlackBoxMultifileClassCodegenTest: AbstractBlackBoxCodegenTest() {
public fun doTestMultifileClassAgainstSources(firstFileName: String) {
val fileName = relativePath(File(firstFileName))
val inputFiles = listOf(fileName, fileName.substringBeforeLast("1.kt") + "2.kt")
doTestMultiFile(inputFiles)
}
}
@@ -26,8 +26,7 @@ public abstract class AbstractCompileKotlinAgainstMultifileKotlinTest : Abstract
public fun doBoxTest(firstFileName: String) {
val inputFiles = listOf(firstFileName, firstFileName.substringBeforeLast("1.kt") + "2.kt")
val (factory1, factory2) = doBoxTest(inputFiles)
doBoxTest(inputFiles)
}
private fun doBoxTest(files: List<String>): Pair<ClassFileFactory, ClassFileFactory> {
@@ -0,0 +1,64 @@
/*
* 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.jvm.compiler;
import com.intellij.testFramework.TestDataPath;
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/codegen/boxMultifileClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class BlackBoxMultifileClassKotlinTestGenerated extends AbstractBlackBoxMultifileClassCodegenTest {
public void testAllFilesPresentInBoxMultifileClasses() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses"), Pattern.compile("^(.+)\\.1.kt$"), true);
}
@TestMetadata("compiler/testData/codegen/boxMultifileClasses/calls")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Calls extends AbstractBlackBoxMultifileClassCodegenTest {
public void testAllFilesPresentInCalls() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxMultifileClasses/calls"), Pattern.compile("^(.+)\\.1.kt$"), true);
}
@TestMetadata("callFromOtherPackage.1.kt")
public void testCallFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.1.kt");
doTestMultifileClassAgainstSources(fileName);
}
@TestMetadata("valFromOtherPackage.1.kt")
public void testValFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.1.kt");
doTestMultifileClassAgainstSources(fileName);
}
@TestMetadata("varFromOtherPackage.1.kt")
public void testVarFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.1.kt");
doTestMultifileClassAgainstSources(fileName);
}
}
}
@@ -48,5 +48,17 @@ public class CompileKotlinAgainstMultifileKotlinTestGenerated extends AbstractCo
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/callFromOtherPackage.1.kt");
doBoxTest(fileName);
}
@TestMetadata("valFromOtherPackage.1.kt")
public void testValFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/valFromOtherPackage.1.kt");
doBoxTest(fileName);
}
@TestMetadata("varFromOtherPackage.1.kt")
public void testVarFromOtherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxMultifileClasses/calls/varFromOtherPackage.1.kt");
doBoxTest(fileName);
}
}
}