We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fb584eb + d28641c commit 3ef1e73Copy full SHA for 3ef1e73
compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
@@ -3532,13 +3532,16 @@ class JSCodeGen()(using genCtx: Context) {
3532
val closure = js.Closure(arrow = true, formalCaptures, formalParams, restParam, genBody, actualCaptures)
3533
3534
if (!funInterfaceSym.exists || defn.isFunctionClass(funInterfaceSym)) {
3535
- assert(!funInterfaceSym.exists || defn.isFunctionClass(funInterfaceSym),
3536
- s"Invalid functional interface $funInterfaceSym reached the back-end")
3537
val formalCount = formalParams.size
3538
val cls = ClassName("scala.scalajs.runtime.AnonFunction" + formalCount)
3539
val ctorName = MethodName.constructor(
3540
jstpe.ClassRef(ClassName("scala.scalajs.js.Function" + formalCount)) :: Nil)
3541
js.New(cls, js.MethodIdent(ctorName), List(closure))
+ } else if (funInterfaceSym.name == tpnme.FunctionXXL && funInterfaceSym.owner == defn.ScalaRuntimePackageClass) {
+ val cls = ClassName("scala.scalajs.runtime.AnonFunctionXXL")
3542
+ val ctorName = MethodName.constructor(
3543
+ jstpe.ClassRef(ClassName("scala.scalajs.js.Function1")) :: Nil)
3544
+ js.New(cls, js.MethodIdent(ctorName), List(closure))
3545
} else {
3546
assert(funInterfaceSym.isJSType,
3547
s"Invalid functional interface $funInterfaceSym reached the back-end")
library-js/src/scala/scalajs/runtime/AnonFunctionXXL.scala
@@ -0,0 +1,8 @@
1
+package scala.scalajs.runtime
2
+
3
+import scala.scalajs.js
4
5
+@inline
6
+final class AnonFunctionXXL(f: js.Function1[IArray[Object], Object]) extends scala.runtime.FunctionXXL {
7
+ override def apply(xs: IArray[Object]): Object = f(xs)
8
+}
project/MiMaFilters.scala
@@ -17,6 +17,9 @@ object MiMaFilters {
17
ProblemFilters.exclude[MissingClassProblem]("scala.util.boundary$Break"),
18
ProblemFilters.exclude[MissingClassProblem]("scala.util.boundary$Label"),
19
20
+ // Scala.js only: new runtime support class in 3.2.3; not available to users
21
+ ProblemFilters.exclude[MissingClassProblem]("scala.scalajs.runtime.AnonFunctionXXL"),
22
23
// New experimental features in 3.3.X
24
ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language#experimental.clauseInterleaving"),
25
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$clauseInterleaving$"),
tests/run/functionXXL.scala
@@ -1,5 +1,3 @@
-// scalajs: --skip --pending
-
object Test {
val f = (x1: Int,
tests/run/i2004.scala
def main(args: Array[String]) = {
tests/run/implicitFunctionXXL.scala
def main(args: Array[String]): Unit = {
tests/run/tupled-function-andThen.scala
import scala.util.TupledFunction
tests/run/tupled-function-apply.scala
@@ -119,4 +117,4 @@ object Test {
119
117
*/
120
118
extension [F, Args <: Tuple, R](f: F) def apply (args: Args)(using tf: TupledFunction[F, Args => R]): R =
121
tf.tupled(f)(args)
122
-}
tests/run/tupled-function-compose.scala
tests/run/tupled-function-extension-method.scala
@@ -13,7 +11,7 @@ object Test {
13
11
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25)
14
12
)
15
16
- println(f0())
+ portablePrintln(f0())
println(f1(1))
println(f2(1, 2))
println(f3(1, 2, 3))
@@ -34,6 +32,10 @@ object Test {
34
32
35
33
}
36
+ def portablePrintln(x: Any): Unit =
+ if x == () then println("()")
37
+ else println(x)
38
39
class Expr[T](val x: T)
40
41
// Specialized only for arity 0 and one as auto tupling will not provide the disired effect
@@ -50,4 +52,4 @@ object Test {
50
52
extension [F, Args <: Tuple, R](e: Expr[F]) def applyGiven (args: Args)(using tf: TupledFunction[F, Args ?=> R]): R =
51
53
tf.tupled(e.x)(using args)
54
55
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments