Skip to content

Don't write (using ctx: Context) #8639

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

Merged
merged 28 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c7d39fa
Don't write `(using ctx: Context)`
odersky Mar 31, 2020
ebea9c2
Rename curCtx -> ctx
odersky Mar 31, 2020
686cdc7
New helper method: withContext
odersky Mar 31, 2020
5eb9000
Drop explicit declarations of `ctx`
odersky Apr 1, 2020
2f7f6ce
Drop more ctx bindings
odersky Apr 1, 2020
9ebde7c
Drop more ctx bindings
odersky Apr 1, 2020
85d5d70
Rename withContext -> inContext
odersky Apr 1, 2020
adeeedd
Fix positions problem when pickling wildcard givens
odersky Apr 2, 2020
6400ffa
Drop more ctx bindings
odersky Apr 2, 2020
1485357
Drop more occurrences
odersky Apr 2, 2020
3083140
Drop more occurrences
odersky Apr 2, 2020
48e939d
Make context closure implicit
odersky Apr 2, 2020
bf975e0
Fix accesibility error message for overloaded references
odersky Apr 2, 2020
a6c5296
Convert implicits to using clauses in TypeAssigner
odersky Apr 2, 2020
6e1e4c9
Switch to (using Context) for Typer
odersky Apr 2, 2020
4de11a4
Switch to (using context) for other files in typer
odersky Apr 2, 2020
16f93a7
Switch to (using Context) in more files in typer
odersky Apr 2, 2020
1d8e99f
Switch to (using Context) in more files in typer
odersky Apr 2, 2020
c2a9682
Switch to (using Context) in more files in typer
odersky Apr 2, 2020
6d38347
Switch to (using Context) in more files in typer
odersky Apr 2, 2020
6e7bcf2
Switch to (using Context) in more files in typer
odersky Apr 2, 2020
889556e
Fix rebase breakage and other tweaks
odersky Apr 3, 2020
65c51a5
Switch to (using Context) in more files in typer
odersky Apr 3, 2020
5678ccc
Switch to (using Context) in Implicits
odersky Apr 3, 2020
970c4a2
Switch to (using Context) in more files in typer
odersky Apr 3, 2020
41fd8b7
Switch to (using Context) in more files in typer
odersky Apr 3, 2020
4b7ef1e
Break out implicit synthesis into separate class
odersky Apr 3, 2020
7641518
Streamline Synthesizer initialization
odersky Apr 4, 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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package backend.jvm
import dotc.ast.Trees.Select
import dotc.ast.tpd._
import dotc.core._
import Contexts.Context
import Contexts.{Context, ctx}
import Names.TermName, StdNames._
import Types.{JavaArrayType, UnspecifiedErrorType, Type}
import Symbols.{Symbol, NoSymbol}
Expand Down Expand Up @@ -49,7 +49,7 @@ class DottyPrimitives(ictx: Context) {
* @param tpe The type of the receiver object. It is used only for array
* operations
*/
def getPrimitive(app: Apply, tpe: Type)(implicit ctx: Context): Int = {
def getPrimitive(app: Apply, tpe: Type)(using Context): Int = {
val fun = app.fun.symbol
val defn = ctx.definitions
val code = app.fun match {
Expand Down Expand Up @@ -130,7 +130,7 @@ class DottyPrimitives(ictx: Context) {
primitives(s) = code
}

def addPrimitives(cls: Symbol, method: TermName, code: Int)(implicit ctx: Context): Unit = {
def addPrimitives(cls: Symbol, method: TermName, code: Int)(using Context): Unit = {
val alts = cls.info.member(method).alternatives.map(_.symbol)
if (alts.isEmpty)
ctx.error(s"Unknown primitive method $cls.$method")
Expand Down
18 changes: 9 additions & 9 deletions compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package dotty.tools
package dotc

import util.{FreshNameCreator, SourceFile}
import core._
import Contexts.{Context, ctx}
import SymDenotations.ClassDenotation
import Symbols._
import util.{FreshNameCreator, SourceFile, NoSource}
import util.Spans.Span
import ast.{tpd, untpd}
import tpd.{Tree, TreeTraverser}
import typer.PrepareInlineable.InlineAccessors
import typer.Nullables
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.SymDenotations.ClassDenotation
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.transform.SymUtils._
import util.{NoSource, SourceFile}
import util.Spans.Span
import core.Decorators._
import transform.SymUtils._
import core.Decorators.{given _}

class CompilationUnit protected (val source: SourceFile) {

Expand Down Expand Up @@ -43,7 +43,7 @@ class CompilationUnit protected (val source: SourceFile) {

var suspended: Boolean = false

def suspend()(using ctx: Context): Nothing =
def suspend()(using Context): Nothing =
if !suspended then
if (ctx.settings.XprintSuspension.value)
ctx.echo(i"suspended: $this")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
.setTyperState(new TyperState(ctx.typerState))
ctx.initialize()(start) // re-initialize the base context with start
def addImport(ctx: Context, rootRef: ImportInfo.RootRef) =
ctx.fresh.setImportInfo(ImportInfo.rootImport(rootRef)(ctx))
ctx.fresh.setImportInfo(ImportInfo.rootImport(rootRef))
defn.RootImportFns.foldLeft(start.setRun(this))(addImport)
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ object desugar {
* <extension> def g[Ts](x: T)(using C)(z: T) = f(z)
*/
def collectiveExtensionBody(stats: List[Tree],
tparams: List[TypeDef], vparamss: List[List[ValDef]])(using ctx: Context): List[Tree] =
tparams: List[TypeDef], vparamss: List[List[ValDef]])(using Context): List[Tree] =
for stat <- stats yield
stat match
case mdef: DefDef =>
Expand Down Expand Up @@ -968,7 +968,7 @@ object desugar {
}

/** Invent a name for an anonympus given or extension of type or template `impl`. */
def inventGivenOrExtensionName(impl: Tree)(using ctx: Context): SimpleName =
def inventGivenOrExtensionName(impl: Tree)(using Context): SimpleName =
val str = impl match
case impl: Template =>
if impl.parents.isEmpty then
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/MainProxies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object MainProxies {
}

import untpd._
def mainProxy(mainFun: Symbol)(using ctx: Context): List[TypeDef] = {
def mainProxy(mainFun: Symbol)(using Context): List[TypeDef] = {
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span
def pos = mainFun.sourcePos
val argsRef = Ident(nme.args)
Expand Down
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/ast/TreeMapWithImplicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TreeMapWithImplicits extends tpd.TreeMap {
case stat: Import => ctx.importContext(stat, stat.symbol)
case _ => ctx
}
val stat1 = transform(stat)(statCtx)
val stat1 = transform(stat)(using statCtx)
if (stat1 ne stat) recur(stats, stat1, rest)(restCtx)
else traverse(rest)(restCtx)
case nil =>
Expand Down Expand Up @@ -81,37 +81,37 @@ class TreeMapWithImplicits extends tpd.TreeMap {
nestedCtx
}

override def transform(tree: Tree)(implicit ctx: Context): Tree = {
override def transform(tree: Tree)(using Context): Tree = {
def localCtx =
if (tree.hasType && tree.symbol.exists) ctx.withOwner(tree.symbol) else ctx
try tree match {
case tree: Block =>
super.transform(tree)(nestedScopeCtx(tree.stats))
super.transform(tree)(using nestedScopeCtx(tree.stats))
case tree: DefDef =>
implicit val ctx = localCtx
given Context = localCtx
cpy.DefDef(tree)(
tree.name,
transformSub(tree.tparams),
tree.vparamss mapConserve (transformSub(_)),
transform(tree.tpt),
transform(tree.rhs)(nestedScopeCtx(tree.vparamss.flatten)))
transform(tree.rhs)(using nestedScopeCtx(tree.vparamss.flatten)))
case EmptyValDef =>
tree
case _: PackageDef | _: MemberDef =>
super.transform(tree)(localCtx)
super.transform(tree)(using localCtx)
case impl @ Template(constr, parents, self, _) =>
cpy.Template(tree)(
transformSub(constr),
transform(parents)(ctx.superCallContext),
transform(parents)(using ctx.superCallContext),
Nil,
transformSelf(self),
transformStats(impl.body, tree.symbol))
case tree: CaseDef =>
val patCtx = patternScopeCtx(tree.pat)(ctx)
val patCtx = patternScopeCtx(tree.pat)(using ctx)
cpy.CaseDef(tree)(
transform(tree.pat),
transform(tree.guard)(patCtx),
transform(tree.body)(patCtx)
transform(tree.guard)(using patCtx),
transform(tree.body)(using patCtx)
)
case _ =>
super.transform(tree)
Expand Down
Loading