Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d8cd2bb
Convert to using clauses
odersky Jul 9, 2020
717bce7
Convert Symbols to using clauses
odersky Jul 8, 2020
7330e7f
Convert Denotations to using clauses
odersky Jul 8, 2020
86ae3ca
Remove implicit definitions of `ctx` that are not parameters
odersky Jul 9, 2020
1d8cb7c
Change Printers to givens
odersky Jul 9, 2020
9d52399
Change Printers to givens
odersky Jul 9, 2020
d1f2a11
Remove implicit definitions of `ctx` that are not parameters (2)
odersky Jul 9, 2020
017a578
Convert to givens in TypeComparer
odersky Jul 9, 2020
f16fec0
Convert core classes (1)
odersky Jul 9, 2020
0c0d896
Convert core classes (2)
odersky Jul 9, 2020
114e0d2
Convert core classes (3)
odersky Jul 9, 2020
23b19e8
Convert core classes (4)
odersky Jul 9, 2020
50144f4
Convert core classes (5)
odersky Jul 9, 2020
adc75a0
Convert core classes (6)
odersky Jul 9, 2020
a66f8f3
Convert tasty and unpickler classes
odersky Jul 9, 2020
f76b9b6
Convert ast classes
odersky Jul 9, 2020
b935477
Convert config classes
odersky Jul 9, 2020
2ab9a58
Convert parser classes
odersky Jul 9, 2020
e71a167
Convert interactive classes
odersky Jul 9, 2020
f5c30a9
Convert reporting classes
odersky Jul 9, 2020
1ae90ec
Convert transform classes (1)
odersky Jul 9, 2020
7366f5c
Convert transform classes (2)
odersky Jul 9, 2020
1798e29
Convert transform classes (3)
odersky Jul 9, 2020
ce9aa2d
Convert transform classes (4)
odersky Jul 9, 2020
edb4869
Convert other dotc classes (1)
odersky Jul 9, 2020
68e1fea
Convert other dotc classes (2)
odersky Jul 9, 2020
4dc0b9b
Fixes
odersky Jul 10, 2020
d84abfe
Convert tools classes
odersky Jul 9, 2020
682ef6a
Convert repl classes
odersky Jul 10, 2020
6e54aed
Convert test classes (1)
odersky Jul 10, 2020
f71a4b3
Convert test classes (2)
odersky Jul 10, 2020
b76d2e4
Make Contexts.ctx an inline function
odersky Jul 10, 2020
a9c405f
Omit redundant (using ctx)
odersky Jul 10, 2020
f3e03fc
Move atPhase and friends to Contexts
odersky Jul 10, 2020
0ece69a
Use atPhase instead of inContext where possible
odersky Jul 10, 2020
da6829b
Rename Context#phases -> Phases.curPhases
odersky Jul 10, 2020
cd9f05d
Move individual phases to Phases
odersky Jul 10, 2020
165b7d8
Use atPhase instead of passing ctx.withPhase
odersky Jul 10, 2020
5442a4f
Use atPhase for ContextFunctionResults
odersky Jul 10, 2020
1236d8c
Convert remaining instance to atPhase
odersky Jul 10, 2020
159486a
Move plugins to ContextBase
odersky Jul 10, 2020
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
Next Next commit
Convert to using clauses
  • Loading branch information
