-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Avoid infinite recursion when looking for suggestions #22361
base: main
Are you sure you want to change the base?
Conversation
Reverting to draft for now, as we should look for more cases. For example, as noted by @natsukagami, this still fails: trait Collection:
def bar(base: Collection) = base.foo
object a extends Collection:
def foo: Int = 0
object b extends Collection:
def foo: Int = 1 |
I wonder whether this kind of recursion is what the If I recall correctly, we did not figure out the original motivation for |
I continue to wonder if we couldn't make I initially thought this could be problem when several members have the same type symbol but with different params, for example: class C[T]:
extension (x: T) def f(): Int = 1
object O:
val c0: C[String] = new C[String]
val c1: C[Int] = new C[Int]
//import c1.f
2.f() But there actually is already no suggestion for this example, even without So if we only consider objects and packages, as the documentation of |
Co-authored-by: Martin Odersky <[email protected]> Co-authored-by: Ondřej Lhoták <[email protected]> Co-authored-by: Nguyen Pham <[email protected]>
Discussed with @odersky, who gave this example where making package foo
class C[T]:
object Ext:
extension (x: T) def f(): Int = 1
object O1 extends C[String]
object O2 extends C[Int]
def main =
2.f() Martin instead suggested to keep a set of seen parents symbols between |
Keep a a set of seen parent symbols between
rootsIn
androotsStrictlyIn
to avoid infinitely growing paths that refer to the same value, such asCollection.this.O.O.O.O.O.O.O....
when computing import suggestions for:Fixes #22145.