Skip to content

Unsoundness in the Reflection Typed #12222

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 Apr 26, 2021 · 0 comments · Fixed by #13362
Closed

Unsoundness in the Reflection Typed #12222

nicolasstucki opened this issue Apr 26, 2021 · 0 comments · Fixed by #13362
Assignees
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.0.0-RC3

Issue

Typed assumes that it is typing a Term but it might also be a pattern.

Solution 1

Make Typed contain a Tree.

This is a simple change at the definition site, but it has an impact at the use site.
For all Typed that are terms we would need to do:

-  case Typed(expr, tpt) =>
+  case Typed(expr: Term, tpt) =>

Solution 2

Create an alternative type such as TypedTree which handles the cases where the expr is not a Term.

There might be a subtyping relationship Typed <:< TypedTree.

@nicolasstucki nicolasstucki self-assigned this Apr 26, 2021
@nicolasstucki nicolasstucki linked a pull request Apr 26, 2021 that will close this issue
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 24, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 24, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 26, 2021
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

Fixes scala#12222
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
TypeOrTest can match or construct type tests or ascriptions `x: T` in expressions or patterns.
Unlike `Typed`, it contains a `Tree` instead of a `Term` which might be one of the patterns trees.

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