Skip to content

Commit e7a197c

Browse files
Merge pull request #10115 from dotty-staging/sjs-private-inner-js-class
Scala.js: Handle private inner JS classes.
2 parents c0ff503 + ad9c642 commit e7a197c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3384,8 +3384,15 @@ class JSCodeGen()(using genCtx: Context) {
33843384
} else {
33853385
val captureValues = {
33863386
if (code == CREATE_INNER_JS_CLASS) {
3387+
/* Private inner classes that do not actually access their outer
3388+
* pointer do not receive an outer argument. We therefore count
3389+
* the number of constructors that have non-empty param list to
3390+
* know how many times we need to pass `this`.
3391+
*/
3392+
val requiredThisParams =
3393+
classSym.info.decls.lookupAll(nme.CONSTRUCTOR).count(_.info.paramInfoss.head.nonEmpty)
33873394
val outer = genThis()
3388-
List.fill(classSym.info.decls.lookupAll(nme.CONSTRUCTOR).size)(outer)
3395+
List.fill(requiredThisParams)(outer)
33893396
} else {
33903397
val fakeNewInstances = args(2).asInstanceOf[JavaSeqLiteral].elems
33913398
fakeNewInstances.flatMap(genCaptureValuesFromFakeNewInstance(_))

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,6 @@ object Build {
11091109
++ (dir / "shared/src/test/require-jdk7" ** "*.scala").get
11101110

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

11311131
// Not investigated so far

0 commit comments

Comments
 (0)