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

Fix TypeTreeTypeTest to not match TypeBoundsTrees #19485

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

nicolasstucki
Copy link
Contributor

Also see TypeBoundsTreeTypeTest in QuotesImpl and Quotes spec

   *           +- TypeTree ----+- Inferred
   *           |               +- ...
   *           |               ...
   *           +- TypeBoundsTree

Fixes #19480

@nicolasstucki
Copy link
Contributor Author

The original issue was that in the following pattern match the TypeBoundsTree went into the TypeTree branch.

trait TreeMap:
  def transformTree(tree: Tree)(owner: Symbol): Tree = 
    tree match 
      ...
      case tree: TypeTree => ...
      case tree: TypeBoundsTree => ...
      ...

@ghik
Copy link

ghik commented Jan 19, 2024

I tested this and it works with a regular type parameter, but still does not work with a higher-kinded parameter, e.g.

val t = '{class K[T[_]]}.asTerm

Now failing with the following exception:

Exception occurred while executing macro expansion.
scala.MatchError: LambdaTypeTree(List(TypeDef("_$1", TypeBoundsTree(Inferred(), Inferred()))), TypeBoundsTree(Inferred(), Inferred())) (of class java.lang.String)
	at scala.quoted.Quotes$reflectModule$TreeMap.transformTree(Quotes.scala:4955)
	at scala.quoted.Quotes$reflectModule$TreeMap.transformTree$(Quotes.scala:4926)
        ...

@nicolasstucki
Copy link
Contributor Author

val t = '{class K[T[_]]}.asTerm

works now

Also see `TypeBoundsTreeTypeTest` in `QuotesImpl` and `Quotes` spec

```
   *           +- TypeTree ----+- Inferred
   *           |               +- ...
   *           |               ...
   *           +- TypeBoundsTree
```

Fixes  scala#19480
Copy link
Contributor

@jchyb jchyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Sorry for not looking at this sooner, I must have somehow missed this

@nicolasstucki nicolasstucki merged commit 0e2bfe4 into scala:main Mar 11, 2024
19 checks passed
@nicolasstucki nicolasstucki deleted the fix-19480 branch March 11, 2024 13:27
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
WojciechMazur added a commit that referenced this pull request Jul 3, 2024
…TS (#20984)

Backports #19485 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MatchError in Quotes.TreeMap for local class definition with type parameter
4 participants