[FIR] KT-55503: Prefer members-extensions over @HidesMembers extensions
Passing `EXTENSION_RECEIVER` when processing `noReceiver` looks like a mistake in general. This change is backed by the `hidesMembers` and `memberWithHidesMemberAnnotationVsMemberWithout` tests. The exact reason with `memberWithHidesMemberAnnotationVsMemberWithout` is that it first checks `@HidesMembers` candidates, only takes the `kotlin/collections/Iterable<T>.forEach`, but then yields `InapplicableWrongReceiver`, because `explicitReceiverKind = EXTENSION_RECEIVER` (which is strange, because we really don't have an explicit receiver). Then we visit the same scope once more (now for all candidates) and take 2 functions: - `kotlin/collections/Iterable<T>.forEach` - `kotlin/sequence/Sequence<T>.forEach` ...and they both result in `RESOLVED`, because this time `explicitReceiverKind = NO_EXPLICIT_RECEIVER`. This change ensures the first candidate we see while checking `@HidesMembers` is taken as `RESOLVED`. ^KT-55503 Fixed
This commit is contained in:
committed by
Space Team
parent
906b16b41e
commit
603b46e531
@@ -1,8 +1,8 @@
|
||||
fun foo() = withIntList {
|
||||
withStringSequence {
|
||||
forEach { line ->
|
||||
line.rem(1)
|
||||
line.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
line.<!UNRESOLVED_REFERENCE!>rem<!>(1)
|
||||
line.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ FILE: Second.kt
|
||||
public final fun box(): R|kotlin/Unit| {
|
||||
^box R|kotlin/with|<R|sample/pack/A|, R|kotlin/Unit|>(R|sample/pack/A.A|(), <L> = with@fun R|sample/pack/A|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
R|kotlin/with|<R|sample/pack/B|, R|kotlin/Unit|>(R|sample/pack/B.B|(), <L> = with@fun R|sample/pack/B|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
this@R|special/anonymous|.R|sample/pack/forEach|()
|
||||
(this@R|special/anonymous|, this@R|special/anonymous|).R|sample/pack/A.forEach|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import sample.pack.*
|
||||
fun box() {
|
||||
return with(A()) {
|
||||
with(B()) {
|
||||
// K1 resolves to A::B.check
|
||||
// K2 - to ::A.check
|
||||
// Both K1 & K2 resolve to A::B.check
|
||||
forEach()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user