Skip to content

Polymorphic function literals should consider givens as value parameters #11813

Open
@japgolly

Description

@japgolly

Compiler version

3.0.0-RC1

Minimized code

import scala.quoted.*

object X:
  def asd(using q: Quotes)(f: [A] => Type[A] ?=> q.reflect.TypeRepr): Unit =
    f[Int]

  def test1(using Quotes) =
    import quotes.reflect.*
    asd([A] => TypeRepr.of[A]) // error

  def test2(using Quotes) =
    import quotes.reflect.*
    asd([A] => (_: Type[A]) ?=> TypeRepr.of[A]) // ok

Output

[error] 14 |    asd([A] => TypeRepr.of[A])
[error]    |            ^
[error]    |Implementation restriction: polymorphic function literals must have a value parameter

Expectation

The difference between test1 and test2 is the manual (_: Type[A]) ?=> . In all other places the compiler will synthesise the (_: Type[A]) ?=> so it should do so here too.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions