Report error on state in multi-file class with -Xmultifile-parts-inherit
Simplify MultifileClassPartCodegen, remove related tests and change some tests to use const val instead of val because backing fields for const properties are stored in the facade, not parts #KT-23701 Fixed
This commit is contained in:
@@ -659,8 +659,6 @@ public class FunctionCodegen {
|
||||
genNotNullAssertionsForParameters(new InstructionAdapter(mv), parentCodegen.state, functionDescriptor, frameMap);
|
||||
}
|
||||
|
||||
parentCodegen.beforeMethodBody(mv);
|
||||
|
||||
methodEnd = new Label();
|
||||
context.setMethodEndLabel(methodEnd);
|
||||
strategy.generateBody(mv, frameMap, signature, context, parentCodegen);
|
||||
|
||||
@@ -455,17 +455,13 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
if (clInit == null) {
|
||||
DeclarationDescriptor contextDescriptor = context.getContextDescriptor();
|
||||
SimpleFunctionDescriptorImpl clInitDescriptor = createClInitFunctionDescriptor(contextDescriptor);
|
||||
MethodVisitor mv = createClInitMethodVisitor(contextDescriptor);
|
||||
MethodVisitor mv =
|
||||
v.newMethod(JvmDeclarationOriginKt.OtherOrigin(contextDescriptor), ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInitDescriptor), state, this);
|
||||
}
|
||||
return clInit;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MethodVisitor createClInitMethodVisitor(@NotNull DeclarationDescriptor contextDescriptor) {
|
||||
return v.newMethod(JvmDeclarationOriginKt.OtherOrigin(contextDescriptor), ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SimpleFunctionDescriptorImpl createClInitFunctionDescriptor(@NotNull DeclarationDescriptor descriptor) {
|
||||
SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(),
|
||||
@@ -496,9 +492,6 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeMethodBody(@NotNull MethodVisitor mv) {
|
||||
}
|
||||
|
||||
// Requires public access, because it is used by serialization plugin to generate initializer in synthetic constructor
|
||||
public void initializeProperty(@NotNull ExpressionCodegen codegen, @NotNull KtProperty property) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil
|
||||
import org.jetbrains.kotlin.codegen.context.MultifileClassPartContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
@@ -28,13 +27,8 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtTypeAlias
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
|
||||
|
||||
class MultifileClassPartCodegen(
|
||||
v: ClassBuilder,
|
||||
@@ -47,31 +41,13 @@ class MultifileClassPartCodegen(
|
||||
) : MemberCodegen<KtFile>(state, null, partContext, file, v) {
|
||||
private val partType = partContext.filePartType
|
||||
private val facadeClassType = partContext.multifileClassType
|
||||
private val staticInitClassType = Type.getObjectType(partType.internalName + STATIC_INIT_CLASS_SUFFIX)
|
||||
|
||||
private val partClassAttributes =
|
||||
if (shouldGeneratePartHierarchy)
|
||||
OPEN_PART_CLASS_ATTRIBUTES
|
||||
else
|
||||
FINAL_PART_CLASS_ATTRIBUTES
|
||||
|
||||
private fun ClassBuilder.newSpecialMethod(originDescriptor: DeclarationDescriptor, name: String) =
|
||||
newMethod(OtherOrigin(originDescriptor), Opcodes.ACC_STATIC, name, "()V", null, null)
|
||||
|
||||
private val staticInitClassBuilder = ClassBuilderOnDemand {
|
||||
state.factory.newVisitor(MultifileClass(file, packageFragment), staticInitClassType, file).apply {
|
||||
defineClass(file, state.classFileVersion, STATE_INITIALIZER_CLASS_ATTRIBUTES,
|
||||
staticInitClassType.internalName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
|
||||
visitSource(file.name, null)
|
||||
init {
|
||||
if (shouldGeneratePartHierarchy && file.declarations.any { it is KtProperty && shouldInitializeProperty(it) }) {
|
||||
throw AssertionError("State is not allowed in multi-file classes with -Xmultifile-parts-inherit")
|
||||
}
|
||||
}
|
||||
|
||||
private val requiresDeferredStaticInitialization =
|
||||
shouldGeneratePartHierarchy && file.declarations.any {
|
||||
it is KtProperty && shouldInitializeProperty(it)
|
||||
}
|
||||
|
||||
override fun generate() {
|
||||
if (!state.classBuilderMode.generateMultiFileFacadePartClasses) return
|
||||
|
||||
@@ -91,41 +67,15 @@ class MultifileClassPartCodegen(
|
||||
visitEnd()
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresDeferredStaticInitialization) {
|
||||
staticInitClassBuilder.apply {
|
||||
newField(OtherOrigin(packageFragment), Opcodes.ACC_STATIC or Opcodes.ACC_PRIVATE or Opcodes.ACC_VOLATILE,
|
||||
CLINIT_SYNC_NAME, "I", null, null)
|
||||
|
||||
newSpecialMethod(packageFragment, CLINIT_TRIGGER_NAME).apply {
|
||||
if (generateBodies) {
|
||||
visitCode()
|
||||
visitFieldInsn(Opcodes.GETSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 0)
|
||||
}
|
||||
visitEnd()
|
||||
}
|
||||
|
||||
newSpecialMethod(packageFragment, "<clinit>").apply {
|
||||
if (generateBodies) {
|
||||
visitCode()
|
||||
visitMethodInsn(Opcodes.INVOKESTATIC, partType.internalName, DEFERRED_PART_CLINIT_NAME, "()V", false)
|
||||
visitInsn(Opcodes.ICONST_0)
|
||||
visitFieldInsn(Opcodes.PUTSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
|
||||
visitInsn(Opcodes.RETURN)
|
||||
visitMaxs(1, 0)
|
||||
}
|
||||
visitEnd()
|
||||
}
|
||||
|
||||
writeSyntheticClassMetadata(this, state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateDeclaration() {
|
||||
v.defineClass(element, state.classFileVersion, partClassAttributes, partType.internalName, null, superClassInternalName, ArrayUtil.EMPTY_STRING_ARRAY)
|
||||
val access = if (shouldGeneratePartHierarchy) 0 else Opcodes.ACC_SYNTHETIC or Opcodes.ACC_FINAL
|
||||
|
||||
v.defineClass(
|
||||
element, state.classFileVersion, access or Opcodes.ACC_SUPER, partType.internalName, null, superClassInternalName,
|
||||
ArrayUtil.EMPTY_STRING_ARRAY
|
||||
)
|
||||
v.visitSource(element.name, null)
|
||||
|
||||
generatePropertyMetadataArrayFieldIfNeeded(partType)
|
||||
@@ -143,20 +93,6 @@ class MultifileClassPartCodegen(
|
||||
}
|
||||
}
|
||||
|
||||
override fun createClInitMethodVisitor(contextDescriptor: DeclarationDescriptor): MethodVisitor =
|
||||
if (requiresDeferredStaticInitialization)
|
||||
v.newSpecialMethod(contextDescriptor, DEFERRED_PART_CLINIT_NAME)
|
||||
else
|
||||
super.createClInitMethodVisitor(contextDescriptor)
|
||||
|
||||
override fun done() {
|
||||
super.done()
|
||||
|
||||
if (staticInitClassBuilder.isComputed) {
|
||||
staticInitClassBuilder.done()
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateKotlinMetadataAnnotation() {
|
||||
val (serializer, packageProto) = PackagePartCodegen.serializePackagePartMembers(this, partType)
|
||||
|
||||
@@ -171,28 +107,4 @@ class MultifileClassPartCodegen(
|
||||
override fun generateSyntheticPartsAfterBody() {
|
||||
generateSyntheticAccessors()
|
||||
}
|
||||
|
||||
override fun beforeMethodBody(mv: MethodVisitor) {
|
||||
if (requiresDeferredStaticInitialization) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, staticInitClassType.internalName, CLINIT_TRIGGER_NAME, "()V", false)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val OPEN_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SUPER
|
||||
private val FINAL_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
|
||||
private val STATE_INITIALIZER_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
|
||||
|
||||
private val STATIC_INIT_CLASS_SUFFIX = "__Clinit"
|
||||
private val CLINIT_TRIGGER_NAME = "\$\$clinitTrigger"
|
||||
private val CLINIT_SYNC_NAME = "\$\$clinitSync"
|
||||
private val DEFERRED_PART_CLINIT_NAME = "\$\$clinit"
|
||||
|
||||
@JvmStatic fun isStaticInitTrigger(insn: AbstractInsnNode) =
|
||||
insn.opcode == Opcodes.INVOKESTATIC
|
||||
&& insn is MethodInsnNode
|
||||
&& insn.owner.endsWith(STATIC_INIT_CLASS_SUFFIX)
|
||||
&& insn.name == CLINIT_TRIGGER_NAME
|
||||
&& insn.desc == "()V"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
sourceCompiler.generateAndInsertFinallyBlocks(
|
||||
adapter, infos, (remapper.remap(parameters.argsSizeOnStack + 1).value as StackValue.Local).index
|
||||
)
|
||||
removeStaticInitializationTrigger(adapter)
|
||||
if (!sourceCompiler.isFinallyMarkerRequired()) {
|
||||
removeFinallyMarkers(adapter)
|
||||
}
|
||||
@@ -588,21 +587,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
return (name == "arrayOf" || name == "emptyArray") && callableDescriptor.containingDeclaration is BuiltInsPackageFragment
|
||||
}
|
||||
|
||||
private fun removeStaticInitializationTrigger(methodNode: MethodNode) {
|
||||
val insnList = methodNode.instructions
|
||||
var insn: AbstractInsnNode? = insnList.first
|
||||
while (insn != null) {
|
||||
if (MultifileClassPartCodegen.isStaticInitTrigger(insn)) {
|
||||
val clinitTriggerCall = insn
|
||||
insn = insn.next
|
||||
insnList.remove(clinitTriggerCall)
|
||||
} else {
|
||||
insn = insn.next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*descriptor is null for captured vars*/
|
||||
private fun shouldPutGeneralValue(type: Type, kotlinType: KotlinType?, stackValue: StackValue): Boolean {
|
||||
//remap only inline functions (and maybe non primitives)
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
|
||||
import org.jetbrains.kotlin.config.JvmAnalysisFlags
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
|
||||
object JvmMultifileClassStateChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (descriptor !is PropertyDescriptor ||
|
||||
!DescriptorUtils.isTopLevelDeclaration(descriptor) ||
|
||||
descriptor.isExpect ||
|
||||
descriptor.isConst) return
|
||||
|
||||
if (!context.languageVersionSettings.getFlag(JvmAnalysisFlags.inheritMultifileParts)) return
|
||||
|
||||
if (!JvmFileClassUtil.getFileClassInfoNoResolve(declaration.containingKtFile).withJvmMultifileClass) return
|
||||
|
||||
if (@Suppress("DEPRECATION") descriptor.isDelegated ||
|
||||
context.trace.bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor) == true) {
|
||||
context.trace.report(ErrorsJvm.STATE_IN_MULTIFILE_CLASS.on(declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -72,6 +72,8 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(JVM_PACKAGE_NAME_MUST_BE_VALID_NAME, "''@JvmPackageName'' annotation value must be a valid dot-qualified name of a package");
|
||||
MAP.put(JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES, "''@JvmPackageName'' annotation is not supported for files with class declarations");
|
||||
|
||||
MAP.put(STATE_IN_MULTIFILE_CLASS, "Non-const property with backing field or delegate is not allowed in a multi-file class if -Xmultifile-parts-inherit is enabled");
|
||||
|
||||
MAP.put(NO_REFLECTION_IN_CLASS_PATH, "Call uses reflection API which is not found in compilation classpath. " +
|
||||
"Make sure you have kotlin-reflect.jar in the classpath");
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_MUST_BE_VALID_NAME = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtDeclaration> STATE_IN_MULTIFILE_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
+2
-1
@@ -37,7 +37,8 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase(
|
||||
StrictfpApplicabilityChecker(),
|
||||
ExpectedActualDeclarationChecker(listOf(JavaActualAnnotationArgumentExtractor())),
|
||||
JvmAnnotationsTargetNonExistentAccessorChecker(),
|
||||
BadInheritedJavaSignaturesChecker
|
||||
BadInheritedJavaSignaturesChecker,
|
||||
JvmMultifileClassStateChecker
|
||||
),
|
||||
|
||||
additionalCallCheckers = listOf(
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ fun box(): String = ::OK.get()
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val OK = run { "OK" }
|
||||
const val OK = "OK"
|
||||
+1
-1
@@ -13,7 +13,7 @@ fun box(): String = okInline()
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
internal val ok = run { "OK" }
|
||||
internal const val ok = "OK"
|
||||
|
||||
internal inline fun okInline() =
|
||||
::ok.get()
|
||||
+1
-1
@@ -13,7 +13,7 @@ fun box(): String = OK.okRef.get()
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val ok = run { "OK" }
|
||||
private const val ok = "OK"
|
||||
|
||||
object OK {
|
||||
val okRef = ::ok
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val O = run { "O" }
|
||||
|
||||
// FILE: part2.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
const val K = "K"
|
||||
|
||||
// FILE: part3.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val OK: String = run { O + K }
|
||||
|
||||
// FILE: irrelevantPart.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val X1: Nothing =
|
||||
throw AssertionError("X1 should not be initialized")
|
||||
|
||||
// FILE: reallyIrrelevantPart.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val X2: Nothing =
|
||||
throw AssertionError("X2 should not be initialized")
|
||||
@@ -1,16 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val OK: String by lazy { "OK" }
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = ok()
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val OK = run { "OK" }
|
||||
|
||||
fun ok() = OK
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
public val OK = run { "OK" }
|
||||
@@ -1,30 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = ok()
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val overlapping = run { "oops #1" }
|
||||
|
||||
// FILE: part2.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val overlapping = run { "OK" }
|
||||
|
||||
fun ok() = overlapping
|
||||
|
||||
// FILE: part3.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val overlapping = run { "oops #2" }
|
||||
Vendored
-30
@@ -1,30 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = J.ok()
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MC") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val O = run { "O" }
|
||||
const val K = "K"
|
||||
|
||||
inline fun ok(): String {
|
||||
return O + K
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
import a.MC;
|
||||
|
||||
public class J {
|
||||
public static String ok() {
|
||||
return MC.ok();
|
||||
}
|
||||
}
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = ok {}
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
val O = run { "O" }
|
||||
const val K = "K"
|
||||
|
||||
inline fun ok(block: () -> Unit): String {
|
||||
block()
|
||||
return O + K
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// WITH_RUNTIME
|
||||
// !INHERIT_MULTIFILE_PARTS
|
||||
// FILE: box.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String = OK().ok
|
||||
|
||||
// FILE: part1.kt
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
private val reallyOk = run { "OK" }
|
||||
|
||||
class OK() {
|
||||
val ok = reallyOk
|
||||
}
|
||||
+11
-51
@@ -15714,24 +15714,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multifileClasses/optimized"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToConstVal.kt")
|
||||
public void testCallableRefToConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToFun.kt")
|
||||
public void testCallableRefToFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToInternalValInline.kt")
|
||||
public void testCallableRefToInternalValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt");
|
||||
@TestMetadata("callableRefToInternalConstValInline.kt")
|
||||
public void testCallableRefToInternalConstValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalConstValInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToPrivateVal.kt")
|
||||
public void testCallableRefToPrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToVal.kt")
|
||||
public void testCallableRefToVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToVal.kt");
|
||||
@TestMetadata("callableRefToPrivateConstVal.kt")
|
||||
public void testCallableRefToPrivateConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("calls.kt")
|
||||
@@ -15739,50 +15739,10 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/calls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deferredStaticInitialization.kt")
|
||||
public void testDeferredStaticInitialization() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedVal.kt")
|
||||
public void testDelegatedVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/delegatedVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePrivateVal.kt")
|
||||
public void testInitializePrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePublicVal.kt")
|
||||
public void testInitializePublicVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePublicVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingFuns.kt")
|
||||
public void testOverlappingFuns() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingVals.kt")
|
||||
public void testOverlappingVals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingVals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlineFunCalledFromJava.kt")
|
||||
public void testValAccessFromInlineFunCalledFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlinedToDifferentPackage.kt")
|
||||
public void testValAccessFromInlinedToDifferentPackage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valWithAccessor.kt")
|
||||
public void testValWithAccessor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valWithAccessor.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-51
@@ -15714,24 +15714,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multifileClasses/optimized"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToConstVal.kt")
|
||||
public void testCallableRefToConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToFun.kt")
|
||||
public void testCallableRefToFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToInternalValInline.kt")
|
||||
public void testCallableRefToInternalValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt");
|
||||
@TestMetadata("callableRefToInternalConstValInline.kt")
|
||||
public void testCallableRefToInternalConstValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalConstValInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToPrivateVal.kt")
|
||||
public void testCallableRefToPrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToVal.kt")
|
||||
public void testCallableRefToVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToVal.kt");
|
||||
@TestMetadata("callableRefToPrivateConstVal.kt")
|
||||
public void testCallableRefToPrivateConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("calls.kt")
|
||||
@@ -15739,50 +15739,10 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/calls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deferredStaticInitialization.kt")
|
||||
public void testDeferredStaticInitialization() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedVal.kt")
|
||||
public void testDelegatedVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/delegatedVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePrivateVal.kt")
|
||||
public void testInitializePrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePublicVal.kt")
|
||||
public void testInitializePublicVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePublicVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingFuns.kt")
|
||||
public void testOverlappingFuns() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingVals.kt")
|
||||
public void testOverlappingVals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingVals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlineFunCalledFromJava.kt")
|
||||
public void testValAccessFromInlineFunCalledFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlinedToDifferentPackage.kt")
|
||||
public void testValAccessFromInlinedToDifferentPackage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valWithAccessor.kt")
|
||||
public void testValWithAccessor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valWithAccessor.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-51
@@ -15719,24 +15719,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multifileClasses/optimized"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToConstVal.kt")
|
||||
public void testCallableRefToConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToFun.kt")
|
||||
public void testCallableRefToFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToInternalValInline.kt")
|
||||
public void testCallableRefToInternalValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalValInline.kt");
|
||||
@TestMetadata("callableRefToInternalConstValInline.kt")
|
||||
public void testCallableRefToInternalConstValInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToInternalConstValInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToPrivateVal.kt")
|
||||
public void testCallableRefToPrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableRefToVal.kt")
|
||||
public void testCallableRefToVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToVal.kt");
|
||||
@TestMetadata("callableRefToPrivateConstVal.kt")
|
||||
public void testCallableRefToPrivateConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/callableRefToPrivateConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("calls.kt")
|
||||
@@ -15744,50 +15744,10 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/calls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deferredStaticInitialization.kt")
|
||||
public void testDeferredStaticInitialization() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/deferredStaticInitialization.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedVal.kt")
|
||||
public void testDelegatedVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/delegatedVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePrivateVal.kt")
|
||||
public void testInitializePrivateVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePrivateVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializePublicVal.kt")
|
||||
public void testInitializePublicVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/initializePublicVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingFuns.kt")
|
||||
public void testOverlappingFuns() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingFuns.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overlappingVals.kt")
|
||||
public void testOverlappingVals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/overlappingVals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlineFunCalledFromJava.kt")
|
||||
public void testValAccessFromInlineFunCalledFromJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlineFunCalledFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valAccessFromInlinedToDifferentPackage.kt")
|
||||
public void testValAccessFromInlinedToDifferentPackage() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valAccessFromInlinedToDifferentPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valWithAccessor.kt")
|
||||
public void testValWithAccessor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/multifileClasses/optimized/valWithAccessor.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user