Skip to content

Trait constructors on scala.js #7377

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
wants to merge 1 commit into from
Closed

Conversation

cquiroz
Copy link
Contributor

@cquiroz cquiroz commented Oct 6, 2019

I'm trying to get RangesTests to run on scala.js but I by default get a Linking error

[error] Referring to non-existent method constructor scala.math.Integral.<init>() [error] called from constructor org.scalajs.testsuite.scalalib.RangesTest$aIsIntegral$1$.<init>(scala.runtime.LazyRef,org.scalajs.testsuite.scalalib.RangesTest)

After some discussions in gitter I managed to change it to call the trait constructor but there is an extra step of making the call static and I haven't been able to find it. At the moment my error is as below with a minimal test code to reproduce it

[error] Referring to non-existent method static scala.math.PartialOrdering.$$init$(scala.math.PartialOrdering)void
[error]   called from constructor hello.Integral$B$2.<init>(java.lang.Object)

I've discussed this with @sjrd in Gitter but haven't found a solution. Hence I'm sending this draft PR to get feedback

Signed-off-by: Carlos Quiroz <[email protected]>
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@@ -78,6 +78,12 @@ class LinkScala2Impls extends MiniPhase with IdentityDenotTransformer { thisPhas
val impl = implMethod(sel.symbol)
if (impl.exists) Apply(ref(impl), This(currentClass) :: args).withSpan(app.span)
else app // could have been an abstract method in a trait linked to from a super constructor
case Apply(sel @ Select(Super(a, b), _), args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part should be improved but basically tells to do the transform for constructors even on scala.js

if (meth.isConstructor)
if (meth.isConstructor) {
if (ctx.settings.scalajs.value) {
// Is this the static call?
cls.info.decl(nme.TRAIT_CONSTRUCTOR).symbol
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is incorrect but haven't been able to figure out the correct call, any suggestions?

package hello

// Minimal reproduction
object Integral {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using this for testing but it probably should be removed before merging

@sjrd
Copy link
Member

sjrd commented Jul 22, 2020

This was superseded by #7962 and has become moot since #8652.

@sjrd sjrd closed this Jul 22, 2020
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.

3 participants