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

Quoting type in a pattern doesn't work with higher-kinded types #10864

Closed
IndiscriminateCoding opened this issue Dec 19, 2020 · 1 comment · Fixed by #17362
Closed

Quoting type in a pattern doesn't work with higher-kinded types #10864

IndiscriminateCoding opened this issue Dec 19, 2020 · 1 comment · Fixed by #17362
Labels
Milestone

Comments

@IndiscriminateCoding
Copy link

IndiscriminateCoding commented Dec 19, 2020

Minimized code

T.scala:

import scala.quoted._

case class T(t: Type[_])

object T {
  def impl[T <: AnyKind](using tt: Type[T])(using Quotes): Expr[Unit] = {
    val t = T(tt)
    t.t match
      case '[x] => println("ok")
      case _ => println("not ok :(")
    '{}
  }

  inline def run[T <: AnyKind] = ${ impl[T] }
}

Run.scala:

@main
def run = T.run[List]

Output

not ok :(

Expectation

It is possible to match higher-kinded type in a macro quotation pattern.

@Katrix
Copy link
Contributor

Katrix commented Aug 20, 2021

Was told to mention that the Shapeless 2 port to Scala 3 needs this

milessabin/shapeless#1200

@nicolasstucki nicolasstucki added area:metaprogramming:quotes Issues related to quotes and splices and removed area:metaprogramming labels Jun 2, 2022
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 16, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.

Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 17, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.

Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
```

In combination with scala#16907 it would also allow
```
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```
and therefore solve scala#10864 and scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 17, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.

Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
```

In combination with scala#16907 it would also allow
```scala
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```
and therefore solve scala#10864 and scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 17, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.

Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
```

In combination with scala#16907 it would also allow
```scala
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```
and therefore solve scala#10864 and scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 21, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 28, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 28, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; `x`] =>
case '[type x; Map[`x`, `x`]] =>
case '[type x <: List[Any]; `x`] =>
case '[type f[X]; `f`] =>
case '[type f <: AnyKind; `f`] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 28, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 28, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 2, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
@nicolasstucki nicolasstucki linked a pull request May 2, 2023 that will close this issue
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 2, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 2, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 3, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 3, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 4, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 8, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 12, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 23, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 31, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 31, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 7, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 16, 2023
Support explicit type variable definition in quoted patterns.
This allows users to set explicit bounds or use the binding twice.
Previously this was only possible on quoted expression patterns case '{ ... }.

```scala
case '[type x; x] =>
case '[type x; Map[x, x]] =>
case '[type x <: List[Any]; x] =>
case '[type f[X]; f] =>
case '[type f <: AnyKind; f] =>
```

Fixes scala#10864
Fixes scala#11738
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants