Skip to content

Commit 3edbc71

Browse files
committed
Drop support for Scala 2.10.x.
In this commit, we completely drop support for Scala 2.10.x in Scala.js code. Note that our JVM artifacts are still cross-compiled with 2.10.x, because we still support sbt 0.13.16+ which runs on 2.10. However, it will not be possible to use `enablePlugins(ScalaJSPlugin)` with `scalaVersion := "2.10.x"` anymore. This includes: * Drop CI tasks using 2.10.x with JS artifacts (but not with JVM artifacts). * Remove all workarounds for Scala 2.10 compiler bugs, such as crashes for some usages of `js.Dynamic`. * Remove all 2.10-specific stuff from `CompatComponent` in the compiler. * Remove all 2.10-specific assumptions or branches in the test suite. This commit does not include: * Drop `js.Dynamic.x` and the associated compiler tricks, which work around the 2.10 *library* (not compiler), and deserve a separate commit anyway. * Take advantage of new 2.11 language features, such as making the underlying val of value classes private. Those items are left for further commits.
1 parent e407e10 commit 3edbc71

File tree

67 files changed

+149
-5165
lines changed

Some content is hidden

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

67 files changed

+149
-5165
lines changed

Diff for: TESTING

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ This file contains test cases that should be manually executed.
44

55
The following HTML-runners must be manually tested:
66

7-
examples/helloworld/helloworld-{2.10|2.11}{|-fastopt}.html
8-
examples/reversi/reversi-{2.10|2.11}{|-fastopt}.html
7+
examples/helloworld/helloworld-{2.11|2.12}{|-fastopt}.html
8+
examples/reversi/reversi-{2.11|2.12}{|-fastopt}.html
99

1010
The following sbt-plugin generated test runners must be manually tested (with
11-
Scala 2.10, 2.11 and 2.12, and in `FastOptStage` and `FullOptStage`):
11+
Scala 2.11 and 2.12, and in `FastOptStage` and `FullOptStage`):
1212

1313
testingExample/testHtml
1414
testSuite/testHtml
@@ -17,7 +17,7 @@ Scala 2.10, 2.11 and 2.12, and in `FastOptStage` and `FullOptStage`):
1717

1818
To test source maps, do the following on:
1919

20-
examples/reversi/reversi-{2.10|2.11}{|-fastopt}.html
20+
examples/reversi/reversi-{2.11|2.12}{|-fastopt}.html
2121

2222
1. Open the respective file in Google Chrome
2323
2. Set a break-point in the HTML launcher on the `new Reversi` statement

Diff for: ci/checksizes.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ BASEDIR="`dirname $0`/.."
55
FULLVER="$1"
66

77
case $FULLVER in
8-
2.10.2)
9-
VER=2.10
10-
;;
118
2.11.12)
129
VER=2.11
1310
;;
@@ -17,7 +14,7 @@ case $FULLVER in
1714
2.13.0-M2)
1815
VER=2.13.0-M2
1916
;;
20-
2.10.3|2.10.4|2.10.5|2.10.6|2.10.7|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)
2118
echo "Ignoring checksizes for Scala $FULLVER"
2219
exit 0
2320
;;
@@ -36,12 +33,6 @@ REVERSI_PREOPT_GZ_SIZE=$(stat '-c%s' "$REVERSI_PREOPT.gz")
3633
REVERSI_OPT_GZ_SIZE=$(stat '-c%s' "$REVERSI_OPT.gz")
3734

3835
case $FULLVER in
39-
2.10.2)
40-
REVERSI_PREOPT_EXPECTEDSIZE=512000
41-
REVERSI_OPT_EXPECTEDSIZE=115000
42-
REVERSI_PREOPT_GZ_EXPECTEDSIZE=69000
43-
REVERSI_OPT_GZ_EXPECTEDSIZE=30000
44-
;;
4536
2.11.12)
4637
REVERSI_PREOPT_EXPECTEDSIZE=507000
4738
REVERSI_OPT_EXPECTEDSIZE=116000

Diff for: ci/matrix.xml

