-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement AppliedTermRef (singleton types for term-level applications) #3887
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1e5e86a
Add AppliedTermRef type
gsps 6dcc75d
Add curly-brace singleton type syntax for AppliedTermRef
gsps 1159370
Subtyping, Stable primitives & cleaned-up creation of AppliedTermRef
gsps 058c673
Add AppliedTermRef pickling and (preliminary) pretty printing
gsps 10e182b
Fix AppliedTermRef pretty printing
gsps aa832f8
Add existing tests and a new one inspired by recent issue
gsps 0261183
Fix homogenize and add TODO for summoning
gsps aa67ec8
Adapt check-init test to not fail on unrelated pure expression warning
gsps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1536,6 +1536,7 @@ object Parsers { | |
* | `(' ArgTypes `)' | ||
* | `_' TypeBounds | ||
* | Refinement | ||
* | `{` PostfixExpr `}` | ||
* | Literal | ||
* | ‘$’ ‘{’ Block ‘}’ | ||
*/ | ||
|
@@ -1545,7 +1546,7 @@ object Parsers { | |
makeTupleOrParens(inParens(argTypes(namedOK = false, wildOK = true))) | ||
} | ||
else if (in.token == LBRACE) | ||
atSpan(in.offset) { RefinedTypeTree(EmptyTree, refinement()) } | ||
atSpan(in.offset) { inBraces(emptyRefinementOrSingletonExpr()) } | ||
else if (isSimpleLiteral) { SingletonTypeTree(literal(inType = true)) } | ||
else if (isIdent(nme.raw.MINUS) && in.lookaheadIn(numericLitTokens)) { | ||
val start = in.offset | ||
|
@@ -1575,6 +1576,11 @@ object Parsers { | |
} | ||
} | ||
|
||
def emptyRefinementOrSingletonExpr(): Tree = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe call this |
||
if (!isStatSeqEnd && !isDclIntro) SingletonTypeTree(postfixExpr()) | ||
else RefinedTypeTree(EmptyTree, refineStatSeq()) | ||
} | ||
|
||
val handleSingletonType: Tree => Tree = t => | ||
if (in.token == TYPE) { | ||
in.nextToken() | ||
|
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class A(a: Int) { | ||
a + 3 | ||
val _ = a + 3 | ||
def foo() = a * 2 | ||
} | ||
|
||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to have this in thirdTry and not firstTry? Also I think it'd be good to have more testcases that stress-test the subtype checks for AppliedTermRef. For example, what happens when an AppliedTermRef is hidden in a type alias?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a test that relies on a type application:
I'll also add one that relies on a simple alias.