Skip to content

Support PCP type healing for higher kinded types #5965

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
nicolasstucki opened this issue Feb 21, 2019 · 1 comment
Closed

Support PCP type healing for higher kinded types #5965

nicolasstucki opened this issue Feb 21, 2019 · 1 comment
Assignees

Comments

@nicolasstucki
Copy link
Contributor

Currently

def f[T, S[_]](implicit ev: Type[S[T]]): Any = '{
  val a: S[T] = ???
}

fails with

15 |      val a: S[T] = ???
   |             ^
   |            access to type S from wrong staging level:
   |             - the definition is at level 0,
   |             - but the access is at level 1.
   |            
   |             The access would be accepted with the right type tag, but
   |             no implicit argument of type scala.quoted.Type[S] was found
15 |      val a: S[T] = ???
   |               ^
   |            access to type T from wrong staging level:
   |             - the definition is at level 0,
   |             - but the access is at level 1.
   |            
   |             The access would be accepted with the right type tag, but
   |             no implicit argument of type scala.quoted.Type[T] was found

When healing the types we just do not try to find implicit Type for applied higher kinded types. To support this it looks like we need to handle AppliedTypes in PCPCheckAndHeal.checkType before trying to heal it's parts.

@nicolasstucki
Copy link
Contributor Author

Later, we could add better support for HK type by providing context bounds for them and combining them with Types automatically.

  def f2[T: Type, S[_]: HK1Type]: Any = {
    '{
      val a: S[T] = ???
    }
  }

  class HK1Type[Y[_]] {
    def apply[X](x: Type[X]): Type[Y[X]] = ??? // implemented by the compiler
  }

  implicit def ev[X, Y[_]](implicit x: Type[Y], y: HK1Type[S]): Type[Y[X]] = y(x)

@nicolasstucki nicolasstucki self-assigned this Feb 25, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 26, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 26, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 26, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 27, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 4, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 7, 2019
liufengyun added a commit that referenced this issue Mar 8, 2019
Fix #5965: Make scala.quoted.Type poly-kinded
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

1 participant