Skip to content

Commit e407e10

Browse files
committed
Rename Compat210Component into CompatComponent.
Nowadays, it contains as much compatibility tricks for 2.11/2.12 as for 2.10.
1 parent 512486a commit e407e10

File tree

8 files changed

+20
-18
lines changed

8 files changed

+20
-18
lines changed

compiler/src/main/scala/org/scalajs/core/compiler/Compat210Component.scala renamed to compiler/src/main/scala/org/scalajs/core/compiler/CompatComponent.scala

+13-11
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import scala.collection.mutable
1010
import scala.reflect.internal.Flags.{LOCAL, PRIVATE}
1111
import scala.tools.nsc._
1212

13-
/** Hacks to have our source code compatible with 2.10 and 2.11.
14-
* It exposes 2.11 API in a 2.10 compiler.
13+
/** Hacks to have our source code compatible with the compiler internals of all
14+
* the versions of Scala that we support.
15+
*
16+
* In general, it tries to provide the newer APIs on top of older APIs.
1517
*
1618
* @author Sébastien Doeraene
1719
*/
18-
trait Compat210Component {
19-
import Compat210Component.{infiniteLoop, noImplClasses}
20+
trait CompatComponent {
21+
import CompatComponent.{infiniteLoop, noImplClasses}
2022

2123
val global: Global
2224

@@ -52,7 +54,7 @@ trait Compat210Component {
5254
}
5355

5456
implicit final class GlobalCompat(
55-
self: Compat210Component.this.global.type) {
57+
self: CompatComponent.this.global.type) {
5658

5759
def enteringPhase[T](ph: Phase)(op: => T): T = self.beforePhase(ph)(op)
5860
def beforePhase[T](ph: Phase)(op: => T): T = infiniteLoop()
@@ -224,7 +226,7 @@ trait Compat210Component {
224226
global.definitions.isFunctionSymbol(sym)
225227

226228
private implicit final class DefinitionsCompat(
227-
self: Compat210Component.this.global.definitions.type) {
229+
self: CompatComponent.this.global.definitions.type) {
228230

229231
def repeatedToSingle(t: Type): Type = t match {
230232
case TypeRef(_, self.RepeatedParamClass, arg :: Nil) => arg
@@ -240,20 +242,20 @@ trait Compat210Component {
240242
// that were previously in definitions itself
241243

242244
implicit final class RunCompat(self: Run) {
243-
val runDefinitions: Compat210Component.this.global.definitions.type =
245+
val runDefinitions: CompatComponent.this.global.definitions.type =
244246
global.definitions
245247
}
246248

247249
// Mode.FUNmode replaces analyzer.FUNmode
248250

249251
object Mode {
250-
import Compat210Component.AnalyzerCompat
252+
import CompatComponent.AnalyzerCompat
251253
// No type ascription! Type is different in 2.10 / 2.11
252254
val FUNmode = analyzer.FUNmode
253255
}
254256
}
255257

256-
object Compat210Component {
258+
object CompatComponent {
257259
private object LowPriorityMode {
258260
object Mode {
259261
def FUNmode: Nothing = infiniteLoop()
@@ -262,7 +264,7 @@ object Compat210Component {
262264

263265
private implicit final class AnalyzerCompat(self: scala.tools.nsc.typechecker.Analyzer) {
264266
def FUNmode = { // scalastyle:ignore
265-
import Compat210Component.LowPriorityMode._
267+
import CompatComponent.LowPriorityMode._
266268
{
267269
import scala.reflect.internal._
268270
Mode.FUNmode
@@ -277,7 +279,7 @@ object Compat210Component {
277279
throw new AssertionError("No impl classes in this version")
278280
}
279281

280-
trait PluginComponent210Compat extends Compat210Component {
282+
trait PluginComponentCompat extends CompatComponent {
281283
// Starting 2.11.x, we need to override the default description.
282284
def description: String
283285
}

compiler/src/main/scala/org/scalajs/core/compiler/ExplicitInnerJS.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import scala.collection.mutable
4848
*/
4949
abstract class ExplicitInnerJS
5050
extends plugins.PluginComponent with InfoTransform with TypingTransformers
51-
with PluginComponent210Compat {
51+
with PluginComponentCompat {
5252

5353
val jsAddons: JSGlobalAddons {
5454
val global: ExplicitInnerJS.this.global.type

compiler/src/main/scala/org/scalajs/core/compiler/ExplicitLocalJS.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ import scala.collection.mutable
111111
*/
112112
abstract class ExplicitLocalJS
113113
extends plugins.PluginComponent with Transform with TypingTransformers
114-
with PluginComponent210Compat {
114+
with PluginComponentCompat {
115115

116116
val jsAddons: JSGlobalAddons {
117117
val global: ExplicitLocalJS.this.global.type

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class GenJSCode extends plugins.PluginComponent
3333
with JSEncoding
3434
with GenJSExports
3535
with GenJSFiles
36-
with PluginComponent210Compat {
36+
with PluginComponentCompat {
3737

3838
val jsAddons: JSGlobalAddons {
3939
val global: GenJSCode.this.global.type

compiler/src/main/scala/org/scalajs/core/compiler/JSGlobalAddons.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.scalajs.core.ir.Trees.JSNativeLoadSpec
1616
* @author Sébastien Doeraene
1717
*/
1818
trait JSGlobalAddons extends JSDefinitions
19-
with Compat210Component {
19+
with CompatComponent {
2020
val global: Global
2121

2222
import global._

compiler/src/main/scala/org/scalajs/core/compiler/PreTyperComponent.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import nsc._
6161
* @author Nicolas Stucki
6262
*/
6363
abstract class PreTyperComponent extends plugins.PluginComponent
64-
with transform.Transform with PluginComponent210Compat {
64+
with transform.Transform with PluginComponentCompat {
6565

6666
import global._
6767

compiler/src/main/scala/org/scalajs/core/compiler/PrepJSInterop.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import org.scalajs.core.ir.Trees.{isValidIdentifier, JSNativeLoadSpec}
2828
abstract class PrepJSInterop extends plugins.PluginComponent
2929
with PrepJSExports
3030
with transform.Transform
31-
with PluginComponent210Compat {
31+
with PluginComponentCompat {
3232
import PrepJSInterop._
3333

3434
val jsAddons: JSGlobalAddons {

compiler/src/main/scala/org/scalajs/core/compiler/ScalaJSPlugin.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ScalaJSPlugin(val global: Global) extends NscPlugin {
3939
/** Addons for JavaScript platform */
4040
object jsAddons extends {
4141
val global: ScalaJSPlugin.this.global.type = ScalaJSPlugin.this.global
42-
} with JSGlobalAddons with Compat210Component
42+
} with JSGlobalAddons with CompatComponent
4343

4444
object scalaJSOpts extends ScalaJSOptions {
4545
import ScalaJSOptions.URIMap

0 commit comments

Comments
 (0)