Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/compiler/scala/reflect/macros/contexts/Aliases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
package scala.reflect.macros
package contexts

import scala.reflect.internal.StdCreators

trait Aliases {
self: Context =>

Expand All @@ -28,14 +30,14 @@ trait Aliases {

override type Expr[+T] = universe.Expr[T]
override val Expr = universe.Expr
def Expr[T: WeakTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, universe.FixedMirrorTreeCreator(mirror, tree))
def Expr[T: WeakTypeTag](tree: Tree): Expr[T] = universe.Expr[T](mirror, StdCreators.FixedMirrorTreeCreator(mirror, tree))

override type WeakTypeTag[T] = universe.WeakTypeTag[T]
override type TypeTag[T] = universe.TypeTag[T]
override val WeakTypeTag = universe.WeakTypeTag
override val TypeTag = universe.TypeTag
def WeakTypeTag[T](tpe: Type): WeakTypeTag[T] = universe.WeakTypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe))
def TypeTag[T](tpe: Type): TypeTag[T] = universe.TypeTag[T](mirror, universe.FixedMirrorTypeCreator(mirror, tpe))
def WeakTypeTag[T](tpe: Type): WeakTypeTag[T] = universe.WeakTypeTag[T](mirror, StdCreators.FixedMirrorTypeCreator(mirror, tpe))
def TypeTag[T](tpe: Type): TypeTag[T] = universe.TypeTag[T](mirror, StdCreators.FixedMirrorTypeCreator(mirror, tpe))
override def weakTypeTag[T](implicit attag: WeakTypeTag[T]) = attag
override def typeTag[T](implicit ttag: TypeTag[T]) = ttag
override def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe
Expand Down
13 changes: 10 additions & 3 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ import scala.tools.nsc.transform.patmat.PatternMatching
import scala.tools.nsc.typechecker._
import scala.tools.nsc.util.ClassPath


class Global(var currentSettings: Settings, reporter0: Reporter)
extends SymbolTable
with Closeable
with CompilationUnits
with Plugins
with PhaseAssembly
with Trees
with Printers
with DocComments
with Positions
with Reporting
with Parsing { self =>
Expand Down Expand Up @@ -200,6 +199,11 @@ class Global(var currentSettings: Settings, reporter0: Reporter)

type SymbolPair = overridingPairs.SymbolPair

object docCommentsComponent extends DocComments {
val self: Global.this.type = Global.this
}
type DocComment = docCommentsComponent.DocComment

// Components for collecting and generating output

import scala.reflect.internal.util.Statistics
Expand Down Expand Up @@ -750,7 +754,10 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
computeInternalPhases() // Global.scala
computePlatformPhases() // backend/Platform.scala
computePluginPhases() // plugins/Plugins.scala
cullPhases(computePhaseAssembly()) // PhaseAssembly.scala
val assembly = new PhaseAssembly {
override val self: Global.this.type = Global.this
}
cullPhases(assembly.computePhaseAssembly(phasesSet)) // PhaseAssembly.scala
}

/* The phase descriptor list. Components that are phase factories. */
Expand Down
7 changes: 4 additions & 3 deletions src/compiler/scala/tools/nsc/PhaseAssembly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ import scala.util.chaining._

