File tree 2 files changed +9
-21
lines changed
compiler/src/dotty/tools/backend/sjs
tests/sjs-junit/test/org/scalajs/testsuite/compiler
2 files changed +9
-21
lines changed Original file line number Diff line number Diff line change @@ -2790,27 +2790,7 @@ class JSCodeGen()(using genCtx: Context) {
2790
2790
args : List [Tree ]): js.Tree = {
2791
2791
implicit val pos = tree.span
2792
2792
2793
- val arg = args.head
2794
-
2795
- /* Primitive number types such as scala.Int have a
2796
- * def +(s: String): String
2797
- * method, which is why we have to box the lhs sometimes.
2798
- * Otherwise, both lhs and rhs are already reference types (Any or String)
2799
- * so boxing is not necessary (in particular, rhs is never a primitive).
2800
- */
2801
- assert(! isPrimitiveValueType(receiver.tpe) || arg.tpe.isRef(defn.StringClass ))
2802
- assert(! isPrimitiveValueType(arg.tpe))
2803
-
2804
- val genLhs = {
2805
- val genLhs0 = genExpr(receiver)
2806
- // Box the receiver if it is a primitive value
2807
- if (! isPrimitiveValueType(receiver.tpe)) genLhs0
2808
- else makePrimitiveBox(genLhs0, receiver.tpe)
2809
- }
2810
-
2811
- val genRhs = genExpr(arg)
2812
-
2813
- js.BinaryOp (js.BinaryOp .String_+ , genLhs, genRhs)
2793
+ js.BinaryOp (js.BinaryOp .String_+ , genExpr(receiver), genExpr(args.head))
2814
2794
}
2815
2795
2816
2796
/** Gen JS code for a call to Any.## */
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ class RegressionTestScala3 {
44
44
assertEquals(1 , X_Issue13221 .I .i)
45
45
assertEquals(1 , X_Issue13221 .blah)
46
46
}
47
+
48
+ @ Test def primitivePlusStringThatIsATermRefIssue13518 (): Unit = {
49
+ def charPlusString (x : String ): String = 'a' + x
50
+ assertEquals(" abc" , charPlusString(" bc" ))
51
+
52
+ def intPlusString (x : String ): String = 5 + x
53
+ assertEquals(" 5bc" , intPlusString(" bc" ))
54
+ }
47
55
}
48
56
49
57
object RegressionTestScala3 {
You can’t perform that action at this time.
0 commit comments