aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2016-06-22 14:13:32 +0200
committerGitHub <noreply@github.com>2016-06-22 14:13:32 +0200
commit82a0bd3bdd47fd01765c2e3e8e6e33bf4e943ad1 (patch)
tree2904ab37df31e7731b5ab638e9f6f5035e874cf0
parentc7d1826cf0456e5efad5cb66ae06e7273c8a8e2a (diff)
parentcece884812143c6c8090ce08c6321bd4a1d52ea6 (diff)
downloaddotty-82a0bd3bdd47fd01765c2e3e8e6e33bf4e943ad1.tar.gz
dotty-82a0bd3bdd47fd01765c2e3e8e6e33bf4e943ad1.tar.bz2
dotty-82a0bd3bdd47fd01765c2e3e8e6e33bf4e943ad1.zip
Merge pull request #1325 from dotty-staging/overloaded-extractor
better handling of overloaded extractors
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala4
-rw-r--r--tests/pos/i1318.scala38
2 files changed, 40 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index f743c5784..a9184c7e5 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -709,11 +709,11 @@ trait Applications extends Compatibility { self: Typer =>
// try first for non-overloaded, then for overloaded ocurrences
def tryWithName(name: TermName)(fallBack: Tree => Tree)(implicit ctx: Context): Tree =
tryEither {
- implicit ctx => typedExpr(untpd.Select(qual, name), genericProto)
+ implicit ctx => typedExpr(untpd.Select(qual, name), specificProto)
} {
(sel, _) =>
tryEither {
- implicit ctx => typedExpr(untpd.Select(qual, name), specificProto)
+ implicit ctx => typedExpr(untpd.Select(qual, name), genericProto)
} {
(_, _) => fallBack(sel)
}
diff --git a/tests/pos/i1318.scala b/tests/pos/i1318.scala
new file mode 100644
index 000000000..dfb882825
--- /dev/null
+++ b/tests/pos/i1318.scala
@@ -0,0 +1,38 @@
+object Foo {
+ class S(i: Int)
+ case class T(i: Int) extends S(i)
+
+ object T {
+ def unapply(s: S): Option[(Int, Int)] = Some(5, 6)
+ // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7)
+ }
+
+ val s = new S(5)
+
+ s match {
+ // case T(x, y, z) => println(x + y + z)
+ case T(x, y) => println(x + y)
+ case T(x) => println(x)
+ case _ => println("not match")
+ }
+}
+
+object Bar {
+ case class T(i: Int)
+ class S(i: Int) extends T(i)
+
+ object T {
+ def unapply(s: S): Option[(Int, Int)] = Some(5, 6)
+ // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7)
+ }
+
+ val s = new S(5)
+
+ s match {
+ // case T(x, y, z) => println(x + y + z)
+ case T(x, y) => println(x + y)
+ case T(x) => println(x)
+ case _ => println("not match")
+ }
+}
+