Skip to content

Scala.js: Handle private inner JS classes. #10115

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3384,8 +3384,15 @@ class JSCodeGen()(using genCtx: Context) {
} else {
val captureValues = {
if (code == CREATE_INNER_JS_CLASS) {
/* Private inner classes that do not actually access their outer
* pointer do not receive an outer argument. We therefore count
* the number of constructors that have non-empty param list to
* know how many times we need to pass `this`.
*/
val requiredThisParams =
classSym.info.decls.lookupAll(nme.CONSTRUCTOR).count(_.info.paramInfoss.head.nonEmpty)
val outer = genThis()
List.fill(classSym.info.decls.lookupAll(nme.CONSTRUCTOR).size)(outer)
List.fill(requiredThisParams)(outer)
} else {
val fakeNewInstances = args(2).asInstanceOf[JavaSeqLiteral].elems
fakeNewInstances.flatMap(genCaptureValuesFromFakeNewInstance(_))
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,6 @@ object Build {
++ (dir / "shared/src/test/require-jdk7" ** "*.scala").get

++ (dir / "js/src/test/scala" ** (("*.scala": FileFilter)
-- "ExportsTest.scala" // JS exports + IR checking error
-- "ObjectTest.scala" // compile errors caused by #9588
-- "StackTraceTest.scala" // would require `npm install source-map-support`
-- "UnionTypeTest.scala" // requires the Scala 2 macro defined in Typechecking*.scala
Expand All @@ -1118,6 +1117,7 @@ object Build {
Test / testOptions += Tests.Filter { name =>
!Set[String](
"org.scalajs.testsuite.jsinterop.AsyncTest", // needs JS exports in PromiseMock.scala
"org.scalajs.testsuite.jsinterop.ExportsTest", // JS exports
"org.scalajs.testsuite.jsinterop.JSExportStaticTest", // JS exports

// Not investigated so far
Expand Down