-
Notifications
You must be signed in to change notification settings - Fork 1.1k
First steps to support dependent matches #4997
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disable stability check on SingletonTypeTree for now. Introduce TypeOf only to suspend type checking of top-level TypeApply, Apply, If and Match AST nodes.
The reason why we need to ba a proper subtype of AnnotatedType and not simply instanciate it is because we a custom equality. For instance we want to disregard the differance between Ident and TypedTrees since the later replaces the former during typing.
AnnotatedType uses precise equivalance of Trees, whereas TypeOf is only concerned with certain top level trees.
Also, restore the invariant that the type of the TypeOf tree is the TypeOf type itself. Here is an example showing what would go wrong if we didn't do that. Suppose we have def f(x: Int) = x def g(x: Int) = 2 * x def h(f: Int => Int) = f(1) h(g): { 2 * 1 } Given a type map substituting f for g in f(1), the underlying type should be substituted to the result type of g(1), that is, 2 * 1.
We now effectively -Xprint-types for trees within TypeOf. Instead, we show the underlying type for the top-level tree. Also added toString in TypeOf.
…ght be out of date)
In the new scheme, we never touch a TypeOf tree's type and ensure this by assigning that tree NoType. This currently induces additional tree copies which could be removed at a later point. In the process we also fixed bugs in TreeCopier, which would sometimes not go through TypeAssigner when it should have.
See issue 5146
Rewrite match are going to be replace by quotes and splices, to be reinvestigated later.
This reverts commit b105108.
@gsps @OlivierBlanvillain Inactive for 3 months with lots of accumulated conflicts. Should we close this now? |
@OlivierBlanvillain OK, please go ahead and close #4806. |
This commits resolves all the merge conflicts to make the branch compile, but tests are still failing. Here is what breaks in dotty.tools.dotc.CompilationTests: tests/neg/erased-singleton.scala failed tests/neg/i5521.scala failed tests/pos/dependent-patterns.scala failed tests/pos/dependent3.scala failed tests/pos/dependent6.scala failed tests/run/implicitMatch.scala failed tests/run/tuple-for-comprehension.scala failed tests/run/tuple-patmat.scala failed
Waiting to a TODO
By adding a few widenUnapplyPath...
Apparently Dotty and scalac do not handle this private in the say way...
..ion on TypeOf.
f3a36e3
to
5460cac
Compare
@OlivierBlanvillain do you still intend to merge this / work on this? |
There was no activity on this one for a long while, so let's close it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is based on our ongoing work to add dependent types via the
TypeOf
encoding and extends #4806.At the moment this branch only affects the precision of types given to bindings inside of match patterns. For instance, given
we can now reason about the extracted
x
in relation to the scrutineeCons(1, Cons(2, Nil))
, so thatcan be proven by the type checker.
Note that this PR currently does not do any reduction of matches on the type level, so a match with multiple cases will not behave any differently yet.