Skip to content

Type phase healing doesn't work on type members #6140

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
fhackett opened this issue Mar 21, 2019 · 0 comments · Fixed by #8796
Closed

Type phase healing doesn't work on type members #6140

fhackett opened this issue Mar 21, 2019 · 0 comments · Fixed by #8796

Comments

@fhackett
Copy link
Contributor

fhackett commented Mar 21, 2019

import scala.quoted._
sealed trait Trait[T] {
  type t = T
}

object O {
  def fn[T:Type](t : Trait[T])(using QuoteContext): Type[T] = '[t.t]
}

This fails to compile with a phase incorrectness error:

xxx |  def fn[T:Type](t : Trait[T]) : Type[T] = '[t.t]
    |                                             ^
    |                           access to value t from wrong staging level:
    |                            - the definition is at level 0,
    |                            - but the access is at level 1.

which can be worked around with the following change, despite in both cases there being a Type[T] or Type[t.t] implicitly available:

sealed trait Trait[T] {
  type t = T
}

object O {
  def fn[T:Type](t : Trait[T]) : Type[T] = {
    type TT = t.t
    '[TT]
  }
}

This isn't a huge issue since the workaround is quite simple, but it does seem like a strange thing to not work.

@nicolasstucki nicolasstucki removed their assignment Aug 5, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2020
Fix scala#6140, fix scala#6772, fix scala#7030, fix scala#7892, fix scala#7997, fix scala#8651 and improve scala#8100.

Differences with previous implementation
* Only track and check levels within quotes or splices
* Track levels of all symbols not at level 0
* Split level checking into specialized variants for types and terms (healType/healTermType)
* Detect inconsistent types rather than try to detect consistent ones
* Check/heal term inconsistencies only on leaf nodes (TypeTree, RefTree, Ident, This)
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2020
Fix scala#6140, fix scala#6772, fix scala#7030, fix scala#7892, fix scala#7997, fix scala#8651 and improve scala#8100.

Differences with previous implementation
* Only track and check levels within quotes or splices
* Track levels of all symbols not at level 0
* Split level checking into specialized variants for types and terms (healType/healTermType)
* Detect inconsistent types rather than try to detect consistent ones
* Check/heal term inconsistencies only on leaf nodes (TypeTree, RefTree, Ident, This)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants