File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
compiler/src/dotty/tools/backend/sjs Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -723,9 +723,10 @@ class JSCodeGen()(implicit ctx: Context) {
723723 mutable = false , rest = false )
724724 }
725725
726- def genBody () =
726+ def genBody () = localNames.makeLabeledIfRequiresEnclosingReturn(resultIRType) {
727727 if (resultIRType == jstpe.NoType ) genStat(tree)
728728 else genExpr(tree)
729+ }
729730
730731 // if (!isScalaJSDefinedJSClass(currentClassSym)) {
731732 val flags = js.MemberFlags .empty.withNamespace(namespace)
Original file line number Diff line number Diff line change @@ -92,6 +92,18 @@ object JSEncoding {
9292 returnLabelName = Some (freshName(" _return" ))
9393 js.Ident (returnLabelName.get)
9494 }
95+
96+ /* If this `LocalNameGenerator` has a `returnLabelName` (often added in the
97+ * construction of the `body` argument), wrap the resulting js.Tree to use that label.
98+ */
99+ def makeLabeledIfRequiresEnclosingReturn (tpe : jstpe.Type )(body : js.Tree )(implicit pos : ir.Position ): js.Tree = {
100+ returnLabelName match {
101+ case None =>
102+ body
103+ case Some (labelName) =>
104+ js.Labeled (js.Ident (labelName), tpe, body)
105+ }
106+ }
95107 }
96108
97109 private object LocalNameGenerator {
Original file line number Diff line number Diff line change @@ -979,7 +979,7 @@ object Build {
979979 (
980980 (dir / " shared/src/test/scala/org/scalajs/testsuite/compiler" ** ((" *.scala" : FileFilter ) -- " RegressionTest.scala" -- " ReflectiveCallTest.scala" )).get
981981 ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/lang" ** ((" *.scala" : FileFilter ) -- " ClassTest.scala" -- " StringTest.scala" )).get
982- ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/io" ** ((" *.scala" : FileFilter ) -- " ByteArrayInputStreamTest.scala" -- " ByteArrayOutputStreamTest.scala" -- " DataInputStreamTest.scala" -- " DataOutputStreamTest.scala" -- " InputStreamTest.scala" -- " OutputStreamWriterTest.scala" -- " PrintStreamTest.scala" -- " ReadersTest.scala " -- " CommonStreamsTests.scala" )).get
982+ ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/io" ** ((" *.scala" : FileFilter ) -- " ByteArrayInputStreamTest.scala" -- " ByteArrayOutputStreamTest.scala" -- " DataInputStreamTest.scala" -- " DataOutputStreamTest.scala" -- " InputStreamTest.scala" -- " OutputStreamWriterTest.scala" -- " PrintStreamTest.scala" -- " CommonStreamsTests.scala" )).get
983983 ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/math" ** " *.scala" ).get
984984 ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/net" ** ((" *.scala" : FileFilter ) -- " URITest.scala" )).get
985985 ++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/security" ** " *.scala" ).get
You can’t perform that action at this time.
0 commit comments