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

Add support to query type of a term #1212

Open
olafurpg opened this issue Jan 17, 2018 · 1 comment
Open

Add support to query type of a term #1212

olafurpg opened this issue Jan 17, 2018 · 1 comment
Labels

Comments

@olafurpg
Copy link
Member

olafurpg commented Jan 17, 2018

Currently, SemanticDB supports the ability to query for types of identifiers but not more complex terms like List(1). This is required to implement certain scalafix linter rules like

@olafurpg
Copy link
Member Author

Related #1533

MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 25, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 25, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 25, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 25, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 25, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 26, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 27, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 27, 2018
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 added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 27, 2018
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
MasseGuillaume added a commit to MasseGuillaume/scala-collection-compat that referenced this issue Jun 27, 2018
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
dwijnand pushed a commit to dwijnand/scala-rewrites that referenced this issue Jun 20, 2019
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
dwijnand pushed a commit to dwijnand/scala-rewrites that referenced this issue Jun 20, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants