Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic/modifier lockdown #3

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object Settings {
}
}

case class ArgsSummary(
final case class ArgsSummary(
sstate: SettingsState,
arguments: List[String],
errors: List[String]) {
Expand All @@ -42,7 +42,7 @@ object Settings {
ArgsSummary(sstate, arguments, errors :+ msg)
}

case class Setting[T: ClassTag] private[Settings] (
final case class Setting[T: ClassTag] private[Settings] (
name: String,
description: String,
default: T,
Expand Down
10 changes: 5 additions & 5 deletions src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import Symbols._, Types._, Positions._, Contexts._, Constants._, TypedTrees.tpd.

object Annotations {

abstract class Annotation {
sealed abstract class Annotation {
def tree: Tree
def symbol(implicit ctx: Context): Symbol = tree.tpe.typeSymbol
def matches(cls: Symbol)(implicit ctx: Context): Boolean = symbol.isNonBottomSubClass(cls)
def appliesToModule: Boolean = ???
final def symbol(implicit ctx: Context): Symbol = tree.tpe.typeSymbol
final def matches(cls: Symbol)(implicit ctx: Context): Boolean = symbol.isNonBottomSubClass(cls)
final def appliesToModule: Boolean = ???
}

case class ConcreteAnnotation(val tree: Tree) extends Annotation
final case class ConcreteAnnotation(tree: Tree) extends Annotation

object Annotation {

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Constants {
// For supporting java enumerations inside java annotations (see ClassfileParser)
final val EnumTag = 13

case class Constant(value: Any) {
final case class Constant(value: Any) {
import java.lang.Double.doubleToRawLongBits
import java.lang.Float.floatToRawIntBits

Expand Down
148 changes: 74 additions & 74 deletions src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,74 +35,74 @@ object Contexts {
* of all class fields of type context; allow them only in whitelisted
* classes (which should be short-lived).
*/
abstract class Context extends Periods
with Substituters
with TypeOps
with Printers
with Symbols
with Cloneable {
implicit val ctx: Context = this
sealed abstract class Context extends Periods
with Substituters
with TypeOps
with Printers
with Symbols
with Cloneable {
final implicit val ctx: Context = this

val base: ContextBase

private[this] var _underlying: Context = _
protected def underlying_=(underlying: Context) = _underlying = underlying
def underlying: Context = _underlying
final private[this] var _underlying: Context = _
protected final def underlying_=(underlying: Context) = _underlying = underlying
final def underlying: Context = _underlying

private[this] var _period: Period = _
protected def period_=(period: Period) = _period = period
def period: Period = _period
final private[this] var _period: Period = _
protected final def period_=(period: Period) = _period = period
final def period: Period = _period

private[this] var _constraints: Constraints = _
protected def constraints_=(constraints: Constraints) = _constraints = constraints
def constraints: Constraints = _constraints
final private[this] var _constraints: Constraints = _
protected final def constraints_=(constraints: Constraints) = _constraints = constraints
final def constraints: Constraints = _constraints

private[this] var _typeComparer: TypeComparer = _
protected def typeComparer_=(typeComparer: TypeComparer) = _typeComparer = typeComparer
final private[this] var _typeComparer: TypeComparer = _
protected final def typeComparer_=(typeComparer: TypeComparer) = _typeComparer = typeComparer

def typeComparer: TypeComparer = {
final def typeComparer: TypeComparer = {
if ((_typeComparer eq underlying.typeComparer) &&
(constraints ne underlying.constraints))
_typeComparer = new TypeComparer(this)
_typeComparer
}

private[this] var _position: Position = _
protected def position_=(position: Position) = _position = position
def position: Position = _position
final private[this] var _position: Position = _
protected final def position_=(position: Position) = _position = position
final def position: Position = _position

private[this] var _plainPrinter: Context => Printer = _
protected def plainPrinter_=(plainPrinter: Context => Printer) = _plainPrinter = plainPrinter
def plainPrinter: Context => Printer = _plainPrinter
protected final def plainPrinter_=(plainPrinter: Context => Printer) = _plainPrinter = plainPrinter
final def plainPrinter: Context => Printer = _plainPrinter

private[this] var _refinedPrinter: Context => Printer = _
protected def refinedPrinter_=(refinedPrinter: Context => Printer) = _refinedPrinter = refinedPrinter
def refinedPrinter: Context => Printer = _refinedPrinter
protected final def refinedPrinter_=(refinedPrinter: Context => Printer) = _refinedPrinter = refinedPrinter
final def refinedPrinter: Context => Printer = _refinedPrinter

def printer = if (base.settings.debug.value) plainPrinter else refinedPrinter
final def printer = if (base.settings.debug.value) plainPrinter else refinedPrinter

private[this] var _owner: Symbol = _
protected def owner_=(owner: Symbol) = _owner = owner
def owner: Symbol = _owner
protected final def owner_=(owner: Symbol) = _owner = owner
final def owner: Symbol = _owner

private[this] var _sstate: SettingsState = _
protected def sstate_=(sstate: SettingsState) = _sstate = sstate
def sstate: SettingsState = _sstate

def phase: Phase = ??? // phase(period.phaseId)
def enclClass: Context = ???
def erasedTypes: Boolean = ???
def debug: Boolean = ???
def error(msg: String): Unit = ???
def warning(msg: String): Unit = ???
def log(msg: String): Unit = ???
def debuglog(msg: String): Unit = ???
def inform(msg: String) = ???
def informTime(msg: String, start: Long): Unit = ???
def beforeTyper[T](op: => T): T = ???

private var _condensed: CondensedContext = null
def condensed: CondensedContext = {
protected final def sstate_=(sstate: SettingsState) = _sstate = sstate
final def sstate: SettingsState = _sstate

final def phase: Phase = ??? // phase(period.phaseId)
final def enclClass: Context = ???
final def erasedTypes: Boolean = ???
final def debug: Boolean = ???
final def error(msg: String): Unit = ???
final def warning(msg: String): Unit = ???
final def log(msg: String): Unit = ???
final def debuglog(msg: String): Unit = ???
final def inform(msg: String) = ???
final def informTime(msg: String, start: Long): Unit = ???
final def beforeTyper[T](op: => T): T = ???

private final var _condensed: CondensedContext = null
final def condensed: CondensedContext = {
if (_condensed == null)
_condensed = base.initialCtx.fresh
.withPeriod(period)
Expand All @@ -112,28 +112,28 @@ object Contexts {
_condensed
}

def fresh: FreshContext = {
final def fresh: FreshContext = {
val newctx = super.clone.asInstanceOf[FreshContext]
newctx.underlying = this
newctx._condensed = null
newctx
}
}

abstract class CondensedContext extends Context

abstract class FreshContext extends CondensedContext {
def withPeriod(period: Period): this.type = { this.period = period; this }
def withPhase(pid: PhaseId): this.type = withPeriod(Period(runId, pid))
def withConstraints(constraints: Constraints): this.type = { this.constraints = constraints; this }
def withPlainPrinter(printer: Context => Printer): this.type = { this.plainPrinter = printer; this }
def withRefinedPrinter(printer: Context => Printer): this.type = { this.refinedPrinter = printer; this }
def withOwner(owner: Symbol): this.type = { this.owner = owner; this }
def withSettings(sstate: SettingsState): this.type = { this.sstate = sstate; this }
def withDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this }
sealed abstract class CondensedContext extends Context

sealed abstract class FreshContext extends CondensedContext {
final def withPeriod(period: Period): this.type = { this.period = period; this }
final def withPhase(pid: PhaseId): this.type = withPeriod(Period(runId, pid))
final def withConstraints(constraints: Constraints): this.type = { this.constraints = constraints; this }
final def withPlainPrinter(printer: Context => Printer): this.type = { this.plainPrinter = printer; this }
final def withRefinedPrinter(printer: Context => Printer): this.type = { this.refinedPrinter = printer; this }
final def withOwner(owner: Symbol): this.type = { this.owner = owner; this }
final def withSettings(sstate: SettingsState): this.type = { this.sstate = sstate; this }
final def withDiagnostics(diagnostics: Option[StringBuilder]): this.type = { this.diagnostics = diagnostics; this }
}

private class InitialContext(val base: ContextBase) extends FreshContext {
private final class InitialContext(val base: ContextBase) extends FreshContext {
underlying = NoContext
period = Nowhere
constraints = Map()
Expand All @@ -146,10 +146,10 @@ object Contexts {
lazy val base = unsupported("base")
}

class ContextBase extends ContextState
with Transformers.TransformerBase
with Printers.PrinterBase
with Denotations.DenotationsBase {
final class ContextBase extends ContextState
with Transformers.TransformerBase
with Printers.PrinterBase
with Denotations.DenotationsBase {

val settings = new ScalaSettings

Expand All @@ -167,26 +167,26 @@ object Contexts {
}

/** Mutable state of a context base, collected into a common class */
class ContextState {
abstract class ContextState {

// Symbols state

/** A counter for unique ids */
private[core] var _nextId = 0
private[core] final var _nextId = 0

def nextId = { _nextId += 1; _nextId }
final def nextId = { _nextId += 1; _nextId }

/** A map from a superclass id to the type-ref of the class that has it */
private[core] var classOfId = new Array[TypeRef](InitialSuperIdsSize)
private[core] final var classOfId = new Array[TypeRef](InitialSuperIdsSize)

/** A map from a the type-ref of a superclass to its superclass id */
private[core] val superIdOfClass = new mutable.HashMap[TypeRef, Int]
private[core] final val superIdOfClass = new mutable.HashMap[TypeRef, Int]

/** The last allocate superclass id */
private[core] var lastSuperId = -1
private[core] final var lastSuperId = -1

/** Allocate and return next free superclass id */
private[core] def nextSuperId: Int = {
private[core] final def nextSuperId: Int = {
lastSuperId += 1;
if (lastSuperId >= classOfId.length) {
val tmp = new Array[TypeRef](classOfId.length * 2)
Expand All @@ -197,16 +197,16 @@ object Contexts {
}

// SymDenotations state
private[core] val uniqueBits = new util.HashSet[BitSet]("superbits", 1024)
private[core] final val uniqueBits = new util.HashSet[BitSet]("superbits", 1024)

// Types state
private[core] val uniques = new util.HashSet[Type]("uniques", initialUniquesCapacity) {
private[core] final val uniques = new util.HashSet[Type]("uniques", initialUniquesCapacity) {
override def hash(x: Type): Int = x.hash
}

// TypeOps state
private[core] var volatileRecursions: Int = 0
private[core] val pendingVolatiles = new mutable.HashSet[Type]
private[core] final var volatileRecursions: Int = 0
private[core] final val pendingVolatiles = new mutable.HashSet[Type]
}

object Context {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Definitions {
val MaxFunctionArity, MaxTupleArity = 22
}

class Definitions(implicit ctx: Context) {
final class Definitions(implicit ctx: Context) {
import Definitions._

import ctx.{requiredClass, requiredModule, requiredPackage}
Expand Down
Loading