+3-40
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
<task id="bootstrap"><![CDATA[
160160
setJavaVersion $java
161161
npm install &&
162+
sbt ++$scala tools/test &&
162163
sbt ++$scala irJS/test toolsJS/test &&
163164
sbt 'set scalaJSStage in Global := FullOptStage' \
164165
++$scala irJS/test toolsJS/test &&
@@ -173,7 +174,7 @@
173174
<task id="tools-stubs"><![CDATA[
174175
setJavaVersion $java
175176
npm install &&
176-
sbt ++$scala tools/package ir/test tools/test \
177+
sbt ++$scala tools/package ir/test \
177178
stubs/package nodeJSEnv/test testAdapter/test \
178179
ir/mimaReportBinaryIssues tools/mimaReportBinaryIssues \
179180
jsEnvs/mimaReportBinaryIssues jsEnvsTestKit/mimaReportBinaryIssues \
@@ -188,7 +189,7 @@
188189
<task id="tools-stubs-sbtplugin"><![CDATA[
189190
setJavaVersion $java
190191
npm install &&
191-
sbt ++$scala tools/package ir/test tools/test \
192+
sbt ++$scala tools/package ir/test \
192193
stubs/package nodeJSEnv/test testAdapter/test \
193194
sbtPlugin/package \
194195
ir/mimaReportBinaryIssues tools/mimaReportBinaryIssues \
@@ -268,10 +269,6 @@
268269

269270
<matrix id="pr">
270271
<!-- Main test tasks -->
271-
<run task="main">
272-
<v n="scala">2.10.2</v>
273-
<v n="java">1.8</v>
274-
</run>
275272
<run task="main">
276273
<v n="scala">2.11.12</v>
277274
<v n="java">1.8</v>
@@ -286,11 +283,6 @@
286283
</run>
287284

288285
<!-- Test suite on ECMAScript5 tasks -->
289-
<run task="test-suite-ecma-script5">
290-
<v n="scala">2.10.2</v>
291-
<v n="java">1.8</v>
292-
<v n="testSuite">testSuite</v>
293-
</run>
294286
<run task="test-suite-ecma-script5">
295287
<v n="scala">2.11.12</v>
296288
<v n="java">1.8</v>
@@ -332,11 +324,6 @@
332324
</run>
333325

334326
<!-- Test suite on ECMAScript6 tasks -->
335-
<run task="test-suite-ecma-script6">
336-
<v n="scala">2.10.2</v>
337-
<v n="java">1.8</v>
338-
<v n="testSuite">testSuite</v>
339-
</run>
340327
<run task="test-suite-ecma-script6">
341328
<v n="scala">2.11.12</v>
342329
<v n="java">1.8</v>
@@ -371,10 +358,6 @@
371358
</run>
372359

373360
<!-- Bootstrap test tasks -->
374-
<run task="bootstrap">
375-
<v n="scala">2.10.2</v>
376-
<v n="java">1.8</v>
377-
</run>
378361
<run task="bootstrap">
379362
<v n="scala">2.11.12</v>
380363
<v n="java">1.8</v>
@@ -439,26 +422,6 @@
439422
<run matrix="pr" />
440423

441424
<!-- Main test tasks (all remaining Scala versions) -->
442-
<run task="main">
443-
<v n="scala">2.10.3</v>
444-
<v n="java">1.8</v>
445-
</run>
446-
<run task="main">
447-
<v n="scala">2.10.4</v>
448-
<v n="java">1.8</v>
449-
</run>
450-
<run task="main">
451-
<v n="scala">2.10.5</v>
452-
<v n="java">1.8</v>
453-
</run>
454-
<run task="main">
455-
<v n="scala">2.10.6</v>
456-
<v n="java">1.8</v>
457-
</run>
458-
<run task="main">
459-
<v n="scala">2.10.7</v>
460-
<v n="java">1.8</v>
461-
</run>
462425
<run task="main">
463426
<v n="scala">2.11.0</v>
464427
<v n="java">1.8</v>

Diff for: compiler/src/main/scala/org/scalajs/core/compiler/CompatComponent.scala

+8-172
Original file line numberDiff line numberDiff line change
@@ -24,70 +24,23 @@ trait CompatComponent {
2424

2525
import global._
2626

27-
// unexpandedName replaces originalName
28-
2927
implicit final class SymbolCompat(self: Symbol) {
30-
def unexpandedName: Name = self.originalName
31-
def originalName: Name = infiniteLoop()
32-
3328
def originalOwner: Symbol =
3429
global.originalOwner.getOrElse(self, self.rawowner)
3530

36-
def isPrivateThis: Boolean = self.hasAllFlags(PRIVATE | LOCAL)
37-
def isLocalToBlock: Boolean = self.isLocal
38-
3931
def implClass: Symbol = NoSymbol
4032

4133
def isTraitOrInterface: Boolean = self.isTrait || self.isInterface
42-
43-
def tpe_* : Type = self.tpe // scalastyle:ignore
44-
}
45-
46-
// enteringPhase/exitingPhase replace beforePhase/afterPhase
47-
48-
@inline final def enteringPhase[T](ph: Phase)(op: => T): T = {
49-
global.enteringPhase(ph)(op)
50-
}
51-
52-
@inline final def exitingPhase[T](ph: Phase)(op: => T): T = {
53-
global.exitingPhase(ph)(op)
5434
}
5535

5636
implicit final class GlobalCompat(
5737
self: CompatComponent.this.global.type) {
5838

59-
def enteringPhase[T](ph: Phase)(op: => T): T = self.beforePhase(ph)(op)
60-
def beforePhase[T](ph: Phase)(op: => T): T = infiniteLoop()
61-
62-
def exitingPhase[T](ph: Phase)(op: => T): T = self.afterPhase(ph)(op)
63-
def afterPhase[T](ph: Phase)(op: => T): T = infiniteLoop()
64-
65-
def delambdafy: DelambdafyCompat.type = DelambdafyCompat
66-
67-
// Copied from internal/Trees.scala
68-
def NewFromConstructor(constructor: Symbol, args: Tree*): Apply = {
69-
assert(constructor.isConstructor, constructor)
70-
val instance = New(TypeTree(constructor.owner.tpe))
71-
val init = Select(instance, nme.CONSTRUCTOR).setSymbol(constructor)
72-
Apply(init, args.toList)
73-
}
74-
7539
object originalOwner {
7640
def getOrElse(sym: Symbol, orElse: => Symbol): Symbol = infiniteLoop()
7741
}
7842
}
7943

80-
object DelambdafyCompat {
81-
object FreeVarTraverser {
82-
def freeVarsOf(function: Function): mutable.LinkedHashSet[Symbol] = {
83-
throw new AssertionError(
84-
"FreeVarTraverser should not be called on 2.10")
85-
}
86-
}
87-
}
88-
89-
// Impl classes disappeared in 2.12.0-M4
90-
9144
lazy val scalaUsesImplClasses: Boolean =
9245
definitions.SeqClass.implClass != NoSymbol // a trait we know has an impl class
9346

@@ -106,10 +59,7 @@ trait CompatComponent {
10659
// SAMFunction was introduced in 2.12.0-M4 for LMF-capable SAM types
10760

10861
object SAMFunctionAttachCompatDef {
109-
/* Should extend PlainAttachment, but it does not exist in 2.10, and we
110-
* do not actually need this relationship.
111-
*/
112-
case class SAMFunction(samTp: Type, sam: Symbol)
62+
case class SAMFunction(samTp: Type, sam: Symbol) extends PlainAttachment
11363
}
11464

11565
object SAMFunctionAttachCompat {
@@ -129,13 +79,12 @@ trait CompatComponent {
12979
/* global.genBCode.bTypes.initializeCoreBTypes()
13080
*
13181
* This one has a very particular history:
132-
* - in 2.10.x, no genBCode in global
133-
* - in 2.11.{0-1}, there is genBCode but it has no bTypes member
82+
* - in 2.11.{0-1}, genBCode does not have a bTypes member
13483
* - In 2.11.{2-5}, there is genBCode.bTypes, but it has no
13584
* initializeCoreBTypes (it was actually typo'ed as intializeCoreBTypes!)
13685
* - In 2.11.6+, including 2.12, we finally have
13786
* genBCode.bTypes.initializeCoreBTypes
138-
* - As of 2.12.0-M4, it is mandatory to call that method from GenJSCode.run()
87+
* - Since 2.12.0-M4, it is mandatory to call that method from GenJSCode.run()
13988
*/
14089

14190
object LowPrioGenBCodeCompat {
@@ -147,139 +96,26 @@ trait CompatComponent {
14796
}
14897

14998
def initializeCoreBTypesCompat(): Unit = {
150-
import LowPrioGenBCodeCompat._
99+
import LowPrioGenBCodeCompat.genBCode._
151100

152101
{
153-
import global._
102+
import genBCode._
154103

155-
import LowPrioGenBCodeCompat.genBCode._
104+
import LowPrioGenBCodeCompat.genBCode.bTypes._
156105

157106
{
158-
import genBCode._
107+
import bTypes._
159108

160-
import LowPrioGenBCodeCompat.genBCode.bTypes._
161-
162-
{
163-
import bTypes._
164-
165-
initializeCoreBTypes()
166-
}
109+
initializeCoreBTypes()
167110
}
168111
}
169112
}
170-
171-
// Compat to support: new overridingPairs.Cursor(sym).iterator
172-
173-
implicit class OverridingPairsCursor2Iterable(cursor: overridingPairs.Cursor) {
174-
def iterator: Iterator[SymbolPair] = new Iterator[SymbolPair] {
175-
skipIgnoredEntries()
176-
177-
def hasNext: Boolean = cursor.hasNext
178-
179-
def next(): SymbolPair = {
180-
val symbolPair = new SymbolPair(cursor.overriding, cursor.overridden)
181-
cursor.next()
182-
skipIgnoredEntries()
183-
symbolPair
184-
}
185-
186-
private def skipIgnoredEntries(): Unit = {
187-
while (cursor.hasNext && ignoreNextEntry)
188-
cursor.next()
189-
}
190-
191-
/** In 2.10 the overridingPairs.Cursor returns some false positives
192-
* on overriding members. The known false positives are always trying to
193-
* override the `isInstanceOf` method.
194-
*/
195-
private def ignoreNextEntry: Boolean =
196-
cursor.overriding.name == nme.isInstanceOf_
197-
}
198-
199-
class SymbolPair(val low: Symbol, val high: Symbol)
200-
201-
/** To make this compat code compile in 2.11 as the fields `overriding` and
202-
* `overridden` are only present in 2.10.
203-
*/
204-
private implicit class Cursor210toCursor211(cursor: overridingPairs.Cursor) {
205-
def overriding: Symbol = infiniteLoop()
206-
def overridden: Symbol = infiniteLoop()
207-
}
208-
}
209-
210-
// ErasedValueType has a different encoding
211-
212-
implicit final class ErasedValueTypeCompat(self: global.ErasedValueType) {
213-
def valueClazz: Symbol = self.original.typeSymbol
214-
def erasedUnderlying: Type =
215-
enteringPhase(currentRun.erasurePhase)(
216-
erasure.erasedValueClassArg(self.original))
217-
def original: TypeRef = infiniteLoop()
218-
}
219-
220-
// Definitions
221-
222-
@inline final def repeatedToSingle(t: Type): Type =
223-
global.definitions.repeatedToSingle(t)
224-
225-
final def isFunctionSymbol(sym: Symbol): Boolean =
226-
global.definitions.isFunctionSymbol(sym)
227-
228-
private implicit final class DefinitionsCompat(
229-
self: CompatComponent.this.global.definitions.type) {
230-
231-
def repeatedToSingle(t: Type): Type = t match {
232-
case TypeRef(_, self.RepeatedParamClass, arg :: Nil) => arg
233-
case _ => t
234-
}
235-
236-
def isFunctionSymbol(sym: Symbol): Boolean =
237-
definitions.FunctionClass.seq.contains(definitions.unspecializedSymbol(sym))
238-
239-
}
240-
241-
// run.runDefinitions bundles methods and state related to the run
242-
// that were previously in definitions itself
243-
244-
implicit final class RunCompat(self: Run) {
245-
val runDefinitions: CompatComponent.this.global.definitions.type =
246-
global.definitions
247-
}
248-
249-
// Mode.FUNmode replaces analyzer.FUNmode
250-
251-
object Mode {
252-
import CompatComponent.AnalyzerCompat
253-
// No type ascription! Type is different in 2.10 / 2.11
254-
val FUNmode = analyzer.FUNmode
255-
}
256113
}
257114

258115
object CompatComponent {
259-
private object LowPriorityMode {
260-
object Mode {
261-
def FUNmode: Nothing = infiniteLoop()
262-
}
263-
}
264-
265-
private implicit final class AnalyzerCompat(self: scala.tools.nsc.typechecker.Analyzer) {
266-
def FUNmode = { // scalastyle:ignore
267-
import CompatComponent.LowPriorityMode._
268-
{
269-
import scala.reflect.internal._
270-
Mode.FUNmode
271-
}
272-
}
273-
}
274-
275116
private def infiniteLoop(): Nothing =
276117
throw new AssertionError("Infinite loop in Compat")
277118

278119
private def noImplClasses(): Nothing =
279120
throw new AssertionError("No impl classes in this version")
280121
}
281-
282-
trait PluginComponentCompat extends CompatComponent {
283-
// Starting 2.11.x, we need to override the default description.
284-
def description: String
285-
}

0 commit comments

Comments
 (0)