File tree 3 files changed +15
-2
lines changed
compiler/src/dotty/tools/backend/sjs 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) {
723
723
mutable = false , rest = false )
724
724
}
725
725
726
- def genBody () =
726
+ def genBody () = localNames.makeLabeledIfRequiresEnclosingReturn(resultIRType) {
727
727
if (resultIRType == jstpe.NoType ) genStat(tree)
728
728
else genExpr(tree)
729
+ }
729
730
730
731
// if (!isScalaJSDefinedJSClass(currentClassSym)) {
731
732
val flags = js.MemberFlags .empty.withNamespace(namespace)
Original file line number Diff line number Diff line change @@ -92,6 +92,18 @@ object JSEncoding {
92
92
returnLabelName = Some (freshName(" _return" ))
93
93
js.Ident (returnLabelName.get)
94
94
}
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
+ }
95
107
}
96
108
97
109
private object LocalNameGenerator {
Original file line number Diff line number Diff line change @@ -979,7 +979,7 @@ object Build {
979
979
(
980
980
(dir / " shared/src/test/scala/org/scalajs/testsuite/compiler" ** ((" *.scala" : FileFilter ) -- " RegressionTest.scala" -- " ReflectiveCallTest.scala" )).get
981
981
++ (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
983
983
++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/math" ** " *.scala" ).get
984
984
++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/net" ** ((" *.scala" : FileFilter ) -- " URITest.scala" )).get
985
985
++ (dir / " shared/src/test/scala/org/scalajs/testsuite/javalib/security" ** " *.scala" ).get
You can’t perform that action at this time.
0 commit comments