Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Explain unresolvable references better" to LTS #21129

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

WojciechMazur
Copy link
Contributor

Backports #20477 to the LTS branch.

PR submitted by the release tooling.
[skip ci]

odersky and others added 4 commits July 8, 2024 20:07
We run into problems when referring to a member of a self type of a class
that it not also a member of the class from outside via an asSeenFrom.

One example is in 11226.scala where we see:
```scala
trait ManagedActorClassification { this: ActorEventBus =>
  def unsubscribe(subscriber: Subscriber): Unit
}

class Unsubscriber(bus: ManagedActorClassification) {
  def test(a: ActorRef): Unit = bus.unsubscribe(a) // error
}
```
The problem is that `unsubscribe` refers to the type `Subscriber` which
is not resolvable as a member of `bus`. one idea could be to rule out
type signatures like `unsubscribe`, similar how we rule out public signatures
referring to private members. But this could rule out existing valid programs.
For instance, the `unsubscribe` signature is unproblematic if it gets only
called with prefixes that inherit `ActorEventBus`. You could say that the
problem was instead that the type of `bus` was not specific enough.

In the long term, maybe restructing the signature is the right move. But for
now, we just try to give better error messages in the case of existing failures.

Fixes #11226

[Cherry-picked 21261c0]
Co-authored-by: Guillaume Martres <smarter@ubuntu.com>
[Cherry-picked 66bba46]
Base automatically changed from lts-20486 to lts-3.3 July 9, 2024 16:55
@WojciechMazur
Copy link
Contributor Author

No regressions detected in the community build up to lts-20857.

Reference

@WojciechMazur WojciechMazur merged commit d5b8193 into lts-3.3 Jul 9, 2024
19 checks passed
@WojciechMazur WojciechMazur deleted the lts-20477 branch July 9, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants