From 5f318bc925c227d2bce5cff31610803185b57f54 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 20 Mar 2014 10:51:01 +0100 Subject: Fix of t1272: overloading resolution stripImplicits needs to take polytypes into account. --- src/dotty/tools/dotc/typer/Applications.scala | 12 +++++++++--- tests/pending/pos/t1272.scala | 9 --------- tests/pos/t1272.scala | 9 +++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) delete mode 100644 tests/pending/pos/t1272.scala create mode 100644 tests/pos/t1272.scala diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 4d26532d6..46a6ebf66 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -785,9 +785,13 @@ trait Applications extends Compatibility { self: Typer => }} /** Drop any implicit parameter section */ - def stripImplicit(tp: Type) = tp match { - case mt: ImplicitMethodType if !mt.isDependent => mt.resultType // todo: make sure implicit method types are not dependent - case _ => tp + def stripImplicit(tp: Type): Type = tp match { + case mt: ImplicitMethodType if !mt.isDependent => + mt.resultType // todo: make sure implicit method types are not dependent + case pt: PolyType => + pt.derivedPolyType(pt.paramNames, pt.paramBounds, stripImplicit(pt.resultType)) + case _ => + tp } val owner1 = alt1.symbol.owner @@ -800,6 +804,8 @@ trait Applications extends Compatibility { self: Typer => def winsOwner2 = isDerived(owner2, owner1) def winsType2 = isAsSpecific(alt2, tp2, alt1, tp1) + implicits.println(i"isAsGood($alt1, $alt2)? $tp1 $tp2 $winsOwner1 $winsType1 $winsOwner2 $winsType2") + // Assume the following probabilities: // // P(winsOwnerX) = 2/3 diff --git a/tests/pending/pos/t1272.scala b/tests/pending/pos/t1272.scala deleted file mode 100644 index 916b783bb..000000000 --- a/tests/pending/pos/t1272.scala +++ /dev/null @@ -1,9 +0,0 @@ -object ImplicitTest { - implicit val i : Int = 10 - implicit def a(implicit i : Int) : Array[Byte] = null - implicit def b[T](implicit i : Int) : Array[T] = null - - def fn[T](implicit x : T) = 0 - - val x = fn[Array[Byte]] -} diff --git a/tests/pos/t1272.scala b/tests/pos/t1272.scala new file mode 100644 index 000000000..916b783bb --- /dev/null +++ b/tests/pos/t1272.scala @@ -0,0 +1,9 @@ +object ImplicitTest { + implicit val i : Int = 10 + implicit def a(implicit i : Int) : Array[Byte] = null + implicit def b[T](implicit i : Int) : Array[T] = null + + def fn[T](implicit x : T) = 0 + + val x = fn[Array[Byte]] +} -- cgit v1.2.3