Skip to content

Conversation

@MasseGuillaume
Copy link
Contributor

@MasseGuillaume MasseGuillaume commented Jun 27, 2018

superseded: #62 and #58

This is incomplete since, it's blocked by scalameta/scalameta#1212 (Add support to query type of a term)

iset: immutable.Set[Int]
cset: collecion.Set[Int]

both have +/- implemented via SetLike

given

iset + 1
cset + 1

we know that + is from SetLike, but it's not possible to get the type of iset/cset

Rewrite collection.Set.+ restrict type of lhs

scalafix allow us to match on SetLike.+ but we cannot check the type of the expression on the lhs

We can work arround this limitation if the lhs is a identifier (simple case). This allow us
to document the expected type on the lhs and prepare the implementation once scalameta/scalameta#1212 is resolved
Terms don't have type in scalameta yet: scalameta/scalameta#1212

The SymbolMatcher is not enought for those rules since we need to check the type of the lhs.
One workarround is to jump to the symbol if we see an identifier on the lhs. for example:

iset: immutable.Set[Int]
// ...
iset + 1

we can jump to the symbol of iset and get it's type.

This is really fragile, since it's not going to work if we have aliases/subtyping.

However, it's useful to create those rules, since when we are unblock by scalameta#1212 it's
trivial to add the remaining piece
@MasseGuillaume
Copy link
Contributor Author

@julienrf good to go.

Symbol("_root_.scala.collection.immutable.Map#"),
Symbol("_root_.scala.collection.mutable.Map#"),
Symbol("_root_.scala.Predef.Map#")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we should share this code instead of duplicating it. That can be done in #56, though.

@julienrf julienrf merged commit f823520 into scala:master Jun 27, 2018
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