aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-01-06 12:18:04 +0100
committerMartin Odersky <odersky@gmail.com>2013-01-06 12:19:07 +0100
commitcd0ed1676ac5529b0c04995b9a26f8e165cad4cf (patch)
tree9305347b1f12f315953e93c8b598b93c9dd358aa /src
parenta42900db82a35e612779a8d4ca685a9fa76cc92d (diff)
downloaddotty-cd0ed1676ac5529b0c04995b9a26f8e165cad4cf.tar.gz
dotty-cd0ed1676ac5529b0c04995b9a26f8e165cad4cf.tar.bz2
dotty-cd0ed1676ac5529b0c04995b9a26f8e165cad4cf.zip
Renamed class for SubTypers and added to Context
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala9
-rw-r--r--src/dotty/tools/dotc/core/SubTypers.scala (renamed from src/dotty/tools/dotc/core/SubTyper.scala)11
2 files changed, 16 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index bdec812bf..873bbf377 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -16,6 +16,7 @@ object Contexts {
val underlying: Context
val root: RootContext
val period: Period
+ def constraints: Constraints
def subTyper: SubTyper
def names: NameTable
def phase: Phase = ???
@@ -26,8 +27,11 @@ object Contexts {
abstract class SubContext(val underlying: Context) extends Context {
val root: RootContext = underlying.root
val period: Period = underlying.period
- val subTyper = underlying.subTyper
+ val constraints = underlying.constraints
def names: NameTable = root.names
+ lazy val subTyper =
+ if (constraints eq underlying.constraints) underlying.subTyper
+ else new SubTyper(this)
}
class RootContext extends Context
@@ -37,6 +41,7 @@ object Contexts {
with Types {
val underlying: Context = throw new UnsupportedOperationException("RootContext.underlying")
+ def subTyper: SubTyper = ???
val root: RootContext = this
val period = periodOf(NoRunId, NoPhaseId)
@@ -46,7 +51,7 @@ object Contexts {
var lastPhaseId: Int = NoPhaseId
lazy val definitions = new Definitions()(this)
- val subTyper = new SubTyper(Map())(this)
+ val constraints: Constraints = Map()
}
private final val initialUniquesCapacity = 4096
diff --git a/src/dotty/tools/dotc/core/SubTyper.scala b/src/dotty/tools/dotc/core/SubTypers.scala
index 52e8f7ece..602b380f4 100644
--- a/src/dotty/tools/dotc/core/SubTyper.scala
+++ b/src/dotty/tools/dotc/core/SubTypers.scala
@@ -11,9 +11,13 @@ object SubTypers {
private final val LogPendingSubTypesThreshold = 50
}
- class SubTyper(var constraints: Constraints)(implicit ctx: Context) extends DotClass {
+ class SubTyper(_ctx: Context) extends DotClass {
import SubTyper._
+ implicit val ctx = _ctx
+
+ var constraints = ctx.constraints
+
private var pendingSubTypes: mutable.Set[(Type, Type)] = null
private var recCount = 0
@@ -215,6 +219,9 @@ object SubTypers {
}
}
- def isSameType(tp1: Type, tp2: Type): Boolean = ???
+ def isSameType(tp1: Type, tp2: Type): Boolean =
+ if (tp1 == NoType || tp2 == NoType) false
+ else if (tp1 eq tp2) true
+ else isSubType(tp1, tp2) && isSubType(tp2, tp1)
}
} \ No newline at end of file