File tree 2 files changed +16
-2
lines changed
compiler/src/dotty/tools/backend/sjs
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) {
1829
1829
}
1830
1830
1831
1831
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)
1833
1841
1834
1842
case Typed (expr, _) =>
1835
1843
expr match {
Original file line number Diff line number Diff line change @@ -761,7 +761,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
761
761
// Pass previous arguments to defaultGetter
762
762
val defaultGetterArgs = previousArgsValues(defaultGetter.info.paramInfoss.head.size)
763
763
764
- if (targetSym.isJSType) {
764
+ val callGetter = if (targetSym.isJSType) {
765
765
if (defaultGetter.owner.isNonNativeJSClass) {
766
766
if (defaultGetter.hasAnnotation(jsdefn.JSOptionalAnnot ))
767
767
js.Undefined ()
@@ -784,6 +784,12 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
784
784
} else {
785
785
genApplyMethod(targetTree, defaultGetter, defaultGetterArgs)
786
786
}
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
787
793
}
788
794
789
795
private def targetSymForDefaultGetter (sym : Symbol ): Symbol =
You can’t perform that action at this time.
0 commit comments