[FIR] 1/2 match and check expect fake-overrides vs actuals
^KT-63550 Fixed Review: https://jetbrains.team/p/kt/reviews/13094/timeline Now it's required to create a new ScopeSession when searching for expect members for actuals. If you keep reusing actualScopeSession then members declared in platform may "slip into" the search results, resulting an incorrect expect for actual (e.g. it happens in supertypeIsExpectActual_covariantOverrideOfInjectedFromSuper_transitiveSubstitutionFakeOverride.fir.kt) I suppose that it always has been a bug that we reused actualScopeSession because we were mixing actualScopeSession and expect FirSession (which is a bad idea), but we simply didn't have cases where this bug could be observed. Now after we started matching fake-overrides, we have such cases. But creating a new ScopeSession every time is a suboptimal solution. We need to design a scope caching KT-63773
This commit is contained in:
+6
@@ -23707,6 +23707,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualFakeOverride_transitiveFakeOverrides_incompatible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasForNotExpectClass.kt")
|
||||
public void testActualTypealiasForNotExpectClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasToSpecialAnnotation.kt")
|
||||
public void testActualTypealiasToSpecialAnnotation() throws Exception {
|
||||
|
||||
+6
@@ -23707,6 +23707,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualFakeOverride_transitiveFakeOverrides_incompatible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasForNotExpectClass.kt")
|
||||
public void testActualTypealiasForNotExpectClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasToSpecialAnnotation.kt")
|
||||
public void testActualTypealiasToSpecialAnnotation() throws Exception {
|
||||
|
||||
+6
@@ -68,6 +68,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualFakeOverride_transitiveFakeOverrides_incompatible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasForNotExpectClass.kt")
|
||||
public void testActualTypealiasForNotExpectClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasToSpecialAnnotation.kt")
|
||||
public void testActualTypealiasToSpecialAnnotation() throws Exception {
|
||||
|
||||
+6
@@ -68,6 +68,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualFakeOverride_transitiveFakeOverrides_incompatible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasForNotExpectClass.kt")
|
||||
public void testActualTypealiasForNotExpectClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasToSpecialAnnotation.kt")
|
||||
public void testActualTypealiasToSpecialAnnotation() throws Exception {
|
||||
|
||||
+3
-2
@@ -20,13 +20,14 @@ interface FirExpectActualMatchingContext : ExpectActualMatchingContext<FirBasedS
|
||||
session: FirSession = moduleData.session,
|
||||
): Collection<FirConstructorSymbol>
|
||||
|
||||
val expectScopeSession: ScopeSession
|
||||
override fun RegularClassSymbolMarker.getMembersForExpectClass(name: Name): List<FirCallableSymbol<*>>
|
||||
}
|
||||
|
||||
interface FirExpectActualMatchingContextFactory : FirSessionComponent {
|
||||
fun create(
|
||||
session: FirSession,
|
||||
scopeSession: ScopeSession,
|
||||
actualSession: FirSession,
|
||||
actualScopeSession: ScopeSession,
|
||||
allowedWritingMemberExpectForActualMapping: Boolean = false,
|
||||
): FirExpectActualMatchingContext
|
||||
}
|
||||
|
||||
+2
-3
@@ -41,11 +41,11 @@ class FirExpectActualMatcherProcessor(
|
||||
*/
|
||||
open class FirExpectActualMatcherTransformer(
|
||||
final override val session: FirSession,
|
||||
private val scopeSession: ScopeSession,
|
||||
private val actualScopeSession: ScopeSession,
|
||||
) : FirAbstractTreeTransformer<Nothing?>(FirResolvePhase.EXPECT_ACTUAL_MATCHING) {
|
||||
|
||||
private val expectActualMatchingContext = session.expectActualMatchingContextFactory.create(
|
||||
session, scopeSession,
|
||||
session, actualScopeSession,
|
||||
allowedWritingMemberExpectForActualMapping = true,
|
||||
)
|
||||
|
||||
@@ -102,7 +102,6 @@ open class FirExpectActualMatcherTransformer(
|
||||
val expectForActualData = FirExpectActualResolver.findExpectForActual(
|
||||
actualSymbol,
|
||||
session,
|
||||
scopeSession,
|
||||
expectActualMatchingContext,
|
||||
)
|
||||
memberDeclaration.expectForActual = expectForActualData
|
||||
|
||||
+12
-7
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.utils.zipIfSizesAreEqual
|
||||
|
||||
class FirExpectActualMatchingContextImpl private constructor(
|
||||
private val actualSession: FirSession,
|
||||
private val scopeSession: ScopeSession,
|
||||
private val actualScopeSession: ScopeSession,
|
||||
private val allowedWritingMemberExpectForActualMapping: Boolean,
|
||||
) : FirExpectActualMatchingContext, TypeSystemContext by actualSession.typeContext {
|
||||
override val shouldCheckAbsenceOfDefaultParamsInActual: Boolean
|
||||
@@ -52,6 +52,11 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
override val allowTransitiveSupertypesActualization: Boolean
|
||||
get() = true
|
||||
|
||||
override val expectScopeSession: ScopeSession
|
||||
// todo KT-63773 design a way for managing scope sessions for common scopes during matching.
|
||||
// Right now we create a new session every time
|
||||
get() = ScopeSession()
|
||||
|
||||
private fun DeclarationSymbolMarker.asSymbol(): FirBasedSymbol<*> = this as FirBasedSymbol<*>
|
||||
private fun CallableSymbolMarker.asSymbol(): FirCallableSymbol<*> = this as FirCallableSymbol<*>
|
||||
private fun FunctionSymbolMarker.asSymbol(): FirFunctionSymbol<*> = this as FirFunctionSymbol<*>
|
||||
@@ -170,7 +175,7 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
|
||||
val scope = symbol.defaultType().scope(
|
||||
useSiteSession = session,
|
||||
scopeSession,
|
||||
if (isActualDeclaration) actualScopeSession else expectScopeSession,
|
||||
CallableCopyTypeCalculator.DoNothing,
|
||||
requiredMembersPhase = FirResolvePhase.STATUS,
|
||||
) ?: return emptyList()
|
||||
@@ -196,7 +201,7 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
val symbol = asSymbol()
|
||||
val scope = symbol.defaultType().scope(
|
||||
useSiteSession = symbol.moduleData.session,
|
||||
scopeSession,
|
||||
expectScopeSession,
|
||||
CallableCopyTypeCalculator.DoNothing,
|
||||
requiredMembersPhase = FirResolvePhase.STATUS,
|
||||
) ?: return emptyList()
|
||||
@@ -259,7 +264,7 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
val session = symbol.moduleData.session
|
||||
val containingClass = symbol.containingClassLookupTag()?.toFirRegularClassSymbol(session)
|
||||
?: return sequenceOf(symbol)
|
||||
(sequenceOf(symbol) + symbol.overriddenFunctions(containingClass, session, scopeSession).asSequence())
|
||||
(sequenceOf(symbol) + symbol.overriddenFunctions(containingClass, session, actualScopeSession).asSequence())
|
||||
// Tests work even if you don't filter out fake-overrides. Filtering fake-overrides is needed because
|
||||
// the returned descriptors are compared by `equals`. And `equals` for fake-overrides is weird.
|
||||
// I didn't manage to invent a test that would check this condition
|
||||
@@ -354,7 +359,7 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
|
||||
override fun RegularClassSymbolMarker.isNotSamInterface(): Boolean {
|
||||
val type = asSymbol().defaultType()
|
||||
val isSam = FirSamResolver(actualSession, scopeSession).isSamType(type)
|
||||
val isSam = FirSamResolver(actualSession, actualScopeSession).isSamType(type)
|
||||
return !isSam
|
||||
}
|
||||
|
||||
@@ -613,9 +618,9 @@ class FirExpectActualMatchingContextImpl private constructor(
|
||||
|
||||
object Factory : FirExpectActualMatchingContextFactory {
|
||||
override fun create(
|
||||
session: FirSession, scopeSession: ScopeSession,
|
||||
actualSession: FirSession, actualScopeSession: ScopeSession,
|
||||
allowedWritingMemberExpectForActualMapping: Boolean,
|
||||
): FirExpectActualMatchingContextImpl =
|
||||
FirExpectActualMatchingContextImpl(session, scopeSession, allowedWritingMemberExpectForActualMapping)
|
||||
FirExpectActualMatchingContextImpl(actualSession, actualScopeSession, allowedWritingMemberExpectForActualMapping)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirExpectActualMatchingContext
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.ExpectForActualMatchingData
|
||||
import org.jetbrains.kotlin.fir.declarations.fullyExpandedClass
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.dependenciesSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
@@ -26,7 +27,6 @@ object FirExpectActualResolver {
|
||||
fun findExpectForActual(
|
||||
actualSymbol: FirBasedSymbol<*>,
|
||||
useSiteSession: FirSession,
|
||||
scopeSession: ScopeSession,
|
||||
context: FirExpectActualMatchingContext,
|
||||
): ExpectForActualMatchingData {
|
||||
with(context) {
|
||||
@@ -45,7 +45,7 @@ object FirExpectActualResolver {
|
||||
?.fullyExpandedClass(useSiteSession)
|
||||
|
||||
when (actualSymbol) {
|
||||
is FirConstructorSymbol -> expectContainingClass?.getConstructors(scopeSession)
|
||||
is FirConstructorSymbol -> expectContainingClass?.getConstructors(expectScopeSession)
|
||||
else -> expectContainingClass?.getMembersForExpectClass(actualSymbol.name)
|
||||
}.orEmpty()
|
||||
}
|
||||
@@ -59,7 +59,7 @@ object FirExpectActualResolver {
|
||||
}
|
||||
}
|
||||
candidates.filter { expectSymbol ->
|
||||
actualSymbol != expectSymbol && expectSymbol.isExpect
|
||||
actualSymbol != expectSymbol && (expectContainingClass != null /*match fake overrides*/ || expectSymbol.isExpect)
|
||||
}.groupBy { expectDeclaration ->
|
||||
AbstractExpectActualMatcher.getCallablesMatchingCompatibility(
|
||||
expectDeclaration,
|
||||
@@ -79,8 +79,12 @@ object FirExpectActualResolver {
|
||||
is FirClassLikeSymbol<*> -> {
|
||||
val expectClassSymbol = useSiteSession.dependenciesSymbolProvider
|
||||
.getClassLikeSymbolByClassId(actualSymbol.classId) as? FirRegularClassSymbol ?: return emptyMap()
|
||||
val compatibility = AbstractExpectActualMatcher.matchClassifiers(expectClassSymbol, actualSymbol, context)
|
||||
mapOf(compatibility to listOf(expectClassSymbol))
|
||||
if (expectClassSymbol.isExpect) {
|
||||
val compatibility = AbstractExpectActualMatcher.matchClassifiers(expectClassSymbol, actualSymbol, context)
|
||||
mapOf(compatibility to listOf(expectClassSymbol))
|
||||
} else {
|
||||
emptyMap()
|
||||
}
|
||||
}
|
||||
else -> emptyMap()
|
||||
}
|
||||
|
||||
-2
@@ -217,8 +217,6 @@ object AbstractExpectActualChecker {
|
||||
val actualMembersByName = actualClassSymbol.collectAllMembers(isActualDeclaration = true).groupBy { it.name }
|
||||
|
||||
outer@ for (expectMember in expectClassSymbol.collectAllMembers(isActualDeclaration = false)) {
|
||||
if (expectMember is CallableSymbolMarker && expectMember.shouldSkipMatching(expectClassSymbol)) continue
|
||||
|
||||
val actualMembers = getPossibleActualsByExpectName(expectMember, actualMembersByName)
|
||||
|
||||
val matched = AbstractExpectActualMatcher.matchSingleExpectAgainstPotentialActuals(
|
||||
|
||||
-2
@@ -89,8 +89,6 @@ object AbstractExpectActualMatcher {
|
||||
val actualMembersByName = actualClassSymbol.collectAllMembers(isActualDeclaration = true).groupBy { it.name }
|
||||
|
||||
outer@ for (expectMember in expectClassSymbol.collectAllMembers(isActualDeclaration = false)) {
|
||||
if (expectMember is CallableSymbolMarker && expectMember.shouldSkipMatching(expectClassSymbol)) continue
|
||||
|
||||
val actualMembers = getPossibleActualsByExpectName(expectMember, actualMembersByName)
|
||||
|
||||
matchSingleExpectAgainstPotentialActuals(
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun <R> foo(t: R) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open class Foo : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun <R> foo(t: R) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override lateinit var red1: String
|
||||
override var red2: String = ""
|
||||
override lateinit var green: String
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ expect open class Foo : Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override lateinit var red1: String
|
||||
override var red2: String = ""
|
||||
override lateinit var green: String
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ interface Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
final override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Foo<!> : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
final override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 Foo : Base {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 Foo : Base {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ interface Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual abstract class Foo : Base {
|
||||
actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ expect abstract class Foo() : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual abstract class Foo : Base {
|
||||
actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
final override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open class Foo : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
final override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ open class Base<T> {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base<String>() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base<String>() {
|
||||
final override fun foo(t: String) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open class Foo : Base<String>
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base<String>() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base<String>() {
|
||||
final override fun foo(t: String) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
|
||||
final override fun toString() = "Foo"
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ expect open class Foo
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> {
|
||||
final override fun toString() = "Foo"
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ expect open class Foo3 {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo1 : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo1<!> : Base() {
|
||||
override fun foo(paramNameChanged: Int) {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ expect open class Foo3 {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo1 : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo1<!> : Base() {
|
||||
override fun foo(paramNameChanged: Int) {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun foo(bar: IntArray) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ expect open class Foo : Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun foo(bar: IntArray) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
public override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open class Foo : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
public override fun foo() {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun foo(): String = ""
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@ expect open class Foo : Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override fun foo(): String = ""
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo<T : I> : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><T : I> : Base() {
|
||||
override fun foo(): T = null!!
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ expect open class Foo<T : I> : Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo<T : I> : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><T : I> : Base() {
|
||||
override fun foo(): T = null!!
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ open class Base<R> {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo<E, F : E> : Base<E>() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><E, F : E> : Base<E>() {
|
||||
override fun foo(): F = null!!
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ expect open class Foo<R, T : R> : Base<R> {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo<E, F : E> : Base<E>() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!><E, F : E> : Base<E>() {
|
||||
override fun foo(): F = null!!
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override val foo: String = ""
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ expect open class Foo : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override val foo: String = ""
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ expect open class Base {
|
||||
|
||||
actual typealias Base = BaseJava
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_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.
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ expect open class Foo : Base {
|
||||
|
||||
actual typealias Base = BaseJava
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_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.
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ open class Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override var foo: Int = 1
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ expect open class Foo : Base
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
override var foo: Int = 1
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ open class Base() {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
actual fun existingMethod() {}
|
||||
actual val existingParam: Int = 904
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ expect open class Foo : Base {
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo : Base() {
|
||||
actual open class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Foo<!> : Base() {
|
||||
actual fun existingMethod() {}
|
||||
actual val existingParam: Int = 904
|
||||
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
open class A {
|
||||
open fun foo(): String = "Fail"
|
||||
}
|
||||
expect class C1() : A
|
||||
expect class C2() : A
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: A_J.java
|
||||
public class A_J {}
|
||||
|
||||
// FILE: B_J.java
|
||||
public class B_J extends A_J {
|
||||
public String foo() { return "O"; }
|
||||
}
|
||||
|
||||
// FILE: C2_J.java
|
||||
public class C2_J extends B_J {
|
||||
public String foo() { return "K"; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
actual typealias <!ACTUAL_WITHOUT_EXPECT!>A<!> = A_J
|
||||
|
||||
// Indirect subtyping is allowed in K2 KT-59356
|
||||
actual class C1 : B_J()
|
||||
actual typealias C2 = C2_J
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
open class <!PACKAGE_OR_CLASSIFIER_REDECLARATION{JVM}!>A<!> {
|
||||
open fun foo(): String = "Fail"
|
||||
}
|
||||
expect class C1() : A
|
||||
expect class C2() : A
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: A_J.java
|
||||
public class A_J {}
|
||||
|
||||
// FILE: B_J.java
|
||||
public class B_J extends A_J {
|
||||
public String foo() { return "O"; }
|
||||
}
|
||||
|
||||
// FILE: C2_J.java
|
||||
public class C2_J extends B_J {
|
||||
public String foo() { return "K"; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
actual typealias <!ACTUAL_WITHOUT_EXPECT, PACKAGE_OR_CLASSIFIER_REDECLARATION!>A<!> = A_J
|
||||
|
||||
// Indirect subtyping is allowed in K2 KT-59356
|
||||
actual class C1 : <!ACTUAL_WITHOUT_EXPECT!>B_J()<!>
|
||||
actual typealias <!ACTUAL_WITHOUT_EXPECT!>C2<!> = C2_J
|
||||
compiler/testData/diagnostics/tests/multiplatform/headerClass/equalsOverrideInActualInterface.fir.kt
Vendored
+1
-1
@@ -2,6 +2,6 @@
|
||||
<!EXPECT_ACTUAL_INCOMPATIBILITY{JVM}, EXPECT_ACTUAL_INCOMPATIBILITY{JVM}!>expect interface Base<!>
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
actual interface Base {
|
||||
actual interface <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Base<!> {
|
||||
override fun equals(other: Any?): Boolean
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,6 +2,6 @@
|
||||
expect interface Base
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
actual interface Base {
|
||||
actual interface <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>Base<!> {
|
||||
override fun equals(other: Any?): Boolean
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -12,4 +12,4 @@
|
||||
|
||||
import java.util.AbstractMap
|
||||
|
||||
public actual abstract class AbstractMutableMap<K, V>() : MutableMap<K, V>, AbstractMap<K, V>()
|
||||
public actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>AbstractMutableMap<!><K, V>() : MutableMap<K, V>, AbstractMap<K, V>()
|
||||
|
||||
Vendored
+1
-1
@@ -12,4 +12,4 @@ public expect abstract class AbstractMutableMap<K, V> : MutableMap<K, V> {
|
||||
|
||||
import java.util.AbstractMap
|
||||
|
||||
public actual abstract class AbstractMutableMap<K, V>() : MutableMap<K, V>, AbstractMap<K, V>()
|
||||
public actual abstract class <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>AbstractMutableMap<!><K, V>() : MutableMap<K, V>, AbstractMap<K, V>()
|
||||
|
||||
Vendored
+2
-2
@@ -9,5 +9,5 @@
|
||||
|
||||
typealias MyNothing = Nothing
|
||||
|
||||
<!ACTUAL_TYPE_ALIAS_TO_NOTHING!>actual typealias E01 = Nothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias E02 = MyNothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_TO_NOTHING!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E01<!> = Nothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!> = MyNothing<!>
|
||||
|
||||
+2
-2
@@ -9,5 +9,5 @@ expect class E02
|
||||
|
||||
typealias MyNothing = Nothing
|
||||
|
||||
<!ACTUAL_TYPE_ALIAS_TO_NOTHING!>actual typealias E01 = Nothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias E02 = MyNothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_TO_NOTHING!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E01<!> = Nothing<!>
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!> = MyNothing<!>
|
||||
|
||||
+2
-2
@@ -10,5 +10,5 @@
|
||||
|
||||
typealias MyNothing = Nothing
|
||||
|
||||
actual typealias E01 = Nothing
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias E02 = MyNothing<!>
|
||||
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E01<!> = Nothing
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!> = MyNothing<!>
|
||||
|
||||
+2
-2
@@ -10,5 +10,5 @@ expect class E02
|
||||
|
||||
typealias MyNothing = Nothing
|
||||
|
||||
actual typealias E01 = Nothing
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias E02 = MyNothing<!>
|
||||
actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E01<!> = Nothing
|
||||
<!ACTUAL_TYPE_ALIAS_NOT_TO_CLASS!>actual typealias <!NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS!>E02<!> = MyNothing<!>
|
||||
|
||||
+20
@@ -8,6 +8,26 @@ Output:
|
||||
compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:3:1: error: right-hand side of actual type alias cannot be of type kotlin.Nothing
|
||||
actual typealias E01 = Nothing
|
||||
^
|
||||
compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:3:18: error: 'actual typealias E01 = Nothing' has no corresponding members for expected class members:
|
||||
|
||||
fun equals(other: Any?): Boolean
|
||||
|
||||
fun hashCode(): Int
|
||||
|
||||
fun toString(): String
|
||||
|
||||
actual typealias E01 = Nothing
|
||||
^
|
||||
compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:4:1: error: right-hand side of actual type alias should be a class, not another type alias.
|
||||
actual typealias E02 = MyNothing
|
||||
^
|
||||
compiler/testData/multiplatform/implTypeAlias/actualTypealiasToNothing/jvm.kt:4:18: error: 'actual typealias E02 = MyNothing' has no corresponding members for expected class members:
|
||||
|
||||
fun equals(other: Any?): Boolean
|
||||
|
||||
fun hashCode(): Int
|
||||
|
||||
fun toString(): String
|
||||
|
||||
actual typealias E02 = MyNothing
|
||||
^
|
||||
|
||||
Generated
+6
@@ -23707,6 +23707,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualFakeOverride_transitiveFakeOverrides_incompatible.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasForNotExpectClass.kt")
|
||||
public void testActualTypealiasForNotExpectClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualTypealiasForNotExpectClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("actualTypealiasToSpecialAnnotation.kt")
|
||||
public void testActualTypealiasToSpecialAnnotation() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user