[FE 1.0] Issue a warning if expect and actual are declared in the same module
The commit is based on b09561c3c3
Co-authored-by: Dmitriy Novozhilov <dmitriy.novozhilov@jetbrains.com>
^KT-40904 Fixed
^KT-55177 Fixed
Review: https://jetbrains.team/p/kt/reviews/8731
True negative test already exist:
`compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/intermediateWithActualAndExpect.kt`
This commit is contained in:
+6
@@ -22002,6 +22002,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectAndActualInTheSameModule.kt")
|
||||||
|
public void testExpectAndActualInTheSameModule() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateWithActualAndExpect.kt")
|
@TestMetadata("intermediateWithActualAndExpect.kt")
|
||||||
public void testIntermediateWithActualAndExpect() throws Exception {
|
public void testIntermediateWithActualAndExpect() throws Exception {
|
||||||
|
|||||||
+6
@@ -22008,6 +22008,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectAndActualInTheSameModule.kt")
|
||||||
|
public void testExpectAndActualInTheSameModule() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateWithActualAndExpect.kt")
|
@TestMetadata("intermediateWithActualAndExpect.kt")
|
||||||
public void testIntermediateWithActualAndExpect() throws Exception {
|
public void testIntermediateWithActualAndExpect() throws Exception {
|
||||||
|
|||||||
+6
@@ -22002,6 +22002,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectAndActualInTheSameModule.kt")
|
||||||
|
public void testExpectAndActualInTheSameModule() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateWithActualAndExpect.kt")
|
@TestMetadata("intermediateWithActualAndExpect.kt")
|
||||||
public void testIntermediateWithActualAndExpect() throws Exception {
|
public void testIntermediateWithActualAndExpect() throws Exception {
|
||||||
|
|||||||
@@ -804,6 +804,8 @@ public interface Errors {
|
|||||||
DiagnosticFactory2.create(ERROR, ACTUAL_DECLARATION_NAME);
|
DiagnosticFactory2.create(ERROR, ACTUAL_DECLARATION_NAME);
|
||||||
DiagnosticFactory0<KtNamedDeclaration> ACTUAL_MISSING = DiagnosticFactory0.create(ERROR, ACTUAL_DECLARATION_NAME);
|
DiagnosticFactory0<KtNamedDeclaration> ACTUAL_MISSING = DiagnosticFactory0.create(ERROR, ACTUAL_DECLARATION_NAME);
|
||||||
|
|
||||||
|
DiagnosticFactory1<KtNamedDeclaration, MemberDescriptor> EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||||
|
|
||||||
DiagnosticFactory0<PsiElement> OPTIONAL_EXPECTATION_NOT_ON_EXPECTED = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> OPTIONAL_EXPECTATION_NOT_ON_EXPECTED = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE = DiagnosticFactory0.create(ERROR);
|
||||||
|
|||||||
+3
@@ -339,6 +339,9 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
||||||
NAME, adaptGenerics2(IncompatibleExpectedActualClassScopesRenderer.TEXT));
|
NAME, adaptGenerics2(IncompatibleExpectedActualClassScopesRenderer.TEXT));
|
||||||
MAP.put(ACTUAL_MISSING, "Declaration must be marked with 'actual'");
|
MAP.put(ACTUAL_MISSING, "Declaration must be marked with 'actual'");
|
||||||
|
MAP.put(EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE,
|
||||||
|
"{0}: expect and corresponding actual are declared in the same module, which will be prohibited in Kotlin 2.0. See https://youtrack.jetbrains.com/issue/KT-55177",
|
||||||
|
CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM);
|
||||||
|
|
||||||
MAP.put(OPTIONAL_EXPECTATION_NOT_ON_EXPECTED, "'@OptionalExpectation' can only be used on an expected annotation class");
|
MAP.put(OPTIONAL_EXPECTATION_NOT_ON_EXPECTED, "'@OptionalExpectation' can only be used on an expected annotation class");
|
||||||
MAP.put(OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY, "Declaration annotated with '@OptionalExpectation' can only be used inside an annotation entry");
|
MAP.put(OPTIONAL_DECLARATION_OUTSIDE_OF_ANNOTATION_ENTRY, "Declaration annotated with '@OptionalExpectation' can only be used inside an annotation entry");
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
|||||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||||
|
|
||||||
private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
||||||
|
ExpectActualInTheSameModuleChecker,
|
||||||
DataClassDeclarationChecker(),
|
DataClassDeclarationChecker(),
|
||||||
ConstModifierChecker,
|
ConstModifierChecker,
|
||||||
UnderscoreChecker,
|
UnderscoreChecker,
|
||||||
|
|||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* 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.checkers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||||
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
|
import org.jetbrains.kotlin.platform.isCommon
|
||||||
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
|
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
|
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
|
||||||
|
import org.jetbrains.kotlin.resolve.multiplatform.isCommonSource
|
||||||
|
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||||
|
|
||||||
|
object ExpectActualInTheSameModuleChecker : DeclarationChecker {
|
||||||
|
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||||
|
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) return
|
||||||
|
if (descriptor !is MemberDescriptor) return
|
||||||
|
if (declaration !is KtNamedDeclaration) return
|
||||||
|
if (!descriptor.isExpect) return
|
||||||
|
// Only look for top level actual members; class members will be handled as a part of that expected class
|
||||||
|
if (descriptor.containingDeclaration !is PackageFragmentDescriptor) return
|
||||||
|
val module = descriptor.module
|
||||||
|
val actuals = ExpectedActualResolver.findActualForExpected(descriptor, module)?.flatMap { it.value }
|
||||||
|
?.takeIf(List<MemberDescriptor>::isNotEmpty) ?: return
|
||||||
|
|
||||||
|
// There are 4 cases:
|
||||||
|
// 1. `expect` in common module, `actual` in platform module. It's a legal situation. In K2MetadataCompiler compiler, the
|
||||||
|
// declarations have different modules. In backend specific compiler, `expect` declaration is in common module so warning won't
|
||||||
|
// be issued
|
||||||
|
// 2. `expect` in common module X, `actual` in common module Y (Y depends on X). It's a legal situation. In K2MetadataCompiler
|
||||||
|
// compiler, the declarations have different modules. In backend specific compiler, `expect` declaration is in common so warning
|
||||||
|
// won't be issued
|
||||||
|
// 3. `expect` in common module X, `actual` in the very same common module X. It's an illegal situation. In K2MetadataCompiler
|
||||||
|
// compiler, the declarations have the same module, so the warning will be issue. In backend specific compiler, `expect`
|
||||||
|
// declaration is in common so warning won't be issued
|
||||||
|
// 4. `expect` in platform module X, `actual` in the very same platform module X. It's an illegal situation. K2MetadataCompiler is
|
||||||
|
// invoked only for common modules, so it won't issue a warning. In backend specific compiler, `expect` declaration is in
|
||||||
|
// platform module, the warning will be issued
|
||||||
|
//
|
||||||
|
// The checker doesn't consider cases when platform module depend on another platform module.
|
||||||
|
if (module.platform.isCommon()) { /* If true then we are in K2MetadataCompiler. `isCommon` never returns `true` in backend specific
|
||||||
|
compilers (even when the source is truly common) */
|
||||||
|
// modules can be distinguished only in K2MetadataCompiler because in platform specific compiler all sources are put in
|
||||||
|
// a single module
|
||||||
|
if (actuals.all { it.module != module }) return
|
||||||
|
} else { // backend specific compiler
|
||||||
|
if (declaration.containingKtFile.isCommonSource == true) return
|
||||||
|
}
|
||||||
|
|
||||||
|
context.trace.report(Errors.EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE.on(declaration, descriptor))
|
||||||
|
for (actual in actuals) {
|
||||||
|
val actualSource = actual.declarationSource ?: continue
|
||||||
|
context.trace.report(Errors.EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE.on(actualSource, descriptor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val MemberDescriptor.declarationSource: KtNamedDeclaration?
|
||||||
|
get() = (this.source as? KotlinSourceElement)?.psi as? KtNamedDeclaration
|
||||||
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@Suppress("INLINE_CLASS_DEPRECATED", "EXPERIMENTAL_FEATURE_WARNING")
|
@Suppress("INLINE_CLASS_DEPRECATED", "EXPERIMENTAL_FEATURE_WARNING")
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@kotlin.jvm.JvmInline
|
@kotlin.jvm.JvmInline
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
// SKIP_TXT
|
// SKIP_TXT
|
||||||
// Issue: KT-49714
|
// Issue: KT-49714
|
||||||
|
|
||||||
expect class Counter {
|
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class Counter<!> {
|
||||||
operator fun inc(): Counter
|
operator fun inc(): Counter
|
||||||
operator fun dec(): Counter
|
operator fun dec(): Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
actual typealias Counter = Int
|
actual typealias <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>Counter<!> = Int
|
||||||
|
|||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
// MODULE: common
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
expect class CommonClass {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class CommonClass {
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||||
|
}<!>
|
||||||
|
|
||||||
|
expect fun commonFun()
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun commonFun() {}<!>
|
||||||
|
|
||||||
|
expect val commonProperty: String
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val commonProperty: String
|
||||||
|
get() = "hello"<!>
|
||||||
|
|
||||||
|
// MODULE: intermediate()()(common)
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
expect class IntermediateClass {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class IntermediateClass {
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||||
|
}<!>
|
||||||
|
|
||||||
|
expect fun intermediateFun()
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun intermediateFun() {}<!>
|
||||||
|
|
||||||
|
expect val intermediateProperty: String
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val intermediateProperty: String
|
||||||
|
get() = "hello"<!>
|
||||||
|
|
||||||
|
// MODULE: main()()(intermediate)
|
||||||
|
expect class PlatformClass {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class PlatformClass {
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun memberFun() {}<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val memberProp: Int = 42<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual class Nested<!>
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual inner class Inner<!>
|
||||||
|
}<!>
|
||||||
|
|
||||||
|
expect fun platformFun()
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual fun platformFun() {}<!>
|
||||||
|
|
||||||
|
expect val platformProperty: String
|
||||||
|
<!ACTUAL_WITHOUT_EXPECT!>actual val platformProperty: String
|
||||||
|
get() = "hello"<!>
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
// MODULE: common
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CommonClass<!> {
|
||||||
|
actual fun memberFun() {}
|
||||||
|
actual val memberProp: Int = 42
|
||||||
|
actual class Nested
|
||||||
|
actual inner class Inner
|
||||||
|
}
|
||||||
|
|
||||||
|
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonFun<!>()
|
||||||
|
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonFun<!>() {}
|
||||||
|
|
||||||
|
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonProperty<!>: String
|
||||||
|
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>commonProperty<!>: String
|
||||||
|
get() = "hello"
|
||||||
|
|
||||||
|
// MODULE: intermediate()()(common)
|
||||||
|
// TARGET_PLATFORM: Common
|
||||||
|
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class IntermediateClass<!> {
|
||||||
|
actual fun memberFun() {}
|
||||||
|
actual val memberProp: Int = 42
|
||||||
|
actual class Nested
|
||||||
|
actual inner class Inner
|
||||||
|
}
|
||||||
|
|
||||||
|
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateFun<!>()
|
||||||
|
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateFun<!>() {}
|
||||||
|
|
||||||
|
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateProperty<!>: String
|
||||||
|
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>intermediateProperty<!>: String
|
||||||
|
get() = "hello"
|
||||||
|
|
||||||
|
// MODULE: main()()(intermediate)
|
||||||
|
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> {
|
||||||
|
fun memberFun()
|
||||||
|
val memberProp: Int
|
||||||
|
class Nested
|
||||||
|
inner class Inner
|
||||||
|
}
|
||||||
|
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class PlatformClass<!> {
|
||||||
|
actual fun memberFun() {}
|
||||||
|
actual val memberProp: Int = 42
|
||||||
|
actual class Nested
|
||||||
|
actual inner class Inner
|
||||||
|
}
|
||||||
|
|
||||||
|
expect fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformFun<!>()
|
||||||
|
actual fun <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformFun<!>() {}
|
||||||
|
|
||||||
|
expect val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformProperty<!>: String
|
||||||
|
actual val <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>platformProperty<!>: String
|
||||||
|
get() = "hello"
|
||||||
+130
@@ -0,0 +1,130 @@
|
|||||||
|
// -- Module: <common> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public actual val commonProperty: kotlin.String
|
||||||
|
public expect val commonProperty: kotlin.String
|
||||||
|
public actual fun commonFun(): kotlin.Unit
|
||||||
|
public expect fun commonFun(): kotlin.Unit
|
||||||
|
|
||||||
|
public final actual class CommonClass {
|
||||||
|
public constructor CommonClass()
|
||||||
|
public actual final val memberProp: kotlin.Int = 42
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final actual fun memberFun(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final actual inner class Inner {
|
||||||
|
public constructor Inner()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final actual class Nested {
|
||||||
|
public constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final expect class CommonClass {
|
||||||
|
public expect final val memberProp: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final expect fun memberFun(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final expect inner class Inner {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final expect class Nested {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Module: <intermediate> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public actual val intermediateProperty: kotlin.String
|
||||||
|
public expect val intermediateProperty: kotlin.String
|
||||||
|
public actual fun intermediateFun(): kotlin.Unit
|
||||||
|
public expect fun intermediateFun(): kotlin.Unit
|
||||||
|
|
||||||
|
public final actual class IntermediateClass {
|
||||||
|
public constructor IntermediateClass()
|
||||||
|
public actual final val memberProp: kotlin.Int = 42
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final actual fun memberFun(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final actual inner class Inner {
|
||||||
|
public constructor Inner()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final actual class Nested {
|
||||||
|
public constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final expect class IntermediateClass {
|
||||||
|
public expect final val memberProp: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final expect fun memberFun(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final expect inner class Inner {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final expect class Nested {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Module: <main> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public actual val platformProperty: kotlin.String
|
||||||
|
public actual fun platformFun(): kotlin.Unit
|
||||||
|
|
||||||
|
public final actual class PlatformClass {
|
||||||
|
public constructor PlatformClass()
|
||||||
|
public actual final val memberProp: kotlin.Int = 42
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final actual fun memberFun(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final actual inner class Inner {
|
||||||
|
public constructor Inner()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final actual class Nested {
|
||||||
|
public constructor Nested()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -22008,6 +22008,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectAndActualInTheSameModule.kt")
|
||||||
|
public void testExpectAndActualInTheSameModule() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/expectAndActualInTheSameModule.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intermediateWithActualAndExpect.kt")
|
@TestMetadata("intermediateWithActualAndExpect.kt")
|
||||||
public void testIntermediateWithActualAndExpect() throws Exception {
|
public void testIntermediateWithActualAndExpect() throws Exception {
|
||||||
|
|||||||
+2
-2
@@ -409,8 +409,8 @@ class ClassicFrontendFacade(
|
|||||||
override fun registerDependencyForAllModules(moduleInfo: ModuleInfo, descriptorForModule: ModuleDescriptorImpl) = Unit
|
override fun registerDependencyForAllModules(moduleInfo: ModuleInfo, descriptorForModule: ModuleDescriptorImpl) = Unit
|
||||||
override fun packageFragmentProviderForModuleInfo(moduleInfo: ModuleInfo): PackageFragmentProvider? = null
|
override fun packageFragmentProviderForModuleInfo(moduleInfo: ModuleInfo): PackageFragmentProvider? = null
|
||||||
|
|
||||||
override val friendModuleInfos: List<ModuleInfo> get() = emptyList()
|
override val friendModuleInfos: List<ModuleInfo> = _moduleInfos.filter { it.module.shouldSeeInternalsOf(module) }
|
||||||
override val refinesModuleInfos: List<ModuleInfo> get() = emptyList()
|
override val refinesModuleInfos: List<ModuleInfo> = _moduleInfos.filter { it.module in module.allExpectedByModules }
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test.collections.js
|
package test.collections.js
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@@ -33,4 +34,4 @@ public expect object BackReferenceHandling {
|
|||||||
val nonExistentGroup: HandlingOption
|
val nonExistentGroup: HandlingOption
|
||||||
val nonExistentNamedGroup: HandlingOption
|
val nonExistentNamedGroup: HandlingOption
|
||||||
val groupZero: HandlingOption
|
val groupZero: HandlingOption
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test.collections.js
|
package test.collections.js
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
@@ -38,4 +39,4 @@ public actual object BackReferenceHandling {
|
|||||||
actual val nonExistentGroup: HandlingOption = HandlingOption.MATCH_NOTHING
|
actual val nonExistentGroup: HandlingOption = HandlingOption.MATCH_NOTHING
|
||||||
actual val nonExistentNamedGroup: HandlingOption = HandlingOption.THROW
|
actual val nonExistentNamedGroup: HandlingOption = HandlingOption.THROW
|
||||||
actual val groupZero: HandlingOption = HandlingOption.THROW
|
actual val groupZero: HandlingOption = HandlingOption.THROW
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user