[FIR] Report conflicts for data class generated members
^KT-59880
This commit is contained in:
committed by
Space Team
parent
afc22728fa
commit
bc2eb546b4
+4
-1
@@ -63,7 +63,7 @@ private fun FirBasedSymbol<*>.isCollectable(): Boolean {
|
||||
return when (this) {
|
||||
// - see tests with `fun () {}`.
|
||||
// you can't redeclare something that has no name.
|
||||
is FirNamedFunctionSymbol -> source?.kind !is KtFakeSourceElementKind && name != SpecialNames.NO_NAME_PROVIDED
|
||||
is FirNamedFunctionSymbol -> isCollectableAccordingToSource && name != SpecialNames.NO_NAME_PROVIDED
|
||||
is FirRegularClassSymbol -> name != SpecialNames.NO_NAME_PROVIDED
|
||||
// - see testEnumValuesValueOf.
|
||||
// it generates a static function that has
|
||||
@@ -76,6 +76,9 @@ private fun FirBasedSymbol<*>.isCollectable(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
private val FirNamedFunctionSymbol.isCollectableAccordingToSource: Boolean
|
||||
get() = source?.kind !is KtFakeSourceElementKind || source?.kind == KtFakeSourceElementKind.DataClassGeneratedMembers
|
||||
|
||||
private val FirBasedSymbol<*>.resolvedStatus
|
||||
get() = when (this) {
|
||||
is FirCallableSymbol<*> -> resolvedStatus
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
annotation class An
|
||||
|
||||
@An
|
||||
data class A(@An val x: @An Int) {
|
||||
@An
|
||||
fun copy(@An x: @An Int) = x
|
||||
data class <!CONFLICTING_OVERLOADS("[@An() fun copy(@An() x: @R|An|() Int): @R|An|() Int]")!>A(@An val x: @An Int)<!> {
|
||||
<!CONFLICTING_OVERLOADS("[fun copy(@An() x: @R|An|() Int = ...): A]")!>@An
|
||||
fun copy(@An x: @An Int)<!> = x
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
data class A(val x: Int, val y: String) {
|
||||
data class <!CONFLICTING_OVERLOADS!>A(val x: Int, val y: String)<!> {
|
||||
<!CONFLICTING_OVERLOADS!>fun copy(x: Int, y: String)<!> = x
|
||||
<!CONFLICTING_OVERLOADS!>fun copy(x: Int, y: String)<!> = A(x, y)
|
||||
}
|
||||
Vendored
+2
-2
@@ -4,6 +4,6 @@ interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES!>data<!> class Test(val str: String) : WithCopy<String> {
|
||||
override fun copy(str: String) = Test(str)
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES!>data<!> class <!CONFLICTING_OVERLOADS!>Test(val str: String)<!> : WithCopy<String> {
|
||||
<!CONFLICTING_OVERLOADS!>override fun copy(str: String)<!> = Test(str)
|
||||
}
|
||||
|
||||
compiler/testData/diagnostics/tests/dataClasses/dataClassExplicitlyOverridingCopyWithDefaults.fir.kt
Vendored
+2
-2
@@ -4,6 +4,6 @@ interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES!>data<!> class Test(val str: String) : WithCopy<String> {
|
||||
override fun copy(str: String = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>this.str<!>) = Test(str)
|
||||
<!DATA_CLASS_OVERRIDE_DEFAULT_VALUES!>data<!> class <!CONFLICTING_OVERLOADS!>Test(val str: String)<!> : WithCopy<String> {
|
||||
<!CONFLICTING_OVERLOADS!>override fun copy(str: String = <!DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE!>this.str<!>)<!> = Test(str)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user