[FIR] Fix disappeared ACTUAL_MISSING

^KT-59887 Fixed

Review: https://jetbrains.team/p/kt/reviews/13244
This commit is contained in:
Nikita Bobko
2023-11-20 17:40:06 +01:00
committed by Space Team
parent e44e84d1b0
commit 8c0cf7d0bc
80 changed files with 244 additions and 217 deletions
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription
import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.isActual
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirResolvable
@@ -108,7 +109,7 @@ internal fun checkStatementsAreResolved(script: FirScript) {
}
internal fun checkExpectForActualIsResolved(memberDeclaration: FirMemberDeclaration) {
if (!memberDeclaration.isActual) return
if (memberDeclaration.isExpect) return
checkWithAttachment(
condition = memberDeclaration.expectForActual != null,
@@ -1,3 +1,4 @@
// LANGUAGE: +MultiPlatformProjects
fun main() {
println("Hello, Kotlin/Native!")
}
@@ -10,6 +10,6 @@ FILE: [ResolvedTo(IMPORTS)] expectAndActualInTheSameFile.kt
public? final? [ResolvedTo(RAW_FIR)] fun main(): R|kotlin/Unit| { LAZY_BLOCK }
public? final? expect [ResolvedTo(RAW_FIR)] fun f(): R|kotlin/Unit|
public? final? [ResolvedTo(RAW_FIR)] fun test(): R|kotlin/Unit| { LAZY_BLOCK }
public final actual [ResolvedTo(BODY_RESOLVE)] fun f(): R|kotlin/Unit| {
public final actual [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] fun f(): R|kotlin/Unit| {
<Unresolved name: println>#(String(Hello))
}
@@ -1,3 +1,4 @@
// LANGUAGE: +MultiPlatformProjects
actual class Ac<caret>tual {
fun memberFun() {}
val a = 1
@@ -161,7 +161,7 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
EXPECT_ACTUAL_MATCHING:
FILE: [ResolvedTo(IMPORTS)] actual.kt
public final actual [ResolvedTo(EXPECT_ACTUAL_MATCHING)] class Actual : R|kotlin/Any| {
public final actual [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Actual] constructor(): R|Actual| {
LAZY_super<R|kotlin/Any|>
}
@@ -184,7 +184,7 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
CONTRACTS:
FILE: [ResolvedTo(IMPORTS)] actual.kt
public final actual [ResolvedTo(CONTRACTS)] class Actual : R|kotlin/Any| {
public final actual [ResolvedTo(CONTRACTS)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Actual] constructor(): R|Actual| {
LAZY_super<R|kotlin/Any|>
}
@@ -207,7 +207,7 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] actual.kt
public final actual [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] class Actual : R|kotlin/Any| {
public final actual [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Actual] constructor(): R|Actual| {
LAZY_super<R|kotlin/Any|>
}
@@ -230,7 +230,7 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
ANNOTATION_ARGUMENTS:
FILE: [ResolvedTo(IMPORTS)] actual.kt
public final actual [ResolvedTo(ANNOTATION_ARGUMENTS)] class Actual : R|kotlin/Any| {
public final actual [ResolvedTo(ANNOTATION_ARGUMENTS)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Actual] constructor(): R|Actual| {
LAZY_super<R|kotlin/Any|>
}
@@ -253,14 +253,14 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] actual.kt
public final actual [ResolvedTo(BODY_RESOLVE)] class Actual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual] constructor(): R|Actual| {
public final actual [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual, ExpectForActualAttributeKey={}] constructor(): R|Actual| {
super<R|kotlin/Any|>()
}
public final [ResolvedTo(STATUS)] fun memberFun(): R|kotlin/Unit| { LAZY_BLOCK }
public final [ResolvedTo(BODY_RESOLVE)] val a: R|kotlin/Int| = Int(1)
public final [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] val a: R|kotlin/Int| = Int(1)
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual] get(): R|kotlin/Int|
public? final? actual [ResolvedTo(RAW_FIR)] class NestedActual : R|kotlin/Any| {
@@ -276,23 +276,23 @@ FILE: [ResolvedTo(IMPORTS)] actual.kt
FILE RAW TO BODY:
FILE: [ResolvedTo(BODY_RESOLVE)] actual.kt
public final actual [ResolvedTo(BODY_RESOLVE)] class Actual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual] constructor(): R|Actual| {
public final actual [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] class Actual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual, ExpectForActualAttributeKey={}] constructor(): R|Actual| {
super<R|kotlin/Any|>()
}
public final [ResolvedTo(BODY_RESOLVE)] fun memberFun(): R|kotlin/Unit| {
public final [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] fun memberFun(): R|kotlin/Unit| {
}
public final [ResolvedTo(BODY_RESOLVE)] val a: R|kotlin/Int| = Int(1)
public final [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] val a: R|kotlin/Int| = Int(1)
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Actual] get(): R|kotlin/Int|
public final actual [ResolvedTo(BODY_RESOLVE)] class NestedActual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=NestedActual] constructor(): R|Actual.NestedActual| {
public final actual [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] class NestedActual : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=NestedActual, ExpectForActualAttributeKey={}] constructor(): R|Actual.NestedActual| {
super<R|kotlin/Any|>()
}
public final [ResolvedTo(BODY_RESOLVE)] fun member2(): R|kotlin/Boolean| {
public final [ResolvedTo(BODY_RESOLVE)] [ExpectForActualAttributeKey={}] fun member2(): R|kotlin/Boolean| {
^member2 Boolean(false)
}
@@ -87,6 +87,8 @@ sealed class FirModifier<Node : Any>(val node: Node, val token: KtModifierKeywor
fun KtSourceElement?.getModifierList(): FirModifierList? {
return when (this) {
null -> null
// todo this code is buggy. psi for fake declarations (e.g. ImplicitConstructor, EnumGeneratedDeclaration) means a completely different thing
// KT-63751
is KtPsiSourceElement -> (psi as? KtModifierListOwner)?.modifierList?.let { FirModifierList.FirPsiModifierList(it) }
is KtLightSourceElement -> {
val modifierListNode = lighterASTNode.getChildren(treeStructure).find { it.tokenType == KtNodeTypes.MODIFIER_LIST }
@@ -12,18 +12,13 @@ import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.FirExpectActualMatchingContext
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.getModifierList
import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.isActual
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.declarations.utils.isExternal
import org.jetbrains.kotlin.fir.declarations.utils.isTailRec
import org.jetbrains.kotlin.fir.expectActualMatchingContextFactory
import org.jetbrains.kotlin.fir.languageVersionSettings
import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.fir.symbols.impl.*
@@ -51,12 +46,24 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
}
return
}
// This checker performs a more high level checking. It speaks in terms of "properties" and "functions".
// It doesn't make sense to check:
// - backing fields (fields can't be declared in expect declaration)
// - property accessors (they will be checked as part of the properties checking)
// - functions and setters parameters (they will be checked as part of the properties/functions checking)
// This if is added because hasModifier(KtTokens.ACTUAL_KEYWORD) mistakenly returns `true` for these declarations (KT-63751)
if (declaration is FirBackingField || declaration is FirPropertyAccessor || declaration is FirValueParameter) return
if (declaration.isExpect) {
checkExpectDeclarationModifiers(declaration, context, reporter)
checkOptInAnnotation(declaration, declaration.symbol, context, reporter)
}
if (declaration.isActual) {
checkActualDeclarationHasExpected(declaration, context, reporter)
val matchingCompatibilityToMembersMap = declaration.symbol.expectForActual.orEmpty()
if ((ExpectActualMatchingCompatibility.MatchedSuccessfully in matchingCompatibilityToMembersMap || declaration.hasActualModifier()) &&
!declaration.isLocalMember // Reduce verbosity. WRONG_MODIFIER_TARGET will be reported anyway.
) {
checkActualDeclarationHasExpected(declaration, context, reporter, matchingCompatibilityToMembersMap)
}
}
@@ -120,10 +127,9 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
declaration: FirMemberDeclaration,
context: CheckerContext,
reporter: DiagnosticReporter,
checkActual: Boolean = true,
matchingCompatibilityToMembersMap: ExpectForActualMatchingData,
) {
val symbol = declaration.symbol
val matchingCompatibilityToMembersMap = symbol.expectForActual ?: return
val expectedSingleCandidate =
matchingCompatibilityToMembersMap[ExpectActualMatchingCompatibility.MatchedSuccessfully]?.singleOrNull()
val expectActualMatchingContext = context.session.expectActualMatchingContextFactory.create(
@@ -146,10 +152,15 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
checkAmbiguousExpects(symbol, matchingCompatibilityToMembersMap, symbol, context, reporter)
val source = declaration.source
if (!declaration.isActual) {
if (checkActual && ExpectActualMatchingCompatibility.MatchedSuccessfully in matchingCompatibilityToMembersMap) {
reporter.reportOn(source, FirErrors.ACTUAL_MISSING, context)
}
if (!declaration.hasActualModifier() &&
ExpectActualMatchingCompatibility.MatchedSuccessfully in matchingCompatibilityToMembersMap &&
(actualContainingClass == null || requireActualModifier(symbol, actualContainingClass, context.session)) &&
expectedSingleCandidate != null &&
// Don't require 'actual' keyword on fake-overrides actualizations.
// It's an inconsistency in the language design, but it's the way it works right now
!expectedSingleCandidate.isFakeOverride(expectContainingClass, expectActualMatchingContext)
) {
reporter.reportOn(source, FirErrors.ACTUAL_MISSING, context)
return
}
@@ -158,8 +169,7 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
reportClassScopesIncompatibility(symbol, expectedSingleCandidate, declaration, checkingCompatibility, reporter, source, context)
}
ExpectActualMatchingCompatibility.MatchedSuccessfully !in matchingCompatibilityToMembersMap &&
requireActualModifier(declaration.symbol, context.session) -> {
ExpectActualMatchingCompatibility.MatchedSuccessfully !in matchingCompatibilityToMembersMap -> {
reporter.reportOn(
source,
FirErrors.ACTUAL_WITHOUT_EXPECT,
@@ -174,7 +184,7 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
// A nicer diagnostic for functions with default params
if (declaration is FirFunction && checkingCompatibility == ExpectActualCheckingCompatibility.ActualFunctionWithDefaultParameters) {
reporter.reportOn(declaration.source, FirErrors.ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS, context)
} else if (requireActualModifier(declaration.symbol, context.session)) {
} else {
reporter.reportOn(
source,
FirErrors.ACTUAL_WITHOUT_EXPECT,
@@ -254,6 +264,13 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
}
}
private fun FirBasedSymbol<*>.isFakeOverride(
expectContainingClass: FirRegularClassSymbol?,
expectActualMatchingContext: FirExpectActualMatchingContext,
): Boolean = expectContainingClass != null &&
this@isFakeOverride is FirCallableSymbol<*> &&
with(expectActualMatchingContext) { this@isFakeOverride.isFakeOverride(expectContainingClass) }
private fun getCheckingCompatibility(
actualSymbol: FirBasedSymbol<*>,
expectSymbol: FirBasedSymbol<*>,
@@ -309,14 +326,40 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
}
// we don't require `actual` modifier on
// - implicit primary constructors
// - data class fake members
// - annotation constructors, because annotation classes can only have one constructor
// - value class primary constructors, because value class must have primary constructor
// - value parameter inside primary constructor of inline class, because inline class must have one value parameter
private fun requireActualModifier(declaration: FirBasedSymbol<*>, session: FirSession): Boolean {
return !declaration.isAnnotationConstructor(session) &&
!declaration.isPrimaryConstructorOfInlineOrValueClass(session)
private fun requireActualModifier(
declaration: FirBasedSymbol<*>,
actualContainingClass: FirRegularClassSymbol,
platformSession: FirSession
): Boolean {
return declaration.source?.kind != KtFakeSourceElementKind.ImplicitConstructor &&
declaration.origin != FirDeclarationOrigin.Synthetic.DataClassMember &&
!declaration.isAnnotationConstructor(platformSession) &&
!declaration.isPrimaryConstructorOfInlineOrValueClass(platformSession) &&
!isUnderlyingPropertyOfInlineClass(declaration, actualContainingClass, platformSession)
}
// Ideally, this function shouldn't exist KT-63751
private fun FirElement.hasActualModifier(): Boolean = when (source?.kind) {
KtFakeSourceElementKind.DataClassGeneratedMembers -> false
KtFakeSourceElementKind.EnumGeneratedDeclaration -> false
KtFakeSourceElementKind.ImplicitConstructor -> false
else -> hasModifier(KtTokens.ACTUAL_KEYWORD) || hasModifier(KtTokens.IMPL_KEYWORD)
}
private fun isUnderlyingPropertyOfInlineClass(
symbol: FirBasedSymbol<*>,
actualContainingClass: FirRegularClassSymbol,
platformSession: FirSession
): Boolean = actualContainingClass.isInline &&
symbol is FirPropertySymbol &&
symbol.receiverParameter == null &&
actualContainingClass.primaryConstructorSymbol(platformSession)?.valueParameterSymbols?.singleOrNull()?.name == symbol.name
private fun checkOptInAnnotation(
declaration: FirMemberDeclaration,
expectDeclarationSymbol: FirBasedSymbol<*>,
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.isActual
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.expectActualMatchingContextFactory
import org.jetbrains.kotlin.fir.expressions.FirStatement
import org.jetbrains.kotlin.fir.languageVersionSettings
@@ -93,7 +94,7 @@ open class FirExpectActualMatcherTransformer(
// ------------------------------------------------------
fun transformMemberDeclaration(memberDeclaration: FirMemberDeclaration) {
if (!memberDeclaration.isActual) return
if (memberDeclaration.isExpect) return
val actualSymbol = memberDeclaration.symbol
// Regardless of whether any `expect` symbols are found for `memberDeclaration`, it must be assigned an `expectForActual` map.
@@ -14,7 +14,7 @@ expect value class Wrapper(val obj: Any) {
// FILE: test.kt
actual value class Wrapper(val obj: Any) {
val prop: String
actual val prop: String
get() = "OK"
}
@@ -15,7 +15,7 @@ expect value class Wrapper(val obj: Any) {
@JvmInline
actual value class Wrapper(val obj: Any) {
val prop: String
actual val prop: String
get() = "OK"
}
@@ -32,7 +32,7 @@ expect class ImplicitlyActualizedByJvmDeclarationOnExpectOnly
package kotlin
@OptIn(ExperimentalMultiplatform::class)
actual annotation class <!ACTUAL_WITHOUT_EXPECT, ACTUAL_WITHOUT_EXPECT!>OptionalExpectationOnExpectOnly<!>
actual annotation class <!ACTUAL_WITHOUT_EXPECT!>OptionalExpectationOnExpectOnly<!>
actual fun <!ACTUAL_WITHOUT_EXPECT!>skippedAnnotationsOnExpectOnly<!>() {}
@@ -10,6 +10,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun <R> foo(t: R) {}
actual open class Foo : Base() {
override fun <R> <!ACTUAL_WITHOUT_EXPECT!>foo<!>(t: R) {}
}
@@ -10,6 +10,6 @@ expect open class Foo : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun <R> foo(t: R) {}
actual open class Foo : Base() {
override fun <R> <!ACTUAL_WITHOUT_EXPECT!>foo<!>(t: R) {}
}
@@ -13,8 +13,8 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override lateinit var red1: String
override var red2: String = ""
actual open class Foo : Base() {
override lateinit var <!ACTUAL_WITHOUT_EXPECT!>red1<!>: String
override var <!ACTUAL_WITHOUT_EXPECT!>red2<!>: String = ""
override lateinit var green: String
}
@@ -13,8 +13,8 @@ expect open class Foo : Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override lateinit var red1: String
override var red2: String = ""
actual open class Foo : Base() {
override lateinit var <!ACTUAL_WITHOUT_EXPECT!>red1<!>: String
override var <!ACTUAL_WITHOUT_EXPECT!>red2<!>: String = ""
override lateinit var green: String
}
@@ -10,6 +10,6 @@ interface Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
final override fun foo() {}
actual open class Foo : Base {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -10,6 +10,6 @@ expect open <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Foo<!> : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
final override fun foo() {}
actual open class Foo : Base {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -12,6 +12,6 @@ interface Base {
// Mismatched scope must be reported here. But it's false negative checker in K1.
// For some reason, K1 says that modality of `exect_Foo.foo` is `abstract`.
// https://youtrack.jetbrains.com/issue/KT-59739
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
override fun foo() {}
actual open class Foo : Base {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -12,6 +12,6 @@ expect open <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Foo<!>() : Base
// Mismatched scope must be reported here. But it's false negative checker in K1.
// For some reason, K1 says that modality of `exect_Foo.foo` is `abstract`.
// https://youtrack.jetbrains.com/issue/KT-59739
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
override fun foo() {}
actual open class Foo : Base {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -9,6 +9,6 @@ interface Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
abstract override fun foo()
actual abstract class Foo : Base {
abstract override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>()
}
@@ -9,6 +9,6 @@ expect abstract class Foo() : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
abstract override fun foo()
actual abstract class Foo : Base {
abstract override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>()
}
@@ -10,6 +10,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
final override fun foo() {}
actual open class Foo : Base() {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -10,6 +10,6 @@ expect open class Foo : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
final override fun foo() {}
actual open class Foo : Base() {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -10,6 +10,6 @@ open class Base<T> {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base<String>() {
final override fun foo(t: String) {}
actual open class Foo : Base<String>() {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(t: String) {}
}
@@ -10,6 +10,6 @@ expect open class Foo : Base<String>
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base<String>() {
final override fun foo(t: String) {}
actual open class Foo : Base<String>() {
final override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(t: String) {}
}
@@ -6,6 +6,6 @@
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
final override fun toString() = "Foo"
actual open class Foo {
final override fun <!ACTUAL_WITHOUT_EXPECT!>toString<!>() = "Foo"
}
@@ -6,6 +6,6 @@ expect open class Foo
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
final override fun toString() = "Foo"
actual open class Foo {
final override fun <!ACTUAL_WITHOUT_EXPECT!>toString<!>() = "Foo"
}
@@ -14,8 +14,8 @@ expect open class Foo3 {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo1<!> : Base() {
override fun foo(paramNameChanged: Int) {}
actual open class Foo1 : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(paramNameChanged: Int) {}
}
actual typealias Foo2 = Foo2Java
@@ -14,8 +14,8 @@ expect open class Foo3 {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo1<!> : Base() {
override fun foo(paramNameChanged: Int) {}
actual open class Foo1 : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(paramNameChanged: Int) {}
}
actual typealias Foo2 = Foo2Java
@@ -11,6 +11,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun foo(bar: IntArray) {}
actual open class Foo : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(bar: IntArray) {}
}
@@ -11,6 +11,6 @@ expect open class Foo : Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun foo(bar: IntArray) {}
actual open class Foo : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(bar: IntArray) {}
}
@@ -10,6 +10,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
public override fun foo() {}
actual open class Foo : Base() {
public override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -10,6 +10,6 @@ expect open class Foo : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
public override fun foo() {}
actual open class Foo : Base() {
public override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -12,6 +12,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun foo(): String = ""
actual open class Foo : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): String = ""
}
@@ -12,6 +12,6 @@ expect open class Foo : Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override fun foo(): String = ""
actual open class Foo : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): String = ""
}
@@ -13,6 +13,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><T : I> : Base() {
override fun foo(): T = null!!
actual open class Foo<T : I> : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): T = null!!
}
@@ -13,6 +13,6 @@ expect open class Foo<T : I> : Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><T : I> : Base() {
override fun foo(): T = null!!
actual open class Foo<T : I> : Base() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): T = null!!
}
@@ -11,6 +11,6 @@ open class Base<R> {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><E, F : E> : Base<E>() {
override fun foo(): F = null!!
actual open class Foo<E, F : E> : Base<E>() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): F = null!!
}
@@ -11,6 +11,6 @@ expect open class Foo<R, T : R> : Base<R> {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><E, F : E> : Base<E>() {
override fun foo(): F = null!!
actual open class Foo<E, F : E> : Base<E>() {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): F = null!!
}
@@ -11,6 +11,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override val foo: String = ""
actual open class Foo : Base() {
override val <!ACTUAL_WITHOUT_EXPECT!>foo<!>: String = ""
}
@@ -11,6 +11,6 @@ expect open class Foo : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override val foo: String = ""
actual open class Foo : Base() {
override val <!ACTUAL_WITHOUT_EXPECT!>foo<!>: String = ""
}
@@ -14,11 +14,11 @@ expect open class Base {
actual typealias Base = BaseJava
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
actual open class Foo : Base() {
// K1 doesn't report a diagnostic here because when it compares scopes it sees flexible type
// K2 will likely report a diagnostic here
// I don't think we can fix this 'K1 green -> K2 red'. It must be a rare case anyway.
override fun foo(): List<String> {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): List<String> {
return super.foo()
}
}
@@ -14,11 +14,11 @@ expect open class Foo : Base {
actual typealias Base = BaseJava
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
actual open class Foo : Base() {
// K1 doesn't report a diagnostic here because when it compares scopes it sees flexible type
// K2 will likely report a diagnostic here
// I don't think we can fix this 'K1 green -> K2 red'. It must be a rare case anyway.
override fun foo(): List<String> {
override fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>(): List<String> {
return super.foo()
}
}
@@ -15,5 +15,5 @@ actual open class Foo {
// Expected: NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING.
// But it doesn't work because context receivers are not yet supported in expect actual matcher KT-61447
context(Int)
fun foo() {}
fun <!ACTUAL_MISSING!>foo<!>() {}
}
@@ -10,6 +10,6 @@ open class Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override var foo: Int = 1
actual open class Foo : Base() {
override var <!ACTUAL_WITHOUT_EXPECT!>foo<!>: Int = 1
}
@@ -10,6 +10,6 @@ expect open class Foo : Base
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
override var foo: Int = 1
actual open class Foo : Base() {
override var <!ACTUAL_WITHOUT_EXPECT!>foo<!>: Int = 1
}
@@ -16,14 +16,14 @@ open class Base() {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
actual open class Foo : Base() {
actual fun existingMethod() {}
actual val existingParam: Int = 904
fun injectedMethod() {}
val injectedProperty: Int = 42
override fun overrideReturnType(): String = ""
final override fun overrideModality1(): Any = ""
final override fun overrideModality2(): Any = ""
public override fun overrideVisibility(): Any = ""
override fun <!ACTUAL_WITHOUT_EXPECT!>overrideReturnType<!>(): String = ""
final override fun <!ACTUAL_WITHOUT_EXPECT!>overrideModality1<!>(): Any = ""
final override fun <!ACTUAL_WITHOUT_EXPECT!>overrideModality2<!>(): Any = ""
public override fun <!ACTUAL_WITHOUT_EXPECT!>overrideVisibility<!>(): Any = ""
}
@@ -16,14 +16,14 @@ expect open class Foo : Base {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
actual open class Foo : Base() {
actual fun existingMethod() {}
actual val existingParam: Int = 904
fun injectedMethod() {}
val injectedProperty: Int = 42
override fun overrideReturnType(): String = ""
final override fun overrideModality1(): Any = ""
final override fun overrideModality2(): Any = ""
public override fun overrideVisibility(): Any = ""
override fun <!ACTUAL_WITHOUT_EXPECT!>overrideReturnType<!>(): String = ""
final override fun <!ACTUAL_WITHOUT_EXPECT!>overrideModality1<!>(): Any = ""
final override fun <!ACTUAL_WITHOUT_EXPECT!>overrideModality2<!>(): Any = ""
public override fun <!ACTUAL_WITHOUT_EXPECT!>overrideVisibility<!>(): Any = ""
}
@@ -9,7 +9,11 @@ fun test() {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual annotation class A(val x: Array<String>)
// return types are different in expect and actual (Array<out String> in expect vs Array<String> in actual).
// In K1, different return types are mistakenly considered as expect-actual mismatch ("strong incompatibility" in old terminology)
// In K2, different return types are considered as expect-actual incompatibility ("weak incompatibility" in old terminology)
// ACTUAL_MISSING is not reported only when there is a mismatch => K2 is correct
actual annotation class A(val <!ACTUAL_MISSING!>x<!>: Array<String>)
@A(<!ARGUMENT_TYPE_MISMATCH!>"abc"<!>, <!TOO_MANY_ARGUMENTS!>"foo"<!>, <!TOO_MANY_ARGUMENTS!>"bar"<!>)
fun test2() {}
@@ -9,6 +9,10 @@ fun test() {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
// return types are different in expect and actual (Array<out String> in expect vs Array<String> in actual).
// In K1, different return types are mistakenly considered as expect-actual mismatch ("strong incompatibility" in old terminology)
// In K2, different return types are considered as expect-actual incompatibility ("weak incompatibility" in old terminology)
// ACTUAL_MISSING is not reported only when there is a mismatch => K2 is correct
actual annotation class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>A<!>(val x: Array<String>)
@A(<!TYPE_MISMATCH!>"abc"<!>, <!TOO_MANY_ARGUMENTS!>"foo"<!>, <!TOO_MANY_ARGUMENTS!>"bar"<!>)
@@ -9,7 +9,11 @@ fun test() {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual annotation class A(val x: Array<String>)
// return types are different in expect and actual (Array<out String> in expect vs Array<String> in actual).
// In K1, different return types are mistakenly considered as expect-actual mismatch ("strong incompatibility" in old terminology)
// In K2, different return types are considered as expect-actual incompatibility ("weak incompatibility" in old terminology)
// ACTUAL_MISSING is not reported only when there is a mismatch => K2 is correct
actual annotation class A<!ACTUAL_WITHOUT_EXPECT!>(val <!ACTUAL_MISSING!>x<!>: Array<String>)<!>
@A(<!ARGUMENT_TYPE_MISMATCH!>"abc"<!>, <!TOO_MANY_ARGUMENTS!>"foo"<!>, <!TOO_MANY_ARGUMENTS!>"bar"<!>)
fun test2() {}
@@ -9,6 +9,10 @@ fun test() {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
// return types are different in expect and actual (Array<out String> in expect vs Array<String> in actual).
// In K1, different return types are mistakenly considered as expect-actual mismatch ("strong incompatibility" in old terminology)
// In K2, different return types are considered as expect-actual incompatibility ("weak incompatibility" in old terminology)
// ACTUAL_MISSING is not reported only when there is a mismatch => K2 is correct
actual annotation class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>A<!>(val x: Array<String>)
@A(<!TYPE_MISMATCH!>"abc"<!>, <!TOO_MANY_ARGUMENTS!>"foo"<!>, <!TOO_MANY_ARGUMENTS!>"bar"<!>)
@@ -9,7 +9,11 @@ fun test() {}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual annotation class A(val x: Array<String>)
// return types are different in expect and actual (Array<out String> in expect vs Array<String> in actual).
// In K1, different return types are mistakenly considered as expect-actual mismatch ("strong incompatibility" in old terminology)
// In K2, different return types are considered as expect-actual incompatibility ("weak incompatibility" in old terminology)
// ACTUAL_MISSING is not reported only when there is a mismatch => K2 is correct
actual annotation class A<!ACTUAL_WITHOUT_EXPECT!>(val <!ACTUAL_MISSING!>x<!>: Array<String>)<!>
@A(<!ARGUMENT_TYPE_MISMATCH!>"abc"<!>, <!TOO_MANY_ARGUMENTS!>"foo"<!>, <!TOO_MANY_ARGUMENTS!>"bar"<!>)
fun test2() {}
@@ -28,10 +28,10 @@ expect class M01 {
// FILE: jvm.kt
actual object E01
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E02<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E03<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E04<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E04<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E05<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E06<!>
@@ -28,10 +28,10 @@ expect annotation class ANNO01
// FILE: jvm.kt
actual object E01
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E02<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E03<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E04<!>
actual object <!ACTUAL_WITHOUT_EXPECT!>E04<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E05<!>
actual object <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E06<!>
@@ -37,7 +37,7 @@ actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar1<!>(val s: String)
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar2<!>(val p: String = "value", i: Int)
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar3<!> = JavaBar
actual class Bar4(val s: String) {
constructor() : this("")
<!ACTUAL_MISSING!>constructor() : this("")<!>
}
actual class Bar5 {
@@ -45,7 +45,7 @@ actual class Bar5 {
constructor(s: String)
}
class Bar6 {
class <!ACTUAL_MISSING!>Bar6<!> {
actual constructor()
}
@@ -37,7 +37,7 @@ actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar1<!>(val s: String)
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar2<!>(val p: String = "value", i: Int)
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Bar3<!> = JavaBar
actual class Bar4(val s: String) {
constructor() : this("")
<!ACTUAL_MISSING!>constructor() : this("")<!>
}
actual class Bar5 {
@@ -45,8 +45,8 @@ actual class Bar5 {
constructor(s: String)
}
class Bar6 {
<!ACTUAL_WITHOUT_EXPECT!>actual constructor()<!>
class <!ACTUAL_MISSING!>Bar6<!> {
actual constructor()
}
actual class Bar7 actual constructor(s: String) {
@@ -1,13 +0,0 @@
// MODULE: m1-common
// FILE: common.kt
expect class A {
fun foo()
}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
class A {
actual fun <!ACTUAL_WITHOUT_EXPECT!>foo<!>() {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1-common
// FILE: common.kt
@@ -2,6 +2,6 @@
<!EXPECT_ACTUAL_INCOMPATIBILITY{JVM}, EXPECT_ACTUAL_INCOMPATIBILITY{JVM}!>expect interface Base<!>
// MODULE: m1-jvm()()(m1-common)
actual interface <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Base<!> {
override fun equals(other: Any?): Boolean
actual interface Base {
override fun <!ACTUAL_WITHOUT_EXPECT!>equals<!>(other: Any?): Boolean
}
@@ -2,6 +2,6 @@
expect interface Base
// MODULE: m1-jvm()()(m1-common)
actual interface <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Base<!> {
override fun equals(other: Any?): Boolean
actual interface Base {
override fun <!ACTUAL_WITHOUT_EXPECT!>equals<!>(other: Any?): Boolean
}
@@ -15,13 +15,13 @@ expect open class Foo3
// FILE: jvm.kt
interface Foo1
interface <!ACTUAL_MISSING!>Foo1<!>
actual interface <!ACTUAL_WITHOUT_EXPECT!>Foo2<!>
actual var <!ACTUAL_WITHOUT_EXPECT!>s<!>: String = "value"
fun foo2(): Int = 0
fun <!ACTUAL_MISSING!>foo2<!>(): Int = 0
actual class <!ACTUAL_WITHOUT_EXPECT, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
@@ -31,5 +31,5 @@ actual class DerivedExplicit : Base() {
}
actual class DerivedExplicitCheck : Base() {
override fun foo() {}
override fun <!ACTUAL_MISSING!>foo<!>() {}
}
@@ -1,34 +0,0 @@
// MODULE: m1-common
// FILE: common.kt
expect class Foo1 {
val x: String
}
expect class Foo2 {
val x: String
}
expect class Foo3 {
val x: String
}
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
open class Open {
open val x = "42"
}
actual open class Foo1 : Open() {
override val x = super.x
}
actual open class Foo2 : Open()
open class WithFinal {
val x = "42"
}
actual open class Foo3 : WithFinal()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1-common
// FILE: common.kt
@@ -41,5 +41,5 @@ actual class C {
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>D<!>
actual class E {
class N
class <!ACTUAL_MISSING!>N<!>
}
@@ -41,5 +41,5 @@ actual class C {
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>D<!>
actual class E {
class N
class <!ACTUAL_MISSING!>N<!>
}
@@ -9,7 +9,7 @@
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
fun bar(): String = "bar"
fun bas(g: Int) {}
actual class Foo {
fun <!ACTUAL_MISSING!>bar<!>(): String = "bar"
fun <!ACTUAL_MISSING!>bas<!>(g: Int) {}
}
@@ -9,7 +9,7 @@ expect class Foo {
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
actual class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
fun bar(): String = "bar"
fun bas(g: Int) {}
actual class Foo {
fun <!ACTUAL_MISSING!>bar<!>(): String = "bar"
fun <!ACTUAL_MISSING!>bas<!>(g: Int) {}
}
@@ -16,8 +16,8 @@ expect class A private constructor() {
// FILE: jvm.kt
actual class A actual private constructor() {
private fun foo() {}
private val bar: String = ""
private fun <!ACTUAL_MISSING!>foo<!>() {}
private val <!ACTUAL_MISSING!>bar<!>: String = ""
actual private fun Int.memExt(): Any = 0
actual private class Nested
@@ -20,7 +20,7 @@ expect inline class NonInlineActual(val x: Int)
actual inline class Foo1(val x: Int) {
actual fun bar(): String = "Hello"
}
actual inline class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo2<!>(val x: String)
actual inline class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo2<!>(val <!ACTUAL_WITHOUT_EXPECT!>x<!>: String)
actual <!ABSENCE_OF_PRIMARY_CONSTRUCTOR_FOR_VALUE_CLASS!>inline<!> class Foo3
actual inline class <!ACTUAL_WITHOUT_EXPECT!>NonInlineExpect<!>(val x: Int)
@@ -15,6 +15,6 @@ public class Foo {
// FILE: jvm.kt
class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo<!><T>(t: T) {
fun foo() {}
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo<!><T>(t: T) {
fun <!ACTUAL_MISSING!>foo<!>() {}
}
@@ -15,6 +15,6 @@ public class Foo {
// FILE: jvm.kt
class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo<!><T>(t: T) {
fun foo() {}
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo<!><T>(t: T) {
fun <!ACTUAL_MISSING!>foo<!>() {}
}
@@ -7,5 +7,5 @@ interface A
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
fun <T : A> foo(t: T): T = TODO()
fun <T : A> <!ACTUAL_MISSING!>foo<!>(t: T): T = TODO()
fun <T> foo(t: T): String = TODO()
@@ -7,5 +7,5 @@ expect fun <T : A> foo(t: T): String
// MODULE: m2-jvm()()(m1-common)
// FILE: jvm.kt
fun <T : A> foo(t: T): T = TODO()
fun <T : A> <!ACTUAL_MISSING!>foo<!>(t: T): T = TODO()
fun <T> foo(t: T): String = TODO()
@@ -18,8 +18,8 @@ internal expect open class Other {
// MODULE: platform-jvm()()(common)
public actual open class Some { // should be allowed
public class ProtectedNested // should be allowed
public class InternalNested // should be allowed
public class <!ACTUAL_MISSING!>ProtectedNested<!> // should be allowed
public class <!ACTUAL_MISSING!>InternalNested<!> // should be allowed
public actual fun publicFun() {} // should be allowed
public actual fun internalFun() {} // should be allowed
@@ -3,5 +3,8 @@ Exit code: OK
Output:
-- JVM --
Exit code: OK
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/simpleNoImplKeywordOnTopLevelFunction/jvm.kt:3:5: error: declaration must be marked with 'actual'.
fun foo(s: String): Array<CharSequence?> = arrayOf(s)
^
@@ -5,6 +5,6 @@ Output:
-- JVM --
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/weakIncompatibilityWithoutActualModifier/common.kt:1:1: error: expect declaration `Foo` is incompatible with actual `Foo` because class kinds are different (class, interface, object, enum, annotation)
expect class Foo
^
compiler/testData/multiplatform/weakIncompatibilityWithoutActualModifier/jvm.kt:1:11: error: declaration must be marked with 'actual'.
interface Foo
^
@@ -1,2 +1,2 @@
class My
fun bar() {}
actual class My
actual fun bar() {}
@@ -1,5 +1,5 @@
class My
fun bar() {
actual class My
actual fun bar() {
}