10000 Merge '0.6.x' into 'master'. · scala-js/scala-js@ce0a278 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce0a278

Browse files
committed
Merge '0.6.x' into 'master'.
2 parents d592b99 + a4bce39 commit ce0a278

File tree

131 files changed

+6425
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+6425
-43
lines changed

Jenkinsfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ def otherJavaVersions = []
363363
def allJavaVersions = otherJavaVersions.clone()
364364
allJavaVersions << mainJavaVersion
365365

366-
def mainScalaVersion = "2.12.4"
367-
def mainScalaVersions = ["2.11.12", "2.12.4", "2.13.0-M2"]
366+
def mainScalaVersion = "2.12.5"
367+
def mainScalaVersions = ["2.11.12", "2.12.5", "2.13.0-M3"]
368368
def otherScalaVersions = [
369369
"2.11.0",
370370
"2.11.1",
@@ -378,7 +378,8 @@ def otherScalaVersions = [
378378
"2.11.12",
379379
"2.12.1",
380380
"2.12.2",
381-
"2.12.3"
381+
"2.12.3",
382+
"2.12.4"
382383
]
383384

384385
// The 'quick' matrix
@@ -402,7 +403,7 @@ allJavaVersions.each { javaVersion ->
402403
}
403404
quickMatrix.add([task: "partestc", scala: "2.11.0", java: mainJavaVersion])
404405
quickMatrix.add([task: " 2851 sbtplugin-test", toolsscala: "2.10.7", sbt_version_override: "", java: mainJavaVersion])
405-
quickMatrix.add([task: "sbtplugin-test", toolsscala: "2.12.4", sbt_version_override: "1.0.0", java: mainJavaVersion])
406+
quickMatrix.add([task: "sbtplugin-test", toolsscala: "2.12.5", sbt_version_override: "1.0.0", java: mainJavaVersion])
406407

407408
// The 'full' matrix
408409
def fullMatrix = quickMatrix.clone()

ci/checksizes.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ case $FULLVER in
88
2.11.12)
99
VER=2.11
1010
;;
11-
2.12.4)
11+
2.12.5)
1212
VER=2.12
1313
;;
14-
2.13.0-M2)
15-
VER=2.13.0-M2
14+
2.13.0-M3)
15+
VER=2.13.0-M3
1616
;;
17-
2.11.0|2.11.1|2.11.2|2.11.4|2.11.5|2.11.6|2.11.7|2.11.8|2.11.11|2.12.1|2.12.2|2.12.3)
17+
2.11.0|2.11.1|2.11.2|2.11.4|2.11.5|2.11.6|2.11.7|2.11.8|2.11.11|2.12.1|2.12.2|2.12.3|2.12.4)
1818
echo "Ignoring checksizes for Scala $FULLVER"
1919
exit 0
2020
;;
@@ -39,13 +39,13 @@ case $FULLVER in
3939
REVERSI_PREOPT_GZ_EXPECTEDSIZE=69000
4040
REVERSI_OPT_GZ_EXPECTEDSIZE=30000
4141
;;
42-
2.12.4)
42+
2.12.5)
4343
REVERSI_PREOPT_EXPECTEDSIZE=606000
4444
REVERSI_OPT_EXPECTEDSIZE=138000
4545
REVERSI_PREOPT_GZ_EXPECTEDSIZE=74000
4646
REVERSI_OPT_GZ_EXPECTEDSIZE=32000
4747
;;
48-
2.13.0-M2)
48+
2.13.0-M3)
4949
REVERSI_PREOPT_EXPECTEDSIZE=605000
5050
REVERSI_OPT_EXPECTEDSIZE=138000
5151
REVERSI_PREOPT_GZ_EXPECTEDSIZE=74000

compiler/src/main/scala/org/scalajs/nscplugin/GenJSCode.scala

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,8 @@ abstract class GenJSCode extends plugins.PluginComponent
10071007
genRegisterReflectiveInstantiationForModuleClass(sym)
10081008
else if (sym.isModuleClass)
10091009
None // #3228
1010+
else if (sym.isLifted && !sym.originalOwner.isClass)
1011+
None // #3227
10101012
else
10111013
genRegisterReflectiveInstantiationForNormalClass(sym)
10121014
}
@@ -1245,6 +1247,42 @@ abstract class GenJSCode extends plugins.PluginComponent
12451247
mkSubPreCalls(constructorTree, overrideNumRef)
12461248