odersky committed Jul 9, 2020
commit d8cd2bbc777a2cfe9d06f35327c76ea0154f1799
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ object Contexts {
*/
abstract class Context(val base: ContextBase)
extends Periods
with Substituters
with Phases
with Printers
with Symbols
Expand Down
42 changes: 21 additions & 21 deletions compiler/src/dotty/tools/dotc/core/Substituters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Types._, Symbols._, Contexts._
/** Substitution operations on types. See the corresponding `subst` and
* `substThis` methods on class Type for an explanation.
*/
trait Substituters { this: Context =>
object Substituters:

final def subst(tp: Type, from: BindingType, to: BindingType, theMap: SubstBindingMap): Type =
final def subst(tp: Type, from: BindingType, to: BindingType, theMap: SubstBindingMap)(using Context): Type =
tp match {
case tp: BoundType =>
if (tp.binder eq from) tp.copyBoundType(to.asInstanceOf[tp.BT]) else tp
Expand All @@ -21,7 +21,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def subst1(tp: Type, from: Symbol, to: Type, theMap: Subst1Map): Type =
final def subst1(tp: Type, from: Symbol, to: Type, theMap: Subst1Map)(using Context): Type =
tp match {
case tp: NamedType =>
val sym = tp.symbol
Expand All @@ -35,7 +35,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def subst2(tp: Type, from1: Symbol, to1: Type, from2: Symbol, to2: Type, theMap: Subst2Map): Type =
final def subst2(tp: Type, from1: Symbol, to1: Type, from2: Symbol, to2: Type, theMap: Subst2Map)(using Context): Type =
tp match {
case tp: NamedType =>
val sym = tp.symbol
Expand All @@ -50,7 +50,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def subst(tp: Type, from: List[Symbol], to: List[Type], theMap: SubstMap): Type =
final def subst(tp: Type, from: List[Symbol], to: List[Type], theMap: SubstMap)(using Context): Type =
tp match {
case tp: NamedType =>
val sym = tp.symbol
Expand All @@ -70,7 +70,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def substSym(tp: Type, from: List[Symbol], to: List[Symbol], theMap: SubstSymMap): Type =
final def substSym(tp: Type, from: List[Symbol], to: List[Symbol], theMap: SubstSymMap)(using Context): Type =
tp match {
case tp: NamedType =>
val sym = tp.symbol
Expand Down Expand Up @@ -101,7 +101,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def substThis(tp: Type, from: ClassSymbol, to: Type, theMap: SubstThisMap): Type =
final def substThis(tp: Type, from: ClassSymbol, to: Type, theMap: SubstThisMap)(using Context): Type =
tp match {
case tp: ThisType =>
if (tp.cls eq from) to else tp
Expand All @@ -115,7 +115,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def substRecThis(tp: Type, from: Type, to: Type, theMap: SubstRecThisMap): Type =
final def substRecThis(tp: Type, from: Type, to: Type, theMap: SubstRecThisMap)(using Context): Type =
tp match {
case tp @ RecThis(binder) =>
if (binder eq from) to else tp
Expand All @@ -129,7 +129,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def substParam(tp: Type, from: ParamRef, to: Type, theMap: SubstParamMap): Type =
final def substParam(tp: Type, from: ParamRef, to: Type, theMap: SubstParamMap)(using Context): Type =
tp match {
case tp: BoundType =>
if (tp == from) to else tp
Expand All @@ -143,7 +143,7 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final def substParams(tp: Type, from: BindingType, to: List[Type], theMap: SubstParamsMap): Type =
final def substParams(tp: Type, from: BindingType, to: List[Type], theMap: SubstParamsMap)(using Context): Type =
tp match {
case tp: ParamRef =>
if (tp.binder == from) to(tp.paramNum) else tp
Expand All @@ -157,44 +157,44 @@ trait Substituters { this: Context =>
.mapOver(tp)
}

final class SubstBindingMap(from: BindingType, to: BindingType) extends DeepTypeMap {
final class SubstBindingMap(from: BindingType, to: BindingType)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = subst(tp, from, to, this)
}

final class Subst1Map(from: Symbol, to: Type) extends DeepTypeMap {
final class Subst1Map(from: Symbol, to: Type)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = subst1(tp, from, to, this)
}

final class Subst2Map(from1: Symbol, to1: Type, from2: Symbol, to2: Type) extends DeepTypeMap {
final class Subst2Map(from1: Symbol, to1: Type, from2: Symbol, to2: Type)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = subst2(tp, from1, to1, from2, to2, this)
}

final class SubstMap(from: List[Symbol], to: List[Type]) extends DeepTypeMap {
final class SubstMap(from: List[Symbol], to: List[Type])(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = subst(tp, from, to, this)
}

final class SubstSymMap(from: List[Symbol], to: List[Symbol]) extends DeepTypeMap {
final class SubstSymMap(from: List[Symbol], to: List[Symbol])(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = substSym(tp, from, to, this)
}

final class SubstThisMap(from: ClassSymbol, to: Type) extends DeepTypeMap {
final class SubstThisMap(from: ClassSymbol, to: Type)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = substThis(tp, from, to, this)
}

final class SubstRecThisMap(from: Type, to: Type) extends DeepTypeMap {
final class SubstRecThisMap(from: Type, to: Type)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = substRecThis(tp, from, to, this)
}

final class SubstParamMap(from: ParamRef, to: Type) extends DeepTypeMap {
final class SubstParamMap(from: ParamRef, to: Type)(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = substParam(tp, from, to, this)
}

final class SubstParamsMap(from: BindingType, to: List[Type]) extends DeepTypeMap {
final class SubstParamsMap(from: BindingType, to: List[Type])(using Context) extends DeepTypeMap {
def apply(tp: Type): Type = substParams(tp, from, to, this)
}

/** An approximating substitution that can handle wildcards in the `to` list */
final class SubstApproxMap(from: List[Symbol], to: List[Type])(implicit ctx: Context) extends ApproximatingTypeMap {
final class SubstApproxMap(from: List[Symbol], to: List[Type])(using Context) extends ApproximatingTypeMap {
def apply(tp: Type): Type = tp match {
case tp: NamedType =>
val sym = tp.symbol
Expand All @@ -216,4 +216,4 @@ trait Substituters { this: Context =>
mapOver(tp)
}
}
}
end Substituters
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class TypeApplications(val self: Type) extends AnyVal {
case dealiased: TypeBounds =>
dealiased.derivedTypeBounds(dealiased.lo.appliedTo(args), dealiased.hi.appliedTo(args))
case dealiased: LazyRef =>
LazyRef(c => dealiased.ref(c).appliedTo(args)(using c))
LazyRef(c => dealiased.ref(using c).appliedTo(args)(using c))
case dealiased: WildcardType =>
WildcardType(dealiased.optBounds.orElse(TypeBounds.empty).appliedTo(args).bounds)
case dealiased: TypeRef if dealiased.symbol == defn.NothingClass =>
Expand Down
Loading