-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement tracked
members
#21761
Open
KacperFKorban
wants to merge
5
commits into
scala:main
Choose a base branch
from
dotty-staging:abstract-tracked
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−50
Open
Implement tracked
members
#21761
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6465291
First draft of abstract tracked vals
KacperFKorban f1d146d
Disallow tracked for unusupported definitions, move tracked modifier …
KacperFKorban d2b6a61
Fix handling tracked param accessors
KacperFKorban f7b7188
Fix tracked modifier checks
KacperFKorban 567b2c1
Support inferring precise types for non-overriding members declared a…
KacperFKorban 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:4:14 ---------------------------------------------------------- | ||
4 |tracked trait F // error | ||
|^^^^^^^^^^^^^^^ | ||
|Modifier tracked is not allowed for this definition | ||
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:9:15 ---------------------------------------------------------- | ||
9 |tracked object O // error | ||
|^^^^^^^^^^^^^^^^ | ||
|Modifier tracked is not allowed for this definition | ||
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:11:14 --------------------------------------------------------- | ||
11 |tracked class C // error | ||
|^^^^^^^^^^^^^^^ | ||
|Modifier tracked is not allowed for this definition | ||
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:7:14 ---------------------------------------------------------- | ||
7 | tracked def f: F // error | ||
| ^^^^^^^^^^^^^^^^ | ||
| Modifier tracked is not allowed for this definition | ||
-- [E156] Syntax Error: tests/neg/abstract-tracked.scala:14:14 --------------------------------------------------------- | ||
14 | tracked val x = 1 // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Modifier tracked is not allowed for this definition |
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import scala.language.experimental.modularity | ||
import scala.language.future | ||
|
||
tracked trait F // error | ||
|
||
trait G: | ||
tracked def f: F // error | ||
|
||
tracked object O // error | ||
|
||
tracked class C // error | ||
|
||
def f = | ||
tracked val x = 1 // error |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import scala.language.experimental.modularity | ||
import scala.language.future | ||
|
||
trait F: | ||
tracked val a: Int | ||
|
||
trait G: | ||
tracked val b: Int | ||
|
||
trait H: | ||
tracked val c: Int = 3 | ||
|
||
trait I extends F | ||
|
||
trait J extends F: | ||
val a: Int = 1 | ||
|
||
class K(tracked val d: Int) | ||
|
||
class L | ||
|
||
trait M: | ||
val f: Int | ||
|
||
object Test: | ||
val f = new F: | ||
val a = 1 | ||
val g = new G: | ||
val b: 2 = 2 | ||
val h = new H: | ||
override val c = 4 | ||
val i = new I: | ||
val a = 5 | ||
val j = new J: | ||
override val a = 6 | ||
val k = new K(7) | ||
val l = new L { | ||
tracked val e = 8 | ||
} | ||
val m = new M: | ||
tracked val f = 9 | ||
|
||
summon[f.a.type <:< 1] | ||
summon[g.b.type <:< 2] | ||
summon[h.c.type <:< 4] | ||
summon[i.a.type <:< 5] | ||
summon[j.a.type <:< 6] | ||
summon[k.d.type <:< 7] | ||
// summon[l.e.type <:< 8] // unrelated issue -- error: e is not a member of L | ||
summon[m.f.type <:< 9] |
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.
It seems dangerous to set
info
here. This means that the symbol info gets modified when theval
is type-checked, so it's not the same before and after in definition order.Here is an example:
I am wondering if the logic wouldn't be better placed in
Namer.Completer
, maybe setting the flag incompleteInCreationContext
and computing the precise member type invalOrDefDefSig
? Have you thought about doing so? However this is not easy to do without causing cyclic references.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.
I haven't been able to do exactly what I described above due to cyclic references, but I could move the whole
setAbstractTrackedInfo
toNamer.Completer
: dotty-staging#53.Still seems dirty to write over
.info
, but at least it's done directly when completing the symbol. What do you think?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.
Yes, seemed dirty to me too, but it also seemed like the least intrusive way to do it. If moving the logic to Namer works, then it should be the better solution, so we can merge dotty-staging#53.
I would probably wait on Martin's opinion though. What do you think?
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.
Sounds good to me to wait on Martin's opinion.
And my PR currently fails picklings test actually.