[FIR] Unwrap substitution overrides for multiple default values
Otherwise, duplicate diagnostics may be reported on subtypes of the type that actually declares the problematic override.
This commit is contained in:
committed by
Space Team
parent
76fa812949
commit
2801db0e59
+5
-2
@@ -20,16 +20,19 @@ import org.jetbrains.kotlin.fir.isSubstitutionOverride
|
|||||||
import org.jetbrains.kotlin.fir.scopes.processAllFunctions
|
import org.jetbrains.kotlin.fir.scopes.processAllFunctions
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.unwrapSubstitutionOverrides
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
object FirMultipleDefaultsInheritedFromSupertypesChecker : FirRegularClassChecker() {
|
object FirMultipleDefaultsInheritedFromSupertypesChecker : FirRegularClassChecker() {
|
||||||
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
declaration.unsubstitutedScope(context).processAllFunctions {
|
declaration.unsubstitutedScope(context).processAllFunctions {
|
||||||
if (it.containingClassLookupTag() != declaration.symbol.toLookupTag()) {
|
val originalIfSubstitutionOverride = it.unwrapSubstitutionOverrides()
|
||||||
|
|
||||||
|
if (originalIfSubstitutionOverride.containingClassLookupTag() != declaration.symbol.toLookupTag()) {
|
||||||
return@processAllFunctions
|
return@processAllFunctions
|
||||||
}
|
}
|
||||||
|
|
||||||
checkFunction(declaration, it, context, reporter)
|
checkFunction(declaration, originalIfSubstitutionOverride, context, reporter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
-15
@@ -1,15 +0,0 @@
|
|||||||
interface A<T> {
|
|
||||||
fun foo(x: Int = 42): Int
|
|
||||||
}
|
|
||||||
|
|
||||||
open class B<K> {
|
|
||||||
fun foo(x: Int = 239) = x
|
|
||||||
}
|
|
||||||
|
|
||||||
interface C<E> {
|
|
||||||
fun foo(x: Int): Int
|
|
||||||
}
|
|
||||||
|
|
||||||
open <!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>class Z<!><R> : A<R>, B<R>(), C<R>
|
|
||||||
|
|
||||||
<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE_DEPRECATION_WARNING!>class N<!><W> : Z<W>()
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
interface A<T> {
|
interface A<T> {
|
||||||
fun foo(x: Int = 42): Int
|
fun foo(x: Int = 42): Int
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user