[FIR] Allow declarations to override parts of non-trivial intersection
A class can inherit two declarations that are compatible from the overridability standpoint and are therefore combined to a non-trivial intersection. At the same time, the class can declare a member declaration that only overrides one of the intersection's members. In this case, we break up the intersection and only add the overridden parts to the declared member's direct overridden list. If the class doesn't override the intersection, it exists as intersection override, like before. #KT-65487 Fixed
This commit is contained in:
committed by
Space Team
parent
889182629e
commit
26fae9e83a
+15
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.AbstractFirUseSiteMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirTypeIntersectionScopeContext.ResultOfIntersection
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.MembersByScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.isIntersectionOverride
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.similarFunctionsOrBothProperties
|
||||
import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptor
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -400,6 +401,20 @@ class JavaClassUseSiteMemberScope(
|
||||
return result.toSet()
|
||||
}
|
||||
|
||||
private fun <D : FirCallableSymbol<*>> ResultOfIntersection<D>.extractSomeSymbolFromSuperType(): D {
|
||||
return if (this.isIntersectionOverride()) {
|
||||
/*
|
||||
* we don't want to create intersection override if some declared function actually overrides some functions
|
||||
* from supertypes, so instead of intersection override symbol we check actual symbol from supertype
|
||||
*
|
||||
* TODO(KT-65925): is it enough to check only one function?
|
||||
*/
|
||||
keySymbol
|
||||
} else {
|
||||
chosenSymbol
|
||||
}
|
||||
}
|
||||
|
||||
private fun processSpecialFunctions(
|
||||
requestedName: Name,
|
||||
explicitlyDeclaredFunctionsWithNaturalName: Collection<FirNamedFunctionSymbol>,
|
||||
|
||||
Reference in New Issue
Block a user