/** Sorts the global phasesSet according to SubComponent constraints.
*/
trait PhaseAssembly {
this: Global =>
abstract class PhaseAssembly {
val self: Global
import self._

/** Called by Global#computePhaseDescriptors to compute phase order.
*
* The phases to assemble are provided by `phasesSet`, which must contain
* an `initial` phase. If no phase is `terminal`, then `global.terminal` is added.
*/
def computePhaseAssembly(): List[SubComponent] = {
def computePhaseAssembly(phasesSet: mutable.Set[SubComponent]): List[SubComponent] = {
require(phasesSet.exists(phase => phase.initial || phase.phaseName == DependencyGraph.Parser), "Missing initial phase")
if (!phasesSet.exists(phase => phase.terminal || phase.phaseName == DependencyGraph.Terminal)) {
phasesSet.add(terminal)
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/scala/tools/nsc/ast/DocComments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import scala.tools.nsc.Reporting.WarningCategory
/*
* @author Martin Odersky
*/
trait DocComments { self: Global =>
abstract class DocComments {
val self: Global
import self._

val cookedDocComments = mutable.HashMap[Symbol, String]()

Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Cbuf.StringBuilderOps
trait ScannersCommon {
val global : Global
import global._
import docCommentsComponent._

/** Offset into source character array */
type Offset = Int
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ package classfile
import java.lang.Float.floatToIntBits
import java.lang.Double.doubleToLongBits
import java.util.Arrays.fill

import scala.io.Codec
import scala.reflect.internal.pickling.{PickleBuffer, PickleFormat}
import scala.reflect.internal.pickling.{PickleBuffer, PickleFormat, Translations}
import scala.reflect.internal.util.shortClassOfInstance
import scala.collection.mutable
import PickleFormat._
Expand All @@ -38,6 +37,9 @@ abstract class Pickler extends SubComponent {

val phaseName = "pickler"

private val translations = new Translations { val self: global.type = global }
import translations._

def newPhase(prev: Phase): StdPhase = new PicklePhase(prev)

final def pickle(sym: Symbol, companion: Symbol, noPrivates: Boolean): Pickle = {
Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ trait Infer extends Checkable {
import typeDebug.ptBlock
import typeDebug.str.parentheses
import typingStack.printTyping
import kinds._

/** The formal parameter types corresponding to `formals`.
* If `formals` has a repeated last parameter, a list of
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ abstract class RefChecks extends Transform {

// Variance Checking --------------------------------------------------------

object varianceValidator extends VarianceValidator {
object varianceValidator extends variances.VarianceValidator {
private def tpString(tp: Type) = tp match {
case ClassInfoType(parents, _, clazz) => "supertype "+intersectionType(parents, clazz.owner)
case _ => "type "+tp
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
import global._
import definitions._
import statistics._
import kinds._

final def forArgMode(fun: Tree, mode: Mode) =
if (treeInfo.isSelfOrSuperConstrCall(fun)) mode | SCCmode else mode
Expand All @@ -52,7 +53,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
private val superConstructorCalls: mutable.HashMap[Symbol, collection.Map[Symbol, Symbol]] = perRunCaches.newMap()

// allows override of the behavior of the resetTyper method w.r.t comments
def resetDocComments() = clearDocComments()
def resetDocComments() = docCommentsComponent.clearDocComments()

def resetTyper(): Unit = {
//println("resetTyper called")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ trait TypersTracking {
// Some trees which are typed with mind-numbing frequency and
// which add nothing by being printed. Did () type to Unit? Let's
// gamble on yes.
def printingOk(t: Tree) = printTypings && (settings.isDebug || !noPrint(t))
def printingOk(t: Tree) = printTypings && (settings.isDebug || !typeDebugging.noPrint(t))
def noPrintTyping(t: Tree) = (t.tpe ne null) || !printingOk(t)
def noPrintAdapt(tree1: Tree, tree2: Tree) = !printingOk(tree1) || (
(tree1.tpe == tree2.tpe)
Expand Down
1 change: 1 addition & 0 deletions src/interactive/scala/tools/nsc/interactive/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
with Picklers {

import definitions._
import docCommentsComponent._

if (!settings.Ymacroexpand.isSetByUser)
settings.Ymacroexpand.value = settings.MacroExpand.Discard
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/api/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trait Names {
/** The API of Name instances.
* @group API
*/
abstract class NameApi {
trait NameApi {
/** Checks whether the name is a term name */
def isTermName: Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ trait AnnotationCheckers {
@deprecatedOverriding(
"Create an AnalyzerPlugin and use pluginsTypedReturn. Note: the 'tree' argument here is\n"+
"the 'expr' of a Return tree; 'pluginsTypedReturn' takes the Return tree itself as argument", "2.10.1")
def adaptTypeOfReturn(tree: Tree, pt: Type, default: => Type): Type = default
def adaptTypeOfReturn(tree: Tree, pt: Type, default1: => Type): Type = default1
}

// Syncnote: Annotation checkers inaccessible to reflection, so no sync in var necessary.
Expand Down
49 changes: 0 additions & 49 deletions src/reflect/scala/reflect/internal/CapturedVariables.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import scala.annotation.tailrec
/** The name of this trait defines the eventual intent better than
* it does the initial contents.
*/
trait ExistentialsAndSkolems {
self: SymbolTable =>
abstract class ExistentialsAndSkolems {
val self: SymbolTable
import self._

/** Map a list of type parameter symbols to skolemized symbols, which
* can be deskolemized to the original type parameter. (A skolem is a
Expand Down
5 changes: 3 additions & 2 deletions src/reflect/scala/reflect/internal/Internals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import scala.language.implicitConversions
import scala.reflect.api.Universe
import scala.reflect.macros.Attachments

trait Internals extends api.Internals {
self: SymbolTable =>
abstract class Internals {
val self: SymbolTable
import self.{ treeBuild => _, _}

type Internal = MacroInternalApi
lazy val internal: Internal = new SymbolTableInternal {}
Expand Down
5 changes: 3 additions & 2 deletions src/reflect/scala/reflect/internal/Kinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package internal
import scala.annotation.nowarn
import scala.reflect.internal.util.StringOps.{countAsString, countElementsAsString}

trait Kinds {
self: SymbolTable =>
abstract class Kinds {
val self: SymbolTable
import self._

import definitions._

Expand Down
40 changes: 0 additions & 40 deletions src/reflect/scala/reflect/internal/PrivateWithin.scala

This file was deleted.

4 changes: 3 additions & 1 deletion src/reflect/scala/reflect/internal/ReificationSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ package internal
import Flags._
import util._

trait ReificationSupport { self: SymbolTable =>
abstract class ReificationSupport {
val self: SymbolTable
import self._
import definitions._

class ReificationSupportImpl extends ReificationSupportApi {
Expand Down
8 changes: 3 additions & 5 deletions src/reflect/scala/reflect/internal/StdCreators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ package internal
import scala.reflect.api.{TreeCreator, TypeCreator}
import scala.reflect.api.{Universe => ApiUniverse}

trait StdCreators {
self: SymbolTable =>

case class FixedMirrorTreeCreator(mirror: scala.reflect.api.Mirror[StdCreators.this.type], tree: Tree) extends TreeCreator {
object StdCreators {
case class FixedMirrorTreeCreator(mirror: scala.reflect.api.Mirror[_], tree: SymbolTable#Tree) extends TreeCreator {
def apply[U <: ApiUniverse with Singleton](m: scala.reflect.api.Mirror[U]): U # Tree =
if (m eq mirror) tree.asInstanceOf[U # Tree]
else throw new IllegalArgumentException(s"Expr defined in $mirror cannot be migrated to other mirrors.")
}

case class FixedMirrorTypeCreator(mirror: scala.reflect.api.Mirror[StdCreators.this.type], tpe: Type) extends TypeCreator {
case class FixedMirrorTypeCreator(mirror: scala.reflect.api.Mirror[_], tpe: SymbolTable#Type) extends TypeCreator {
def apply[U <: ApiUniverse with Singleton](m: scala.reflect.api.Mirror[U]): U # Type =
if (m eq mirror) tpe.asInstanceOf[U # Type]
else throw new IllegalArgumentException(s"Type tag defined in $mirror cannot be migrated to other mirrors.")
Expand Down
Loading
Loading