diff options
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Decorators.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Mode.scala | 85 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/classfile/ClassfileParser.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala | 1 |
13 files changed, 87 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index 2b27b5e01..dc4897233 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -5,7 +5,6 @@ import Symbols._, Types._, util.Positions._, Contexts._, Constants._, ast.tpd._ import config.ScalaVersion import StdNames._ import dotty.tools.dotc.ast.{tpd, untpd} -import dotty.tools.dotc.typer.ProtoTypes.FunProtoTyped object Annotations { diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index fd0cff94e..a0bb03e50 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -18,7 +18,7 @@ import util.Positions._ import ast.Trees._ import ast.untpd import util.{FreshNameCreator, SimpleMap, SourceFile, NoSource} -import typer._ +import typer.{Implicits, ImplicitRunInfo, ImportInfo, NamerContextOps, SearchHistory, TypeAssigner, Typer} import Implicits.ContextualImplicits import config.Settings._ import config.Config diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala index 60c019bce..7d108a459 100644 --- a/src/dotty/tools/dotc/core/Decorators.scala +++ b/src/dotty/tools/dotc/core/Decorators.scala @@ -7,7 +7,6 @@ import Contexts._, Names._, Phases._, printing.Texts._, printing.Printer, printi import util.Positions.Position, util.SourcePosition import collection.mutable.ListBuffer import dotty.tools.dotc.transform.TreeTransforms._ -import typer.Mode import scala.language.implicitConversions /** This object provides useful implicit decorators for types defined elsewhere */ diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index b52c11201..218fb8561 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -18,7 +18,6 @@ import printing.Texts._ import printing.Printer import io.AbstractFile import config.Config -import typer.Mode import util.common._ import collection.mutable.ListBuffer import Decorators.SymbolIteratorDecorator diff --git a/src/dotty/tools/dotc/core/Mode.scala b/src/dotty/tools/dotc/core/Mode.scala new file mode 100644 index 000000000..5b3dbc872 --- /dev/null +++ b/src/dotty/tools/dotc/core/Mode.scala @@ -0,0 +1,85 @@ +package dotty.tools.dotc.core + +/** A collection of mode bits that are part of a context */ +case class Mode(val bits: Int) extends AnyVal { + import Mode._ + def | (that: Mode) = Mode(bits | that.bits) + def & (that: Mode) = Mode(bits & that.bits) + def &~ (that: Mode) = Mode(bits & ~that.bits) + def is (that: Mode) = (bits & that.bits) == that.bits + + def isExpr = (this & PatternOrType) == None + + override def toString = + (0 until 31).filter(i => (bits & (1 << i)) != 0).map(modeName).mkString("Mode(", ",", ")") +} + +object Mode { + val None = Mode(0) + + private val modeName = new Array[String](32) + + def newMode(bit: Int, name: String): Mode = { + modeName(bit) = name + Mode(1 << bit) + } + + val Pattern = newMode(0, "Pattern") + val Type = newMode(1, "Type") + + val ImplicitsEnabled = newMode(2, "ImplicitsEnabled") + val InferringReturnType = newMode(3, "InferringReturnType") + + /** This mode bit is set if we collect information without reference to a valid + * context with typerstate and constraint. This is typically done when we + * cache the eligibility of implicits. Caching needs to be done across different constraints. + * Therefore, if TypevarsMissContext is set, subtyping becomes looser, and assumes + * that PolyParams can be sub- and supertypes of anything. See TypeComparer. + */ + val TypevarsMissContext = newMode(4, "TypevarsMissContext") + val CheckCyclic = newMode(5, "CheckCyclic") + + val InSuperCall = newMode(6, "InSuperCall") + + /** This mode bit is set if we want to allow accessing a symbol's denotation + * at a period before that symbol is first valid. An example where this is + * the case is if we want to examine the environment where an access is made. + * The computation might take place at an earlier phase (e.g. it is part of + * some completion such as unpickling), but the environment might contain + * synbols that are not yet defined in that phase. + * If the mode bit is set, getting the denotation of a symbol at a phase + * before the symbol is defined will return the symbol's denotation at the + * first phase where it is valid, instead of throwing a NotDefinedHere error. + */ + val FutureDefsOK = newMode(7, "FutureDefsOK") + + /** Allow GADTFlexType labelled types to have their bounds adjusted */ + val GADTflexible = newMode(8, "GADTflexible") + + /** Allow dependent functions. This is currently necessary for unpickling, because + * some dependent functions are passed through from the front end(s?), even though they + * are technically speaking illegal. + */ + val AllowDependentFunctions = newMode(9, "AllowDependentFunctions") + + /** We are currently printing something: avoid to produce more logs about + * the printing + */ + val Printing = newMode(10, "Printing") + + /** We are currently typechecking an ident to determine whether some implicit + * is shadowed - don't do any other shadowing tests. + */ + val ImplicitShadowing = newMode(11, "ImplicitShadowing") + + /** We are currently in a `viewExists` check. In that case, ambiguous + * implicits checks are disabled and we succeed with the first implicit + * found. + */ + val ImplicitExploration = newMode(12, "ImplicitExploration") + + /** We are currently unpickling Scala2 info */ + val Scala2Unpickling = newMode(13, "Scala2Unpickling") + + val PatternOrType = Pattern | Type +} diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index a83e7726a..28932b691 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -13,7 +13,6 @@ import Decorators.SymbolIteratorDecorator import ast._ import annotation.tailrec import CheckRealizable._ -import typer.Mode import util.SimpleMap import util.Stats import config.Config diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 8f8a7dbdd..26ffefec4 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -12,7 +12,6 @@ import Names._ import NameOps._ import Flags._ import StdNames.tpnme -import typer.Mode import util.Positions.Position import config.Printers._ import collection.mutable diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 4e7a4a75d..c846737b6 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -3,7 +3,6 @@ package dotc package core import Types._, Contexts._, Symbols._, Flags._, Names._, NameOps._, Denotations._ -import typer.Mode import Decorators._ import StdNames.{nme, tpnme} import collection.mutable diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index 26cac4f72..a7d825131 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -6,7 +6,6 @@ import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators. import Uniques.unique import dotc.transform.ExplicitOuter._ import dotc.transform.ValueClasses._ -import typer.Mode import util.DotClass /** Erased types are: diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 3801f1914..5dfe3a4f1 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -31,7 +31,6 @@ import config.Config import config.Printers._ import annotation.tailrec import Flags.FlagSet -import typer.Mode import language.implicitConversions import scala.util.hashing.{ MurmurHash3 => hashing } @@ -3446,7 +3445,7 @@ object Types { object CyclicReference { def apply(denot: SymDenotation)(implicit ctx: Context): CyclicReference = { val ex = new CyclicReference(denot) - if (!(ctx.mode is typer.Mode.CheckCyclic)) { + if (!(ctx.mode is Mode.CheckCyclic)) { cyclicErrors.println(ex.getMessage) for (elem <- ex.getStackTrace take 200) cyclicErrors.println(elem.toString) diff --git a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 25558a79a..f7a69aa53 100644 --- a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -12,7 +12,6 @@ import scala.collection.{ mutable, immutable } import scala.collection.mutable.{ ListBuffer, ArrayBuffer } import scala.annotation.switch import typer.Checking.checkNonCyclic -import typer.Mode import io.AbstractFile import scala.util.control.NonFatal diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index eb3369184..b547862b4 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -13,7 +13,6 @@ import TastyUnpickler._, TastyBuffer._, PositionPickler._ import scala.annotation.{tailrec, switch} import scala.collection.mutable.ListBuffer import scala.collection.{ mutable, immutable } -import typer.Mode import config.Printers.pickling /** Unpickler for typed trees diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 2831de3e0..e4c8d7d13 100644 --- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -17,7 +17,6 @@ import printing.Printer import io.AbstractFile import util.common._ import typer.Checking.checkNonCyclic -import typer.Mode import PickleBuffer._ import scala.reflect.internal.pickling.PickleFormat._ import Decorators._ |