[FIR] Don't generate Any.{toString, equals, hashCode} for expect value classes in metadata
^KT-64121 Fixed Review: https://jetbrains.team/p/kt/reviews/13495/timeline If we generate these declarations then the compiler sees Any.{toString, equals, hashCode} non-synthetic declarations of common metadata and reports false positive ACTUAL_MISSING during intermediate (HMPP) metadata compilation. See the review for more details
This commit is contained in:
+2
-1
@@ -418,7 +418,8 @@ class FirElementSerializer private constructor(
|
||||
val isFakeOverrideOfAnyFunctionInDataOrValueClass = this@collectDeclarations is FirRegularClass &&
|
||||
(this@collectDeclarations.isData || this@collectDeclarations.isInline) &&
|
||||
dispatchReceiverLookupTag?.classId == StandardClassIds.Any && !declaration.isFinal
|
||||
if (isFakeOverrideOfAnyFunctionInDataOrValueClass ||
|
||||
// Related: https://youtrack.jetbrains.com/issue/KT-20427#focus=Comments-27-8652759.0-0
|
||||
if (isFakeOverrideOfAnyFunctionInDataOrValueClass && !this@collectDeclarations.isExpect ||
|
||||
!declaration.isSubstitutionOrIntersectionOverride &&
|
||||
(declaration.isStatic || declaration is FirConstructor || dispatchReceiverLookupTag == this@collectDeclarations.symbol.toLookupTag())
|
||||
) {
|
||||
|
||||
@@ -62,6 +62,7 @@ class FirKotlinScopeProvider(
|
||||
FirDelegatedMemberScope(useSiteSession, scopeSession, klass, it, delegateFields)
|
||||
}
|
||||
val declaredMemberScopeWithPossiblySynthesizedMembers =
|
||||
// Related: https://youtrack.jetbrains.com/issue/KT-20427#focus=Comments-27-8652759.0-0
|
||||
if (klass is FirRegularClass && !klass.isExpect && (klass.isData || klass.isInline)) {
|
||||
// See also KT-58926 (we apply delegation first, and data/value classes after it)
|
||||
FirClassAnySynthesizedMemberScope(useSiteSession, possiblyDelegatedDeclaredMemberScope, klass, scopeSession)
|
||||
|
||||
+7
@@ -113,6 +113,13 @@ class MppDiagnosticsIt : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
fun testKt64121(gradleVersion: GradleVersion) {
|
||||
project("kt64121", gradleVersion) {
|
||||
build("assemble")
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
fun testSuppressGradlePluginWarnings(gradleVersion: GradleVersion) {
|
||||
project("suppressGradlePluginWarnings", gradleVersion) {
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("../repo")
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example.bar"
|
||||
version = "1.0"
|
||||
|
||||
kotlin {
|
||||
js()
|
||||
linuxX64()
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-common"))
|
||||
}
|
||||
}
|
||||
|
||||
val linuxAndJsMain by creating {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
js().compilations["main"].defaultSourceSet {
|
||||
dependsOn(linuxAndJsMain)
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
|
||||
linuxX64().compilations["main"].defaultSourceSet {
|
||||
dependsOn(linuxAndJsMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven("../repo")
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "my-lib-bar"
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.example.bar
|
||||
|
||||
expect value class Bar(val value: String)
|
||||
|
||||
expect value class Foo(val value: String) {
|
||||
override fun toString(): String
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.example.bar
|
||||
|
||||
actual value class Bar actual constructor(actual val value: String){
|
||||
override fun toString(): String {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
actual value class Foo actual constructor(actual val value: String){
|
||||
actual override fun toString(): String {
|
||||
return value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user