-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
if sel.symbol.owner.is(Scala2x) && currentClass.mixins.contains(sel.symbol.owner) && sel.symbol.isConstructor => | ||
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 _ => | ||
app | ||
} | ||
|
@@ -88,8 +94,13 @@ class LinkScala2Impls extends MiniPhase with IdentityDenotTransformer { thisPhas | |
val implName = ImplMethName(meth.name.asTermName) | ||
val cls = meth.owner | ||
if (cls.isAllOf(Scala2xTrait)) | ||
if (meth.isConstructor) | ||
if (meth.isConstructor) { | ||
if (ctx.settings.scalajs.value) { | ||
// Is this the static call? | ||
cls.info.decl(nme.TRAIT_CONSTRUCTOR).symbol | ||
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. I think this is incorrect but haven't been able to figure out the correct call, any suggestions? |
||
} else | ||
cls.info.decl(nme.TRAIT_CONSTRUCTOR).symbol | ||
} | ||
else | ||
cls.info.decl(implName) | ||
.suchThat(c => FullParameterization.memberSignature(c.info) == meth.signature) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package hello | ||
|
||
// Minimal reproduction | ||
object Integral { | ||
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. I'm using this for testing but it probably should be removed before merging |
||
def main(args: Array[String]): Unit = { | ||
trait A[T] extends Ordering[T] | ||
case class B[T](v: T) extends A[T] { | ||
def compare(x: T, y: T): Int = 0 | ||
} | ||
|
||
B(0) | ||
} | ||
} |
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.
This part should be improved but basically tells to do the transform for constructors even on scala.js