-
Notifications
You must be signed in to change notification settings - Fork 395
Fix #4465: Properly call default param getters for nested JS ctors #4502
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
Conversation
test-suite/js/src/test/scala/org/scalajs/testsuite/jsinterop/NestedJSClassTest.scala
Show resolved
Hide resolved
val allParamsAndInfos = for { | ||
(sym, info) <- allParamSyms.zip(jsParamInfos(sym)) | ||
} yield { | ||
genVarRef(sym) -> info | ||
} |
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.
val allParamsAndInfos = for { | |
(sym, info) <- allParamSyms.zip(jsParamInfos(sym)) | |
} yield { | |
genVarRef(sym) -> info | |
} | |
val allParamsAndInfos = for { | |
(paramSym, info) <- allParamSyms.zip(jsParamInfos(sym)) | |
} yield { | |
genVarRef(paramSym) -> info | |
} |
The double sym
on the left and on the right of <-
is confusing.
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 comment still stands.
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 have also renamed sym
to ctorSym
. It was confusing me as well :P
if (!trgSym.isLifted) | ||
genLoadModule(trgSym) | ||
else | ||
genNew(trgSym, trgSym.primaryConstructor, captures) |
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'm pretty sure this is incorrect. We could create several instances of the module per enclosing instance, if we use a new
every time. We should use the getter method on the enclosing instance instead. If the enclosing instance is a JS class, that means accessing the property of its JSName
; if it is a Scala class, it means calling the Scala method with its name and 0 argument.
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.
We should add a side-effect in the constructor of the companion object in the tests, and test that it is only applied once per enclosing instance.
Uh oh, this sounds more complicated. Shall we postpone this past 1.6.0? |
Yes, let's postpone it. |
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.
The fix basically LGTM now. I have a few minor comments.
val allParamsAndInfos = for { | ||
(sym, info) <- allParamSyms.zip(jsParamInfos(sym)) | ||
} yield { | ||
genVarRef(sym) -> info | ||
} |
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 comment still stands.
assert(captures.size == 1, "expected exactly one capture") | ||
|
||
// Find the module accessor. | ||
val outer = enteringPhase(currentRun.picklerPhase)(trgSym.owner) |
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.
Does trgSym.originalOwner
work? It doesn't require time travel, IIRC.
val name = enteringPhase(currentRun.typerPhase)(trgSym.unexpandedName) | ||
|
||
val modAccessor = outer.info.members.lookupModule(name) | ||
val receiver = captures(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.
val receiver = captures(0) | |
val receiver = captures.head |
?
No description provided.