diff options
author | Martin Odersky <odersky@gmail.com> | 2016-08-18 17:24:11 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-08-18 17:49:06 +0200 |
commit | d5ef867b1f89c79f8620129693e4f1e9bc6f617c (patch) | |
tree | 90b573d0452c362d6dbe6be0731f22d211d35200 /tests | |
parent | 5a5f9d7ed37ca6449ef61ee5e0f6fbf9731df795 (diff) | |
download | dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.tar.gz dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.tar.bz2 dotty-d5ef867b1f89c79f8620129693e4f1e9bc6f617c.zip |
Refinements to auto tupling
There's a nasty interaction with auto-tupling and trying to insert an implicit
on the qualifier of a call. If the original call fails, we need to "undo" any
auto-tupling decisions in calls where an implicit is inserted on the qualifier.
Also: Needed to fix canAutoTuple test so that Scala2 feature is checked instead of dotty's.
Also: Drop features in dotty.language that duplicate those in scala.language.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/autoTuplingTest.scala | 2 | ||||
-rw-r--r-- | tests/pos/t2913.scala (renamed from tests/pending/pos/t2913.scala) | 27 |
2 files changed, 25 insertions, 4 deletions
diff --git a/tests/neg/autoTuplingTest.scala b/tests/neg/autoTuplingTest.scala index 37136b760..62f10b3ea 100644 --- a/tests/neg/autoTuplingTest.scala +++ b/tests/neg/autoTuplingTest.scala @@ -1,5 +1,3 @@ -import dotty.language.noAutoTupling - object autoTuplingNeg2 { val x = Some(1, 2) // error: too many arguments for method apply: (x: A)Some[A] diff --git a/tests/pending/pos/t2913.scala b/tests/pos/t2913.scala index 21700e71a..fa91e6f41 100644 --- a/tests/pending/pos/t2913.scala +++ b/tests/pos/t2913.scala @@ -1,4 +1,3 @@ -import language.noAutoTupling // try with on and off class A { def foo(a: Int) = 0 @@ -10,7 +9,8 @@ class RichA { def foo() = 0 } -object Test { +object TestNoAutoTupling { + import language.noAutoTupling // try with on and off implicit def AToRichA(a: A): RichA = new RichA @@ -53,3 +53,26 @@ object Main { () } } + +object TestWithAutoTuling { + + implicit def AToRichA(a: A): RichA = new RichA + + val a = new A + a.foo() + a.foo(1) + + a.foo("") // Without implicits, a type error regarding invalid argument types is generated at `""`. This is + // the same position as an argument, so the 'second try' typing with an Implicit View is tried, + // and AToRichA(a).foo("") is found. + // + // My reading of the spec "7.3 Views" is that `a.foo` denotes a member of `a`, so the view should + // not be triggered. + // + // But perhaps the implementation was changed to solve See https://lampsvn.epfl.ch/trac/scala/ticket/1756 + + a.foo("a", "b") // Without implicits, a type error regarding invalid arity is generated at `foo(<error>"", "")`. + // Typers#tryTypedApply:3274 only checks if the error is as the same position as `foo`, `"a"`, or `"b"`. + // None of these po +} + |