aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-17 15:53:21 +0100
committerTobias Schlatter <tobias@meisch.ch>2014-03-21 11:28:30 +0100
commit77d1c83ff67894bf87d37bfb8982d818fdc88f73 (patch)
tree53c2b4343ef3fe64b2ea81b187360077b6274435 /src/dotty/tools/dotc/core/TypeComparer.scala
parent90f430bfb9178e49dc112bacf5b250d0780dcd1e (diff)
downloaddotty-77d1c83ff67894bf87d37bfb8982d818fdc88f73.tar.gz
dotty-77d1c83ff67894bf87d37bfb8982d818fdc88f73.tar.bz2
dotty-77d1c83ff67894bf87d37bfb8982d818fdc88f73.zip
Fix of t0625 - compare method types
Method type comparison via <:< yielded false if the signatures of the two method types differed. This is too strict, because methods can have the same parametyers but different result types and still be in a subtype relationship. We now onyl demand that the sighatures have the same parameters.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index cfb9477c3..612b78f79 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -201,7 +201,11 @@ class TypeComparer(initctx: Context) extends DotClass {
def isNonBottomSubType(tp1: Type, tp2: Type): Boolean =
!(tp2 isRef NothingClass) && isSubType(tp1, tp2)
- def isSubType(tp1: Type, tp2: Type): Boolean = /*>|>*/ ctx.traceIndented(s"isSubType ${tp1.show} <:< ${tp2.show}", subtyping) /*<|<*/ {
+ private def traceInfo(tp1: Type, tp2: Type) =
+ s"${tp1.show} <:< ${tp2.show}" +
+ (if (ctx.settings.verbose.value) s"${tp1.getClass} ${tp2.getClass}" else "")
+
+ def isSubType(tp1: Type, tp2: Type): Boolean = /*>|>*/ ctx.traceIndented(s"isSubType ${traceInfo(tp1, tp2)}", subtyping) /*<|<*/ {
if (tp2 eq NoType) false
else if (tp1 eq tp2) true
else {
@@ -467,7 +471,7 @@ class TypeComparer(initctx: Context) extends DotClass {
case tp2 @ MethodType(_, formals2) =>
def compareMethod = tp1 match {
case tp1 @ MethodType(_, formals1) =>
- tp1.signature == tp2.signature &&
+ (tp1.signature sameParams tp2.signature) &&
(if (Config.newMatch) subsumeParams(formals1, formals2, tp1.isJava, tp2.isJava)
else matchingParams(formals1, formals2, tp1.isJava, tp2.isJava)) &&
tp1.isImplicit == tp2.isImplicit && // needed?