aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-12-25 14:04:58 +0100
committerMartin Odersky <odersky@gmail.com>2012-12-25 14:04:58 +0100
commitf1550a1a132a7a97d461afce1ea79453d78be5ea (patch)
treee9ec149e7ff6b2cf3e1cad3f29cb9febfc207459
parentbca5fe2d51d98fb97646c2a7217a5c60548b08ab (diff)
downloaddotty-f1550a1a132a7a97d461afce1ea79453d78be5ea.tar.gz
dotty-f1550a1a132a7a97d461afce1ea79453d78be5ea.tar.bz2
dotty-f1550a1a132a7a97d461afce1ea79453d78be5ea.zip
Small additions and fixes to subtyping logic
-rw-r--r--src/dotty/tools/dotc/core/SubTyper.scala16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SubTyper.scala b/src/dotty/tools/dotc/core/SubTyper.scala
index a97f23224..52e8f7ece 100644
--- a/src/dotty/tools/dotc/core/SubTyper.scala
+++ b/src/dotty/tools/dotc/core/SubTyper.scala
@@ -17,7 +17,7 @@ object SubTypers {
private var pendingSubTypes: mutable.Set[(Type, Type)] = null
private var recCount = 0
- def addConstraint(param: PolyParam, bounds: TypeBounds): Boolean = {
+ def addConstraint(param: PolyParam, bounds: TypeBounds): Boolean = {
val newbounds = constraints(param) & bounds
constraints = constraints.updated(param, newbounds)
newbounds.lo <:< newbounds.hi
@@ -129,13 +129,23 @@ object SubTypers {
case tp2 @ MethodType(_, formals1) =>
tp1 match {
case tp1 @ MethodType(_, formals2) =>
- sameLength(formals1, formals2) &&
+ tp1.signature == tp2.signature &&
matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
tp1.isImplicit == tp2.isImplicit &&
isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
case _ =>
false
}
+ case tp2: PolyType =>
+ tp1 match {
+ case tp1: PolyType =>
+ tp1.signature == tp2.signature &&
+ (tp1.paramBounds corresponds tp2.paramBounds)(
+ (b1, b2) => b1 =:= b2.subst(tp2, tp1)) &&
+ isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
+ case _ =>
+ false
+ }
case tp2 @ ExprType(restpe1) =>
tp1 match {
case tp1 @ ExprType(restpe2) =>
@@ -204,5 +214,7 @@ object SubTypers {
matchingParams(rest1, rest2, isJava1, isJava2)
}
}
+
+ def isSameType(tp1: Type, tp2: Type): Boolean = ???
}
} \ No newline at end of file