@@ -10,13 +10,15 @@ import scala.collection.mutable
10
10
import scala .reflect .internal .Flags .{LOCAL , PRIVATE }
11
11
import scala .tools .nsc ._
12
12
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.
15
17
*
16
18
* @author Sébastien Doeraene
17
19
*/
18
- trait Compat210Component {
19
- import Compat210Component .{infiniteLoop , noImplClasses }
20
+ trait CompatComponent {
21
+ import CompatComponent .{infiniteLoop , noImplClasses }
20
22
21
23
val global : Global
22
24
@@ -52,7 +54,7 @@ trait Compat210Component {
52
54
}
53
55
54
56
implicit final class GlobalCompat (
55
- self : Compat210Component .this .global.type ) {
57
+ self : CompatComponent .this .global.type ) {
56
58
57
59
def enteringPhase [T ](ph : Phase )(op : => T ): T = self.beforePhase(ph)(op)
58
60
def beforePhase [T ](ph : Phase )(op : => T ): T = infiniteLoop()
@@ -224,7 +226,7 @@ trait Compat210Component {
224
226
global.definitions.isFunctionSymbol(sym)
225
227
226
228
private implicit final class DefinitionsCompat (
227
- self : Compat210Component .this .global.definitions.type ) {
229
+ self : CompatComponent .this .global.definitions.type ) {
228
230
229
231
def repeatedToSingle (t : Type ): Type = t match {
230
232
case TypeRef (_, self.RepeatedParamClass , arg :: Nil ) => arg
@@ -240,20 +242,20 @@ trait Compat210Component {
240
242
// that were previously in definitions itself
241
243
242
244
implicit final class RunCompat (self : Run ) {
243
- val runDefinitions : Compat210Component .this .global.definitions.type =
245
+ val runDefinitions : CompatComponent .this .global.definitions.type =
244
246
global.definitions
245
247
}
246
248
247
249
// Mode.FUNmode replaces analyzer.FUNmode
248
250
249
251
object Mode {
250
- import Compat210Component .AnalyzerCompat
252
+ import CompatComponent .AnalyzerCompat
251
253
// No type ascription! Type is different in 2.10 / 2.11
252
254
val FUNmode = analyzer.FUNmode
253
255
}
254
256
}
255
257
256
- object Compat210Component {
258
+ object CompatComponent {
257
259
private object LowPriorityMode {
258
260
object Mode {
259
261
def FUNmode : Nothing = infiniteLoop()
@@ -262,7 +264,7 @@ object Compat210Component {
262
264
263
265
private implicit final class AnalyzerCompat (self : scala.tools.nsc.typechecker.Analyzer ) {
264
266
def FUNmode = { // scalastyle:ignore
265
- import Compat210Component .LowPriorityMode ._
267
+ import CompatComponent .LowPriorityMode ._
266
268
{
267
269
import scala .reflect .internal ._
268
270
Mode .FUNmode
@@ -277,7 +279,7 @@ object Compat210Component {
277
279
throw new AssertionError (" No impl classes in this version" )
278
280
}
279
281
280
- trait PluginComponent210Compat extends Compat210Component {
282
+ trait PluginComponentCompat extends CompatComponent {
281
283
// Starting 2.11.x, we need to override the default description.
282
284
def description : String
283
285
}
0 commit comments