aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-14 19:04:47 +0100
committerMartin Odersky <odersky@gmail.com>2015-01-14 19:09:34 +0100
commit19234838329aabfe202a2fbf46470528baebd83c (patch)
treea7b0193e7a20fb2a480d1c2b5839ad76979f05ca /src/dotty/tools/dotc
parentc0b75098f66d4611683bc308d7f6127e6c6e433b (diff)
downloaddotty-19234838329aabfe202a2fbf46470528baebd83c.tar.gz
dotty-19234838329aabfe202a2fbf46470528baebd83c.tar.bz2
dotty-19234838329aabfe202a2fbf46470528baebd83c.zip
Allow to merge TypeBounds and ClassInfos in |, &
There seems to be no reason why we should not merge a class and an abstract type that has the class within its bounds. I.e. Assume class A { type T } class B { class T } Then (A | B) # T should be legal and refer to type T, and (A & B) # T should be legal and refer to class T.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala3
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala16
-rw-r--r--src/dotty/tools/dotc/core/Types.scala1
3 files changed, 12 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index 2be97691f..2854d7d2f 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -256,6 +256,9 @@ trait Symbols { this: Context =>
tparams
}
+ /** Create a new skolem symbol. This is not the same as SkolemType, even thouggh the
+ * motivation (create a singleton referencing to a type)= is similar.
+ */
def newSkolem(tp: Type) = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | Permanent, tp)
def newErrorSymbol(owner: Symbol, name: Name) =
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 05edad59b..0d2dc20d3 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -932,14 +932,14 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
case tp1: TypeBounds =>
tp2 match {
case tp2: TypeBounds => tp1 & tp2
+ case tp2: ClassInfo if tp1 contains tp2.typeRef => tp2
case _ => andConflict(tp1, tp2)
}
case tp1: ClassInfo =>
tp2 match {
- case tp2: ClassInfo if tp1.cls eq tp2.cls =>
- tp1.derivedClassInfo(tp1.prefix & tp2.prefix)
- case _ =>
- andConflict(tp1, tp2)
+ case tp2: ClassInfo if tp1.cls eq tp2.cls => tp1.derivedClassInfo(tp1.prefix & tp2.prefix)
+ case tp2: TypeBounds if tp2 contains tp1.typeRef => tp1
+ case _ => andConflict(tp1, tp2)
}
case tp1 @ MethodType(names1, formals1) =>
tp2 match {
@@ -997,14 +997,14 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
case tp1: TypeBounds =>
tp2 match {
case tp2: TypeBounds => tp1 | tp2
+ case tp2: ClassInfo if tp1 contains tp2.typeRef => tp1
case _ => orConflict(tp1, tp2)
}
case tp1: ClassInfo =>
tp2 match {
- case tp2: ClassInfo if tp1.cls eq tp2.cls =>
- tp1.derivedClassInfo(tp1.prefix | tp2.prefix)
- case _ =>
- orConflict(tp1, tp2)
+ case tp2: ClassInfo if tp1.cls eq tp2.cls => tp1.derivedClassInfo(tp1.prefix | tp2.prefix)
+ case tp2: TypeBounds if tp2 contains tp1.typeRef => tp2
+ case _ => orConflict(tp1, tp2)
}
case tp1 @ MethodType(names1, formals1) =>
tp2 match {
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 0363a8c70..8249e5a4c 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2151,6 +2151,7 @@ object Types {
}
}
+ /** TODO Some docs would be nice here! */
case class PolyParam(binder: PolyType, paramNum: Int) extends ParamType {
type BT = PolyType
def copyBoundType(bt: BT) = PolyParam(bt, paramNum)