Skip to content

Commit ea641d3

Browse files
committed
Scala.js: Do not emit definitions for primitive methods.
1 parent 82752b7 commit ea641d3

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ class DottyPrimitives(ictx: Context) {
397397
primitives.toMap
398398
}
399399

400+
def isPrimitive(sym: Symbol): Boolean =
401+
primitives.contains(sym)
402+
400403
def isPrimitive(fun: Tree): Boolean =
401404
given Context = ictx
402405
primitives.contains(fun.symbol)
@@ -407,4 +410,3 @@ class DottyPrimitives(ictx: Context) {
407410
case _ => true
408411
})
409412
}
410-

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ class JSCodeGen()(using genCtx: Context) {
791791
toIRType(param.info), mutable = false, rest = false)
792792
}
793793

794-
/*if (primitives.isPrimitive(sym)) {
794+
if (primitives.isPrimitive(sym)) {
795795
None
796-
} else*/ if (sym.is(Deferred)) {
796+
} else if (sym.is(Deferred)) {
797797
Some(js.MethodDef(js.MemberFlags.empty, methodName, originalName,
798798
jsParams, toIRType(patchedResultType(sym)), None)(
799799
OptimizerHints.empty, None))

compiler/src/dotty/tools/backend/sjs/JSPrimitives.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class JSPrimitives(ictx: Context) extends DottyPrimitives(ictx) {
5959
override def getPrimitive(app: Apply, tpe: Type)(using Context): Int =
6060
jsPrimitives.getOrElse(app.fun.symbol, super.getPrimitive(app, tpe))
6161

62+
override def isPrimitive(sym: Symbol): Boolean =
63+
jsPrimitives.contains(sym) || super.isPrimitive(sym)
64+
6265
override def isPrimitive(fun: Tree): Boolean =
6366
jsPrimitives.contains(fun.symbol(using ictx)) || super.isPrimitive(fun)
6467

0 commit comments

Comments
 (0)