-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactor lambda types #2121
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
Refactor lambda types #2121
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
Here's a high-level summary of what was done: Splits: Common base traits:
Renamings:
|
odersky
added a commit
to dotty-staging/dotty
that referenced
this pull request
Apr 4, 2017
This commit can hopefully be reverted once scala#2121 is in.
ad6cb52
to
4939b47
Compare
Rebased to master |
This leads to a slight overall simplification, harmonizes pickle format with internal representation, and makes MethodTypes and PolyTypes more similar to each other. I believe the change is useful as it is, but in particular it is a useful step for an eventual unification of MethodTypes and PolyTypes.
and fix typo
It was a red herring. Symbolic names are expanded anyway to $plus / $minus, so they can't be confused with a variance prefix.
and generalize MethodParam to ParamRef, and TypeParamInfo to ParamInfo
MethodTypes have paramTypes whereas PolyTypes have paramBounds. We now harmonize by alling both paramInfos, and parameterizing types that will become common to both.
Trying to bring PolyTypes closer to TypeLambdas
Use an abstract type instead.
It seems we need a more refined way to deal with non-variant variables in pattern matches. See branch change-patmat-undet for a WIP. For the moment we disable -strict to be able to compile latest version of dotty.
It seems we need a more refined way to deal with non-variant variables in pattern matches. See branch change-patmat-undet for a WIP. For the moment we disable -strict to be able to compile latest version of dotty. (reverted from commit c8fe830)
Also, rename LambdaOver{Type,Term}s to {Type,Term}Lambda
... to distinguish between HK(proxy) and *(ground) types. Also, refactor some more methods to keep it DRY.
Replace with ParamRef
Replace with LambdaType
- Use TypeLambda instead of PolyType. - Further harmonize factory operations
Use fromParams instead.
It's too surprising to leave it as a type proxy. In all circumstances except erasure, it is not true that a PolyType is somehow the same as its result type.
Two benefits: (1) less code. (2) finding subtle bugs about parameter dependent method types. By merging with PolyTypes we are forced to take parameter dependencies into account.
- split LambdaType.equals into two equals so that tests are more specific (also avoids type testing against a trait) - re-order cases in some pattern matches with the aim to (1) move common cases earlier, (2) move more expensive trait type tests later.
odersky
added a commit
to dotty-staging/dotty
that referenced
this pull request
Jul 19, 2017
This commit can hopefully be reverted once scala#2121 is in. (reverted from commit 4c576bf)
odersky
added a commit
to dotty-staging/dotty
that referenced
this pull request
Jul 19, 2017
This commit can hopefully be reverted once scala#2121 is in. (reverted from commit 4c576bf)
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 is a huge refactoring which tries to exploit commonalities between PolyTypes and MethodTypes on the one hand and PolyParams (now called TypeParamRef) and MethodParams (now called TermParamRef) on the other hand. It creates a 2x2 matrix of lambda types where one dimension is its kind (* vs higher kinded) and the other is whether the abstraction is over terms or types.
One square of the matrix is currently unpopulated: higher-kinded types over term parameters do not exit yet. But given the refactorings they would be easy to add.
There are several benefits achieved by exploiting symmetries:
Based on #2103