-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement Scala2 traits #622
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 Scala2 traits #622
Conversation
bd86088
to
0a86409
Compare
Rebased to #623 and changed comments. |
0a86409
to
d93b964
Compare
Rebased to latest make-tests-pass to be able to pass junit tests. |
d93b964
to
55c6d08
Compare
Added one more commit to make tests pass and rebased to master. |
partest seems to hang for all PRs. The log says it's succesful but the task is not terminated. |
/synch |
@adriaanm: any idea why /synch is necessary in all PRs, but only for partest? |
/synch |
i had a quick pass over the change, couldn't see any obvious issues. how will this be tested? |
I checked scabot's log but didn't see any irregularities. I'm on vacation this week, but will have a look next week. I would not recommend blindly trusting the result of /synch, because it seems it's marking things green that shouldn't be. I've never seen it do that before... I'll disable that behavior at least. |
Is this expected to work?
The last tree from
|
If memoize and constructors are run in different groups, memoize's previous postcondition "all concerete methods are implemented" is wrong, because constructors are not implemengted yet. Solved by moving the postcondition to phase Constructors.
It definitely does appear in trees, so should be included in the set. Affects how things are printed. Before, typed var's would still show up as vals.
Also: generalize expandedName so that it can cater for trait setters.
We'd like to make it reusable for a phase that treats Scala2 traits.
This brings it in line with Scala2 conventions.
Previously it didn't, because it created an ExprType, which is illegal after erasure.
A typed `_'. This is needed in a few places.
They don't exist for Scala2 traits. Instead we let the initializer be `_' and rely on trait setters (to be implemented) to initialize the field.
Erasure uncurries arguments, need to track that in memberSignature.
This phase rewrites supercalls to calls to static implementation class methods.
Fixes junit failure in dotty where a lazy val was initialized with a "...$lazy = _" assignment. Moved ElimWiildcard to one group before. It does not really matter where it goes so it might as well go someshere in the middle of the pack.
Instead of cleaning up, generate sensical code in the first place. This is shorter and (I would argue) clearer, and also has the advantage that some initializing assignments are not generated at all.
Looks like Moving it to a new phase just before
|
A transformFollowingDeep was missing, so LinkScala2ImplClasses never got to see the call.
Scala 2 doe snot generate default methods, so we always need forwarders.
We are still lacking the setup to do this right for mixed Scala 2/Dotty runtime tests. So I checked into `pos` for now.
Where are you seeing that? |
For implemented getters and forwarded methods we need a notion of "isCurrent", which means: would the getter or method before the implementation is added be a member of the implementing class? Only in this case do we need to do anything. The method formulation was previously weaker than the getter formulation, which led to an error when compiling core (duplicate methods: andThen and size).
c00974c
to
0a0d3dd
Compare
@retronym Oops that was not quite ready for prime time yet. I got distracted with the build problems. It's in somewhat better shape with the recent commits which address the problems you have encountered. There's a more comprehensive test in @DarkDimius Lazy vals do not work yet under this scheme. I have left some code in the test files regarding lazy vals, but they are currently commented out. Uncomment once they are implemented. |
Still something wrong with isCurrent. I'm investigating. |
Those WARNING statuses are green by default: https://github.com/scala/scabot/blob/master/server/src/main/scala/Actors.scala#L361 (they are stupidly added when the connection fails.. my bad) |
It looks like it's an issue with Jenkins. At the end of the partest job, it says:
This means Scabot likely did not see the status update (it's listening at that URL for Jenkins to inform us about the job ending). I suspect it could be because the ansicolor plugin does some fancy formatting with the buildlog, which is part of the notification. Maybe it can't be serialized. To test the hypothesis, I've disabled the plugin and hit rebuild on the job. UPDATE: the rebuild has a stacktrace of the jenkins notification plugin failing to notify Scabot. No idea why this broke all of a sudden:
UPDATE2: known bug: https://issues.jenkins-ci.org/browse/JENKINS-27441, fixed in jenkins 1.613 (we're on 1.611 :-() -- I'll see about upgrading UPDATE3: ah, great, there's another bug involved that's not fixed: https://issues.jenkins-ci.org/browse/JENKINS-26162 -- oh shitty jenkins and your shitty plugins... We'll have to (privately) release our own version of that plugin with this line commented out: https://github.com/jenkinsci/notification-plugin/blob/master/src/main/java/com/tikal/hudson/plugins/notification/Phase.java#L99.. The project does not seem very active. |
@adriaanm I presume that dotty could turn off direct archiving of partest logs as a workaround? |
Yep, that would work around it, but I've deployed a patched notification plugin that doesn't include logs/artifacts (not needed anyway). Plugin installed manually for now. Tracking automation: scala/scala-jenkins-infra#69 |
The policy is now made clear in a doc comment. The new part is that we will prefer a symbol defined in a subclass over a symbol defined in a superclass. With the previous commit 0a0d3dd on "More precise and uniform modelling of isCurrent" we got runtime test failures for Course-2002-03.scala because the new definition isCurrent assumed a behavior of `member` which was not assured: Namely that the merged denotation would prefer symbols in subclasses over symbols in superclasses.
The previius commit on "Refine & for Denotations" caused NotDefinedHere errors in the backend when compiling dotc/typer. These were tracked down to three occurrences in LazyVals where `enter` instead of `enteredAfter` was used. `enter` will enter a symbol in an unknown set of previous phases. Transformations that traverse scope (like erasedMembers in TypeErasure will then see the denotations of these symbols outside the scope in which they are defined.
This PR has strirred up quite a lot of trouble. Let's see whether the dust settles down now. |
Until the previous fix to Denotation-& the test here spuriously passed. The Dotty spec is that value classes synthesize equals and hashCode only if no concrete definitions are inherited except the ones from Any. That was previously miscalculated. The test has been updated to reflect the specified behavior.
Yay! And we did not even need a /synch! Thanks @adriaanm for this. |
@smarter There's plenty of precendent regarding equals != ==: scala> 1L.equals(1) scala> 1L == 1 |
Yeah, but if I have a |
@smarter The advantage of Dotty's scheme is that it treats value classes and case classes in the same way. All the bad scenarios you describe hold equally for case classes. |
For value classes we rewrite |
And for hashcode? That's the Scala bug we were talking about. But I think On Tue, Jun 2, 2015 at 3:32 PM, Guillaume Martres [email protected]
Martin Odersky |
Yes, disallowing equals/hashCode in universal traits might be the only sane solution, it breaks the scala standard library but we've already given up on that anyway. |
@smarter Agreed. Can you open an issue? Thanks! - |
Why? Those methods could be handled by the same rewriting scheme. Additionally, that will supersede current special rule for hashcode and equals, making whole scheme more regular. And what about toString? |
See #629. |
🎉 thanks -- happy it's working! |
Any more review remarks? Would be good to get this in, as it fixes quite a lot of problems and unblocks the bootstrapping project. |
I propose we merge this one, and continue with run tests. |
Added new phases that let Dotty classes implement Scala 2.x compiled traits.
The treatment of lazy vals is probably not yet correct. @DarkDimius can you take a look.
If @retronym or @lrytz could take a look to review this would be helpful as well.