8000 Fix #2285: Adapt to 2.12 trait encoding (removal of impl classes). by sjrd · Pull Request #2288 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #2285: Adapt to 2.12 trait encoding (removal of impl classes). #2288

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 2 commits into from
Mar 11, 2016

Conversation

sjrd
Copy link
Member
@sjrd sjrd commented Mar 10, 2016

The main changes are actually related to keeping source compatibility with older versions, through more compat hacks.

Also:

  • Use isTraitOrInterface instead of isInterface to identify something that should be an interface at the IR level.
  • A method is abstract iff its body is EmptyTree.

@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016

Review by @retronym, please.

@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016

@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2917/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3771/
Test PASSed.

@gzm0
Copy link
Contributor
gzm0 commented Mar 10, 2016

Do we have no stack trace tests at all? (Otherwise I will of course ask you to add one for default methods :P)

* but we use this method in places where, previously, we had only
* `isInterface`.
*/
def isTraitOrInterface: Boolean = self.isInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard is it to write an assertion that no one calls this from PrepJSInterop? IIUC, the method would not do the same in 2.11 and 2.12, there, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. Could you elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If somebody (in the future), uses this method in PrepJSInterop (or any phase pre-mixin for that matter) and expects it to return isTrait || isInterface (which exists pre-2.12 IIUC), this will work in 2.12. However, in pre-2.12, this test will fail for traits that have implementations. (Btw. why can't you just implement this with self.isInterface || self.isTrait?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw. why can't you just implement this with self.isInterface || self.isTrait?

Er ... I didn't try ^^ I probably can, indeed. -_-'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works just as well, so I'll take that.

@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016

Do we have no stack trace tests at all? (Otherwise I will of course ask you to add one for default methods :P)

They come with the second commit, for free ;-)

@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016
!! 623 - run/t6443.scala                           [compilation failed]

failed in two jobs, so it's probably not spurious

@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016

run/t6443.scala

scalac gives us this absurd tree after mixin in 2.11.7:

  abstract trait A extends Object {
    <accessor> def helloworld$A$_setter_$s_=(x$1: String): Unit;
    def foo(d: String, d2: String): helloworld.Base = {
  <synthetic> val d2$1: String = (d2: String);
  <empty>
}.$asInstanceOf[helloworld.Base]();
    <stable> <accessor> def s(): String;
    def bar(): Unit
  };

Note that A is an interface, yet it has a method (foo) with a non-empty body, but that body, inside, contains an <empty>, which causes the blow up ...

@sjrd sjrd force-pushed the scalac-no-impl-class branch from 12d78d1 to e6eefd8 Compare March 10, 2016 23:11
@sjrd
Copy link
Member Author
sjrd commented Mar 10, 2016

@gzm0 Updated with your comments + fix run/t6443.scala (there's a comment).

@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2918/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3772/
Test FAILed.

@retronym
Copy link

@sjrd I can confirm that this branch builds successfully in a run of Scala community build using the new trait encoding.

@retronym
Copy link

This patch LGTM, too, although I'm not familiar enough with ScalaJS to offer more than a superficial review.

…ses).

The main changes are actually related to keeping source
compatibility with older versions, through more compat hacks.

Also:
* Use isTraitOrInterface instead of isInterface to identify
  something that should be an interface at the IR level.
* A method is abstract iff its body is EmptyTree.
@sjrd sjrd force-pushed the scalac-no-impl-class branch from e6eefd8 to eefb2cb Compare March 11, 2016 09:00
@sjrd
Copy link
Member Author
sjrd commented Mar 11, 2016

@retronym Thanks! I had to re-change the privateSuffix thing so that impl classes in 2.10 and 2.11 don't receive the full class name to fix the CI failure (we have a test asserting that the generated .js file does not grow). I did retest on the 2.12 temporary build, but maybe it deserves another community build to be safe.

@gzm0 Would you have time to have a second look today, please?

@gzm0
Copy link
Contributor
gzm0 commented Mar 11, 2016

LGTM

@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2919/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3774/
Test PASSed.

@sjrd
Copy link
Member Author
sjrd commented Mar 11, 2016

@sjrd
Copy link
Member Author
sjrd commented Mar 11, 2016

Nightly passed :-)

sjrd added a commit that referenced this pull request Mar 11, 2016
Fix #2285: Adapt to 2.12 trait encoding (removal of impl classes).
@sjrd sjrd merged commit 98e0591 into scala-js:master Mar 11, 2016
@sjrd sjrd deleted the scalac-no-impl-class branch March 11, 2016 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0