File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
compiler/src/dotty/tools/backend/sjs Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1829,7 +1829,15 @@ class JSCodeGen()(using genCtx: Context) {
18291829 }
18301830
18311831 case Block (stats, expr) =>
1832- js.Block (stats.map(genStat) :+ genStatOrExpr(expr, isStat))
1832+ // #15419 Collapse { <undefined-param>; BoxedUnit } to <undefined-param>
1833+ val genStatsAndExpr0 = stats.map(genStat(_)) :+ genStatOrExpr(expr, isStat)
1834+ val genStatsAndExpr = genStatsAndExpr0 match {
1835+ case (undefParam @ js.Transient (UndefinedParam )) :: js.Undefined () :: Nil =>
1836+ undefParam :: Nil
1837+ case _ =>
1838+ genStatsAndExpr0
1839+ }
1840+ js.Block (genStatsAndExpr)
18331841
18341842 case Typed (expr, _) =>
18351843 expr match {
Original file line number Diff line number Diff line change @@ -761,7 +761,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
761761 // Pass previous arguments to defaultGetter
762762 val defaultGetterArgs = previousArgsValues(defaultGetter.info.paramInfoss.head.size)
763763
764- if (targetSym.isJSType) {
764+ val callGetter = if (targetSym.isJSType) {
765765 if (defaultGetter.owner.isNonNativeJSClass) {
766766 if (defaultGetter.hasAnnotation(jsdefn.JSOptionalAnnot ))
767767 js.Undefined ()
@@ -784,6 +784,12 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
784784 } else {
785785 genApplyMethod(targetTree, defaultGetter, defaultGetterArgs)
786786 }
787+
788+ // #15419 If the getter returns void, we must "box" it by returning undefined
789+ if (callGetter.tpe == jstpe.NoType )
790+ js.Block (callGetter, js.Undefined ())
791+ else
792+ callGetter
787793 }
788794
789795 private def targetSymForDefaultGetter (sym : Symbol ): Symbol =
You can’t perform that action at this time.
0 commit comments