-
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
Add missing span to extension method select #18557
Conversation
@@ -860,7 +860,7 @@ trait Implicits: | |||
/** Find an implicit conversion to apply to given tree `from` so that the | |||
* result is compatible with type `to`. | |||
*/ | |||
def inferView(from: Tree, to: Type)(using Context): SearchResult = { | |||
def inferView(from: Tree, to: Type, maybeNameSpan: Option[Span] = None)(using Context): SearchResult = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already a NoSpan
"null" object we can use, instead of having to wrap it with Option. Could you switch to that, please? You can then call .exists
on the span (which just compares to NoSpan) instead of calling foldLeft
(which also creates another lambda).
492274d
to
12c88bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry for not mention this earlier. I thinking now we should try to carry the name span together with the name, in the SelectionProto. If need be, I can try that out myself when I'm back home on Monday.
@kasiaMarek Awesome, could you add a test case for SemanticDB that confirms this change fixes #18570 ? diff --git a/tests/semanticdb/expect/Extension.scala b/tests/semanticdb/expect/Extension.scala
index c204b1ff7f..86d6ec0586 100644
--- a/tests/semanticdb/expect/Extension.scala
+++ b/tests/semanticdb/expect/Extension.scala
@@ -16,3 +16,12 @@ extension (s: String)
trait Functor[F[_]]:
extension [T](t: F[T]) def map[U](f: T => U): F[U]
+
+opaque type Deck = Long
+object Deck:
+ extension (data: Deck)
+ def fooSize: Int = ???
+
+object DeckUsage:
+ val deck: Deck = ???
+ deck.fooSize
\ No newline at end of file and run Now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nicely done, thank you. 1 diff question left
cba5398
to
fe4a685
Compare
done |
Backports #18557 to the LTS branch. PR submitted by the release tooling. [skip ci]
Backports #18557 to the LTS branch. PR submitted by the release tooling. [skip ci]
For:
uneven
call in the typed tree has span<126..126>
, where it should be<138..144>
.connected to: scalameta/metals#5630
I'm open to suggestions on how to do it nicer.