aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-20 14:20:23 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-20 14:20:23 +0100
commitdb5066bbb4c281bd3b65fe6422314afee115de5e (patch)
treeabae091c0339527852c22a7701885e2306b9e453 /src
parentacc9d750d1776d8d1c864fb3ddaadbaec34d286e (diff)
downloaddotty-db5066bbb4c281bd3b65fe6422314afee115de5e.tar.gz
dotty-db5066bbb4c281bd3b65fe6422314afee115de5e.tar.bz2
dotty-db5066bbb4c281bd3b65fe6422314afee115de5e.zip
More tweaks
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Constraint.scala6
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala5
-rw-r--r--src/dotty/tools/dotc/core/TyperState.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala6
4 files changed, 13 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Constraint.scala b/src/dotty/tools/dotc/core/Constraint.scala
index 29e1e01fe..d2ea6aa65 100644
--- a/src/dotty/tools/dotc/core/Constraint.scala
+++ b/src/dotty/tools/dotc/core/Constraint.scala
@@ -19,6 +19,12 @@ class Constraint(val map: SimpleMap[PolyType, Array[Type]]) extends AnyVal with
/** Does the constraint's domain contain the type parameters of `pt`? */
def contains(pt: PolyType): Boolean = map(pt) != null
+ /** Does the constraint's domain contain the type parameter `param`? */
+ def contains(param: PolyParam): Boolean = {
+ val entries = map(param.binder)
+ entries != null && entries(param.paramNum).exists
+ }
+
/** The constraint for given type parameter `param`, or NoType if `param` is not part of
* the constraint domain.
*/
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index a4d96019e..a796d7e43 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -56,8 +56,9 @@ class TypeComparer(initctx: Context) extends DotClass {
val pnum = param.paramNum
val oldEntries = constraint(pt)
val oldBounds = oldEntries(pnum).asInstanceOf[TypeBounds]
- val constrBounds = if (fromBelow) TypeBounds.lower(bound) else TypeBounds.upper(bound)
- val newBounds = oldBounds & constrBounds
+ val newBounds =
+ if (fromBelow) oldBounds.derivedTypeBounds(oldBounds.lo | bound, oldBounds.hi)
+ else oldBounds.derivedTypeBounds(oldBounds.lo, oldBounds.hi & bound)
if (oldBounds ne newBounds) {
val newEntries = oldEntries.clone
newEntries(pnum) = newBounds
diff --git a/src/dotty/tools/dotc/core/TyperState.scala b/src/dotty/tools/dotc/core/TyperState.scala
index 8246ae198..626c1227f 100644
--- a/src/dotty/tools/dotc/core/TyperState.scala
+++ b/src/dotty/tools/dotc/core/TyperState.scala
@@ -104,7 +104,7 @@ extends TyperState(reporter) {
def checkConsistent(show: Showable => String = MutableTyperState.toStr): Unit = if (checkingEnabled) {
def err(msg: String, what: Showable) = s"$msg: ${show(what)}\n${show(this)}"
for (tvar <- undetVars)
- assert(constraint(tvar.origin).exists, err("unconstrained type var", tvar.origin))
+ assert(constraint contains tvar.origin, err("unconstrained type var", tvar.origin))
if (isCommittable) {
val undetParams = undetVars map (_.origin)
for (param <- constraint.domainParams)
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 9d6df553c..f1b603b4a 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -598,9 +598,9 @@ trait Applications extends Compatibility { self: Typer =>
ctx.maximizeType(unapplyArgType) match {
case Some(tvar) =>
def msg =
- s"""There is no best instantiation of pattern type ${unapplyArgType.show}
- |that makes it a subtype of selector type ${pt.show}.
- |Non-variant type variable ${tvar.origin.show} cannot be uniquely instantiated.""".stripMargin
+ i"""There is no best instantiation of pattern type $unapplyArgType
+ |that makes it a subtype of selector type $pt.
+ |Non-variant type variable ${tvar.origin} cannot be uniquely instantiated.""".stripMargin
if (fromScala2x) {
// We can't issue an error here, because in Scala 2, ::[B] is invariant
// whereas List[+T] is covariant. According to the strict rule, a pattern