aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-07-08 11:05:55 +0200
committerMartin Odersky <odersky@gmail.com>2013-07-11 10:07:32 +0200
commitc9679f6c0f3c8200e1b1f537e89488094cfc2576 (patch)
tree59f142f2b241049737bfb71838235a4451d40cc1 /src/dotty/tools/dotc/core/Contexts.scala
parent0af96c0f5179104fca02cf1aa144c6176bdb71eb (diff)
downloaddotty-c9679f6c0f3c8200e1b1f537e89488094cfc2576.tar.gz
dotty-c9679f6c0f3c8200e1b1f537e89488094cfc2576.tar.bz2
dotty-c9679f6c0f3c8200e1b1f537e89488094cfc2576.zip
Added functionality to deal with function applications.
- Added Applications class to represent applications - Added Constraint class to represent type constraints - Added TyperState class to represent typer state - Added Diagnostic class to buffer errors and warnings - Added Inferencing class that contains some common functionality for type inferencing (this one's still rudimentary). - Added extractor for FunctionType in Definitions - Added desugaring of default parameters to default getters in Desugar - Added flags to deal with default parameters - Added substitutions that replace bound parameters
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index e2273738f..b1523144d 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -9,8 +9,11 @@ import Phases._
import Types._
import Symbols._
import Scopes._
-import TypeComparers._, NameOps._, SymDenotations._, util.Positions._
-import ast.Trees._, ast.untpd
+import NameOps._
+import SymDenotations._
+import util.Positions._
+import ast.Trees._
+import ast.untpd
import util.{FreshNameCreator, SimpleMap}
import typer._
import config.Settings._
@@ -83,9 +86,9 @@ object Contexts {
}
/** The current type comparer */
- private[this] var _typeComparer: TypeComparer = _
- protected def typeComparer_=(typeComparer: TypeComparer) = _typeComparer = typeComparer
- def typeComparer: TypeComparer = _typeComparer
+ private[this] var _typerState: TyperState = _
+ protected def typerState_=(typerState: TyperState) = _typerState = typerState
+ def typerState: TyperState = _typerState
/** The current position */
private[this] var _position: Position = _
@@ -149,6 +152,12 @@ object Contexts {
protected def moreProperties_=(moreProperties: Map[String, Any]) = _moreProperties = moreProperties
def moreProperties: Map[String, Any] = _moreProperties
+ private var _typeComparer: TypeComparer = _
+ def typeComparer: TypeComparer = {
+ if (_typeComparer == null || (_typeComparer.ctx ne this))
+ _typeComparer = new TypeComparer()(this)
+ _typeComparer
+ }
/** If -Ydebug is on, the top of the stack trace where this context
* was created, otherwise `null`.
@@ -208,7 +217,7 @@ object Contexts {
if (_condensed eq outer.condensed)
_condensed = base.initialCtx.fresh
.withPeriod(period)
- // typeComparer and its constraints is not preserved in condensed
+ // typerState and its constraint is not preserved in condensed
.withPlainPrinter(plainPrinter)
.withRefinedPrinter(refinedPrinter)
.withOwner(owner)
@@ -242,7 +251,8 @@ object Contexts {
*/
abstract class FreshContext extends CondensedContext {
def withPeriod(period: Period): this.type = { this.period = period; this }
- def withTypeComparer(typeComparer: TypeComparer): this.type = { this.typeComparer = typeComparer; this }
+ def withTyperState(typerState: TyperState): this.type = { this.typerState = typerState; this }
+ def withNewTyperState: this.type = withTyperState(typerState.fresh)
def withPosition(position: Position): this.type = { this.position = position; this }
def withPlainPrinter(printer: Context => Printer): this.type = { this.plainPrinter = printer; this }
def withRefinedPrinter(printer: Context => Printer): this.type = { this.refinedPrinter = printer; this }
@@ -273,7 +283,7 @@ object Contexts {
private class InitialContext(val base: ContextBase, settings: SettingGroup) extends FreshContext {
outer = NoContext
period = InitialPeriod
- typeComparer = new TypeComparer
+ typerState = new TyperState
position = NoPosition
plainPrinter = new PlainPrinter(_)
refinedPrinter = new RefinedPrinter(_)