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

Quotes#PolyType type-tests as Quotes#TypeLambda #16961

Closed
pweisenburger opened this issue Feb 19, 2023 · 1 comment · Fixed by #16972
Closed

Quotes#PolyType type-tests as Quotes#TypeLambda #16961

pweisenburger opened this issue Feb 19, 2023 · 1 comment · Fixed by #16972
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API
Milestone

Comments

@pweisenburger
Copy link
Contributor

pweisenburger commented Feb 19, 2023

Compiler version

3.3.1-RC1-bin-20230216-2507577-NIGHTLY

Minimized example

import scala.quoted.*

inline def test = ${ testImpl }

def testImpl(using Quotes) =
  import quotes.reflect.*

  PolyType(List("arg"))(_ => List(TypeBounds.empty), _ => TypeRepr.of[Any]) match
    case _: TypeLambda => println("is a TypeLambda")
    case _ => println("is not a TypeLambda")

  '{ () }

Output

When expanding, the macro prints is a TypeLambda

Expectation

The documentation shows the type hierarchy:

             +
             +- LambdaType -+- MethodOrPoly -+- MethodType
             |              |                +- PolyType
             |              +- TypeLambda
             +

Based on this, I would expect the output to be is not a TypeLambda. Of course, it could be that the run time type of what PolyType generates is a subtype of both PolyType and TypeLambda, but given the documentation I find this behavior at least unexpected. I suppose that the type test and the documentation should be aligned.

@pweisenburger pweisenburger added the stat:needs triage Every issue needs to have an "area" and "itype" label label Feb 19, 2023
@nicolasstucki
Copy link
Contributor

The bug seems to be in the definition of type TypeLambda, we should probably have type TypeLambda = dotc.core.Types.HKTypeLambda

@nicolasstucki nicolasstucki added area:metaprogramming:reflection Issues related to the quotes reflection API and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 20, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 21, 2023
smarter added a commit that referenced this issue Feb 22, 2023
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants