Skip to content

Import suggestion should filter out extensions in scope #10231

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

Closed
bishabosha opened this issue Nov 8, 2020 · 4 comments
Closed

Import suggestion should filter out extensions in scope #10231

bishabosha opened this issue Nov 8, 2020 · 4 comments

Comments

@bishabosha
Copy link
Member

bishabosha commented Nov 8, 2020

Minimized code

Sometimes, there can be an error in applying an extension method, but the import suggestions can suggest something already in scope:

class A:                                                                                                         
  extension (s: String)
    def len: Int = s.length

object B extends A:
  def len(s: String): Int = s.length + 1

@main def Test =
  import B.len
  assert("abc".len == 4)

Output

10 |   assert("abc".len == 4)
   |          ^^^^^^^^^
   |value len is not a member of String, but could be made available as an extension method.
   |
   |The following import might fix the problem:
   |
   |  import B.len
   |

Expectation

Just say that "value len is not a member of String".

The member issue is due to len in B overriding an extension method but not having the extension flag, but this error is not reported until later

@bishabosha bishabosha changed the title Import suggestion should filter out extension Import suggestion should filter out extensions in scope Nov 8, 2020
@julienrf
Copy link
Contributor

julienrf commented Nov 8, 2020

Is this #8051 again? Or just a variant of it?

@odersky
Copy link
Contributor

odersky commented Nov 10, 2020

@julienrf Seems at least very similar. So you want to take a look?

@julienrf
Copy link
Contributor

I am a bit too busy at the moment, I prefer that someone else takes it.

@griggt griggt assigned griggt and unassigned julienrf Sep 11, 2021
@julienrf
Copy link
Contributor

julienrf commented Jun 6, 2023

The error message does not anymore suggest the import (tested with 3.3.0).

@julienrf julienrf closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants