Skip to content

Commit

Permalink
Simplify context handling
Browse files Browse the repository at this point in the history
 - Use only wildcard imports from Contexts
 - Use `(using Context)` throughout
  • Loading branch information
odersky committed Jul 16, 2020
1 parent 68ed6bf commit a59a2f5
Show file tree
Hide file tree
Showing 110 changed files with 554 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.transform.Erasure
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.util.Spans._
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.report

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.ast.Trees
import dotty.tools.dotc.core.Annotations._
import dotty.tools.dotc.core.Constants._
import dotty.tools.dotc.core.Contexts.{Context, atPhase}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Decorators._
import dotty.tools.dotc.core.Flags._
Expand Down Expand Up @@ -927,7 +927,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
throw new RuntimeException(msg)
}

private def compilingArray(using ctx: Context) =
private def compilingArray(using Context) =
ctx.compilationUnit.source.file.name == "Array.scala"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.collection.mutable
import scala.collection.generic.Clearable

import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.Contexts.{inContext, atPhase}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Phases.Phase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools.backend.jvm

import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Phases._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Flags.Trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ object DottyBackendInterface {
* True if the current compilation unit is of a primitive class (scala.Boolean et al).
* Used only in assertions.
*/
def isCompilingPrimitive(using ctx: Context) = {
def isCompilingPrimitive(using Context) = {
primitiveCompilationUnits(ctx.compilationUnit.source.file.name)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object GenBCode {
val name: String = "genBCode"
}

class GenBCodePipeline(val int: DottyBackendInterface)(using ctx: Context) extends BCodeSyncAndTry {
class GenBCodePipeline(val int: DottyBackendInterface)(using Context) extends BCodeSyncAndTry {
import DottyBackendInterface.symExtensions

private var tree: Tree = _
Expand Down
2 changes: 1 addition & 1 deletion 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, ctx}
import Contexts._
import Names.TermName, StdNames._
import Types.{JavaArrayType, UnspecifiedErrorType, Type}
import Symbols.{Symbol, NoSymbol}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Bench.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools
package dotc

import core.Contexts.{Context, ctx}
import core.Contexts._
import reporting.Reporter

import scala.annotation.internal.sharable
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc

import core._
import Contexts.{Context, ctx}
import Contexts._
import SymDenotations.ClassDenotation
import Symbols._
import util.{FreshNameCreator, SourceFile, NoSource}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.nio.file.{Files, Paths}
import dotty.tools.FatalError
import config.CompilerCommand
import core.Comments.{ContextDoc, ContextDocstrings}
import core.Contexts.{Context, ContextBase, inContext, ctx}
import core.Contexts._
import core.{MacroClassLoader, Mode, TypeError}
import core.StdNames.nme
import dotty.tools.dotc.ast.Positioned
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Resident.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools
package dotc

import core.Contexts.{Context, ctx, inContext}
import core.Contexts._
import reporting.Reporter
import java.io.EOFException
import scala.annotation.tailrec
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/NavigateAST.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools.dotc
package ast

import core.Contexts.{Context, ctx}
import core.Contexts._
import core.Decorators._
import util.Spans._
import Trees.{MemberDef, DefTree, WithLazyField}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Positioned.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package ast

import util.Spans._
import util.{SourceFile, NoSource, SourcePosition}
import core.Contexts.{Context, ctx}
import core.Contexts._
import core.Decorators._
import core.Flags.{JavaDefined, Extension}
import core.StdNames.nme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package dotty.tools.dotc.classpath
import dotty.tools.io.{AbstractFile, VirtualDirectory}
import FileUtils.AbstractFileOps
import dotty.tools.io.ClassPath
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._

/**
* Provides factory methods for classpath. When creating classpath instances for a given path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.nio.file.attribute.{BasicFileAttributes, FileTime}

import scala.annotation.tailrec
import dotty.tools.io.{AbstractFile, ClassPath, ClassRepresentation, FileZipArchive, ManifestResources}
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import FileUtils._

/**
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools.dotc
package config

import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.io.{ Directory, PlainDirectory, AbstractFile }
import PathResolver.Defaults
import rewrites.Rewrites
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package config

import core.Contexts.{Context, ctx}
import core.Contexts._
import core.Names.TermName
import core.StdNames.nme
import core.Decorators.{given _}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/GadtConstraint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ final class ProperGadtConstraint private(

// ---- Protected/internal -----------------------------------------------

override def comparerCtx(using ctx: Context): Context = ctx
override def comparerCtx(using Context): Context = ctx

override protected def constraint = myConstraint
override protected def constraint_=(c: Constraint) = myConstraint = c
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/JavaNullInterop.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.dotc.core

import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Flags.JavaDefined
import dotty.tools.dotc.core.StdNames.{jnme, nme}
import dotty.tools.dotc.core.Symbols._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/NameKinds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Names._
import NameOps._
import StdNames._
import NameTags._
import Contexts.{Context, ctx}
import Contexts._
import collection.mutable

import scala.annotation.internal.sharable
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/NullOpsDecorator.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.dotc.core

import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Symbols.defn
import dotty.tools.dotc.core.Types._

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/ParamInfo.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools.dotc.core

import Names.Name
import Contexts.{Context, ctx}
import Contexts._
import Types.Type
import Variances.{Variance, varianceToInt}

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ object SymDenotations {
* Makes use of `rawParamss` when present, or constructs fresh parameter symbols otherwise.
* This method can be allocation-heavy.
*/
final def paramSymss(using ctx: Context): List[List[Symbol]] =
final def paramSymss(using Context): List[List[Symbol]] =

def recurWithParamss(info: Type, paramss: List[List[Symbol]]): List[List[Symbol]] =
info match
Expand Down Expand Up @@ -1446,7 +1446,7 @@ object SymDenotations {
privateWithin: Symbol = null,
annotations: List[Annotation] = null,
rawParamss: List[List[Symbol]] = null)(
using ctx: Context): SymDenotation = {
using Context): SymDenotation = {
// simulate default parameters, while also passing implicit context ctx to the default values
val initFlags1 = (if (initFlags != UndefinedFlags) initFlags else this.flags)
val info1 = if (info != null) info else this.info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc.core.tasty

import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.core.Comments.{Comment, CommentsContext, ContextDocstrings}
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._

import dotty.tools.tasty.TastyBuffer
import TastyBuffer.{Addr, NoAddr}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package fromtasty
import java.nio.file.{Files, Path, Paths}
import java.io

import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.NameKinds
import dotty.tools.dotc.core.Names.SimpleName
import dotty.tools.dotc.core.StdNames.nme
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.nio.charset.Charset
import dotty.tools.dotc.ast.Trees._
import dotty.tools.dotc.ast.untpd
import dotty.tools.dotc.config.Printers.interactiv
import dotty.tools.dotc.core.Contexts.{Context, NoContext, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.CheckRealizable
import dotty.tools.dotc.core.Decorators.StringInterpolators
import dotty.tools.dotc.core.Denotations.SingleDenotation
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/printing/Highlighting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotc
package printing

import scala.collection.mutable
import core.Contexts.{Context, ctx}
import core.Contexts._

object Highlighting {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotc
package printing

import core._
import Contexts.{Context, ctx}
import Contexts._
import util.Property
import Texts.Text

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Names._
import Symbols._
import NameOps._
import TypeErasure.ErasedValueType
import Contexts.{Context, ctx}
import Contexts._
import Annotations.Annotation
import Denotations._
import SymDenotations._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc
package printing

import dotty.tools.dotc.ast.untpd
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.StdNames._
import dotty.tools.dotc.parsing.Parsers.Parser
import dotty.tools.dotc.parsing.Scanners.Scanner
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/profile/AsyncHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.concurrent._
import java.util.concurrent.atomic.AtomicInteger

import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._

sealed trait AsyncHelper {

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.management.openmbean.CompositeData
import javax.management.{Notification, NotificationEmitter, NotificationListener}

import dotty.tools.dotc.core.Phases.Phase
import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.io.AbstractFile

object Profiler {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.dotc.quoted

import dotty.tools.dotc.core.Contexts.{Context, ctx}
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.tastyreflect.ReflectionImpl

object QuoteContext {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotc
package reporting

import util.SourcePosition
import core.Contexts.{Context, ctx}
import core.Contexts._
import config.Settings.Setting
import interfaces.Diagnostic.{ERROR, INFO, WARNING}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package reporting

import core.Contexts.{Context, ctx}
import core.Contexts._

/**
* This trait implements `isHidden` so that we avoid reporting non-sensical messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package reporting

import java.lang.System.{lineSeparator => EOL}

import core.Contexts.{Context, ctx}
import core.Contexts._
import core.Decorators._
import printing.Highlighting.{Blue, Red, Yellow}
import printing.SyntaxHighlighting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package reporting

import core.Contexts.{Context, ctx}
import core.Contexts._
import collection.mutable
import config.Printers.typr
import Diagnostic._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package reporting

import core.Contexts.{Context, ctx}
import core.Contexts._
import Diagnostic.Error

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package reporting

import scala.collection.mutable
import util.SourceFile
import core.Contexts.{Context, ctx}
import core.Contexts._

/** This trait implements `isHidden` so that multiple messages per position
* are suppressed, unless they are of increasing severity. */
Expand Down
Loading

0 comments on commit a59a2f5

Please sign in to comment.