aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-21 23:44:32 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-21 23:44:32 +0100
commite38813ac1362a1d528dfa1ee79f0f8b0d6f7ccb8 (patch)
treed8c2e1a9b2c1b86373f1ae125af617578ab8696f /src/dotty/tools/dotc/core/Types.scala
parented6d9327c5efc70db59d5fd90612e4a5a58cff8c (diff)
downloaddotty-e38813ac1362a1d528dfa1ee79f0f8b0d6f7ccb8.tar.gz
dotty-e38813ac1362a1d528dfa1ee79f0f8b0d6f7ccb8.tar.bz2
dotty-e38813ac1362a1d528dfa1ee79f0f8b0d6f7ccb8.zip
Consolidation of TyperState and Constraint
Removing undetVars and instTypes as separately assignable fields. This is better for maintaining invariants by design.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 1b880b86f..f530ff986 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1998,18 +1998,11 @@ object Types {
*/
private[core] var owningState = creatorState
- assert(!(creatorState.undetVars contains this))
- creatorState.undetVars += this
-
/** The instance type of this variable, or NoType if the variable is currently
* uninstantiated
*/
def instanceOpt(implicit ctx: Context): Type =
- if (inst.exists) inst
- else {
- val i = ctx.typerState.instType(this)
- if (i == null) NoType else i
- }
+ if (inst.exists) inst else ctx.typerState.instType(this)
/** Is the variable already instantiated? */
def isInstantiated(implicit ctx: Context) = instanceOpt.exists
@@ -2018,10 +2011,9 @@ object Types {
def instantiateWith(tp: Type)(implicit ctx: Context): Type = {
assert(tp ne this)
println(s"instantiating ${this.show} with ${tp.show}") // !!!DEBUG
- assert(ctx.typerState.undetVars contains this)
- ctx.typerState.undetVars -= this
+ assert(ctx.typerState.constraint contains this) // !!! DEBUG
if (ctx.typerState eq owningState) inst = tp
- else ctx.typerState.instType = ctx.typerState.instType.updated(this, tp)
+ ctx.typerState.constraint = ctx.typerState.constraint.replace(origin, tp)
tp
}
@@ -2041,7 +2033,7 @@ object Types {
case _ => false
}
ctx.typerState.withCheckingDisabled {
- var inst = ctx.typeComparer.approximate(origin, fromBelow)
+ var inst = ctx.typeComparer.approximation(origin, fromBelow)
if (fromBelow && isSingleton(inst) && !isSingleton(upperBound))
inst = inst.widen
instantiateWith(inst.simplified)