12471249
val preSuperCall = {
1250+
def checkForUndefinedParams(args: List[js.Tree]): List[js.Tree] = {
1251+
def isUndefinedParam(tree: js.Tree): Boolean = tree match {
1252+
case js.Transient(UndefinedParam) => true
1253+
case _ => false
1254+
}
1255+
1256+
if (!args.exists(isUndefinedParam)) {
1257+
args
1258+
} else {
1259+
/* If we find an undefined param here, we're in trouble, because
1260+
* the handling of a default param for the target constructor has
1261+
* already been done during overload resolution. If we store an
1262+
* `undefined` now, it will fall through without being properly
1263+
* processed.
1264+
*
1265+
* Since this seems very tricky to deal with, and a pretty rare
1266+
* use case (with a workaround), we emit an "implementation
1267+
* restriction" error.
1268+
*/
1269+
reporter.error(pos,
1270+
"Implementation restriction: in a JS class, a secondary " +
1271+
"constructor calling another constructor with default " +
1272+
"parameters must provide the values of all parameters.")
1273+
1274+
/* Replace undefined params by undefined to prevent subsequent
1275+
* compiler crashes.
1276+
*/
1277+
args.map { arg =>
1278+
if (isUndefinedParam(arg))
1279+
js.Undefined()(arg.pos)
1280+
else
1281+
arg
1282+
}
1283+
}
1284+
}
1285+
12481286
constructorTree.method.body.get match {
12491287
case js.Block(stats) =>
12501288
val beforeSuperCall = stats.takeWhile {
@@ -1254,14 +1292,16 @@ abstract class GenJSCode extends plugins.PluginComponent
12541292
val superCallParams = stats.collectFirst {
12551293
case js.ApplyStatic(_, mtd, js.This() :: args)
12561294
if ir.Definitions.isConstructorName(mtd.name) =>
1257-
zipMap(outputParams, args)(js.Assign(_, _))
1295+
val checkedArgs = checkForUndefinedParams(args)
1296+
zipMap(outputParams, checkedArgs)(js.Assign(_, _))
12581297
}.getOrElse(Nil)
12591298

12601299
beforeSuperCall ::: superCallParams
12611300

12621301
case js.ApplyStatic(_, mtd, js.This() :: args)
12631302
if ir.Definitions.isConstructorName(mtd.name) =>
1264-
zipMap(outputParams, args)(js.Assign(_, _))
1303+
val checkedArgs = checkForUndefinedParams(args)
1304+
zipMap(outputParams, checkedArgs)(js.Assign(_, _))
12651305

12661306
case _ => Nil
12671307
}

compiler/src/test/scala/org/scalajs/nscplugin/test/NonNativeJSTypeTest.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,18 @@ class NonNativeJSTypeTest extends DirectTest with TestHelpers {
643643
"""
644644
}
645645

646+
@Test
647+
def noCallOtherConstructorsWithLeftOutDefaultParams: Unit = {
648+
"""
649+
class A(x: Int, y: String = "default") extends js.Object {
650+
def this() = this(12)
651+
}
652+
""" hasErrors
653+
"""
654+
|newSource1.scala:5: error: Implementation restriction: in a JS class, a secondary constructor calling another constructor with default parameters must provide the values of all parameters.
655+
| class A(x: Int, y: String = "default") extends js.Object {
656+
| ^
657+
"""
658+
}
659+
646660
}

javalanglib/src/main/scala/java/lang/Character.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ object Character {
191191
(c & HighSurrogateMask) == HighSurrogateID
192192
@inline def isLowSurrogate(c: scala.Char): scala.Boolean =
193193
(c & LowSurrogateMask) == LowSurrogateID
194+
@inline def isSurrogate(c: scala.Char): scala.Boolean =
195+
isHighSurrogate(c) || isLowSurrogate(c)
194196
@inline def isSurrogatePair(high: scala.Char, low: scala.Char): scala.Boolean =
195197
isHighSurrogate(high) && isLowSurrogate(low)
196198

library/src/main/scala/scala/scalajs/reflect/Reflect.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ object Reflect {
118118
* The class or one of its super types (classes or traits) must be annotated
119119
* with
120120
* [[scala.scalajs.reflect.annotation.EnableReflectiveInstantiation @EnableReflectiveInstantiation]].
121-
* Moreover, the class must not be abstract.
121+
* Moreover, the class must not be abstract, nor be a local class (i.e., a
122+
* class defined inside a `def`). Inner classes (defined inside another
123+
* class) are supported.
122124
*
123125
* If the class cannot be found, either because it does not exist,
124-
* was not `@EnableReflectiveInstantiation` or was abstract, this method
125-
* returns `None`.
126+
* was not `@EnableReflectiveInstantiation` or was abstract or local, this
127+
* method returns `None`.
126128
*
127129
* @param fqcn
128130
* Fully-qualified name of the class

0 commit comments

Comments
 (0)
0