-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Pattern matcher #174
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
Merged
Merged
Pattern matcher #174
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
These were not handled before.
Added decorators for symbols that can query specific annotations and annotation arguments (for now, -deprecated and -migration are added)
Added method to traverse all parts of a type.
Two improvements to TreeTransform: 1) Added transformOther functionality which handles trees not handled by other parts 2) Passes down Mode.Pattern in the context when in a pattern. TreeTransform no longer normalizes unknown trees but passes them to transformOther. The former Companions phase has been renamed to FirstTransform. It now performs the following optimizations: - adds companion objects (this was done before) - other normalizations that were formally done in TreeTransform, - rewrite native methods to stubs (this was formally done in RefChecks)
Cycles are now detected early, when an info is first completed. Legal, f-bounded cycles are broken by a LazyRef, which will construct its type lazily. This makes checkBounds validation of AppliedTypeTrees work (in FirstTransform). Formerly, this stackoverflowed despite the laziness precautions in findMember. Todo: Do the same for class files coming from Java and Scala 2.x.
Insert LazyRefs to break cycles for F-bounded types that are unpickled or read from Java signatures.
Now that F-bunded types are treated more robustly, we can check bounds for non-emptyness during Typer. This unvealed one wrong test (wonder how that passed scalac?), which got moved to neg.
Statements are now transformed with the transform returned by prepareStats, analogoys to the other prepare methods.
This is still disabled, because the prepare machinery in transform does not work yet. Concretely, prepare ops need to return a new TreeTransform but that tree transform has an undefined phaase id. We need some architectural changes to disentangle transforms from phases.
... so that it can be combined with TreeTransform in a trait composition in a future dientanglement of TreeTransforms and Phases.
Would be flagged as unimplemented members in refChecks otherwise
TreeTransforms are no longer phases. This allows to generate new transforms in prepare... methods without running into the problem that thee new transforms are undefined as phases. It also makes for a cleaner separation of concerns.
Should have lazy flag set, otherwise forward reference checking would fail for modules. Note: LazyVals needed to be disabled because it also should transform module vals, but didn't do this so far because it only tested the Lazy flag. It turned out the module val transformation exposed some bugs in lazy vals in that LazyVals creates symbols as a side effect and enters them into scopes. Such mutations are allowed onyl in very specific cases (essentially only for local throw-away scopes).
Used to show "mutable var x: T".
Scopes are also used in overriding pairs, and there multiple types with the same name can be entered in a scope. So the assert to the contrary should be limited to typechecking only.
Eta-lifting picked some arbitrary base type. It turned out that i94-nada failed once we add a product trait to case classes (in the next commit) because Eta-Kifting picked Product as the base type, even though the target type was bounded by Monad. We now change the scheme so that the target type is included in the lifting, in order to avoid that we lift to useless types.
Case classes with arity <= 1 now also get a ProductN parent trait. This is necessary because we inherit productArity and Element methods in case classes from the ProdictN trait. Needed to add Product0 for this, which is not defined in Scala2.x.
After erasure, former Any members become Object members. Also, fixed some typos and added some TODOs on addBridges.
Was missing before.
asInstance/isInstance/ensureConforms/and/or. They replace some former "mk..." methods.
Also renamed Boolean_and/or to _&&/||, to make it conform to naming convention for other Definition operators.
RefChecks needs both methods.
New phase for Synthetic Method generation. Scala 2.x did it in Typer, but it's cleaner to do it in a separate phase.
If a TypeRef with an expanded name is an alias type, print the alias instead.
Now that caes classes always inherit from ProductX, we can avoid the special case. (We need to define _1 anyway to implement Product1).
(1) set position of companion object def (2) companions of case classes taking multiple parameter lists do not inherit from a function type (reason: we can't straightforwardly converyt a curried method with multiple parameter lists to a function value).
For overriding checks we need a concept where a val can match a def. Normal matches does not provide this.
When lazy val body is moved to a init method the owner of symbols in tree should change
Unit tests still to-be-fixed
dotc_core_transform directory is empty. Files where moved while restructuring erasure.
And a test for this.
.denot was missing
1) strip TypeVars wehere necessary before widening 2) allow the combination of widening and dealiasing, in any order.
isRef is more efficient than subtyping check.
Makes it less confusing as thisTransformer is already used for the ExplicitOuter itself
DarkDimius
added a commit
to DarkDimius/dotty
that referenced
this pull request
Oct 11, 2014
see discussion in 0c551f0
WojciechMazur
pushed a commit
to WojciechMazur/dotty
that referenced
this pull request
Mar 19, 2025
Backport "Copyright 2025" to 3.3 LTS
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.
I believe it should be good to go.
Ready for review.
@adriaanm could you also have a look? as history is long and first pat-mat related commits aren't intelligent, I believe it would be better to start looking from last commits.