diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-06-23 11:27:31 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-06-25 11:01:19 +0200 |
commit | 7a16f76673530f71bf1b8fa79b489b502ef504a8 (patch) | |
tree | cc94c0760f798cf2988d45dee6a29ad4d43ec098 /test/files | |
parent | 1c0b48da8dfa124eb762620c8cb803a9079b7c81 (diff) | |
download | scala-7a16f76673530f71bf1b8fa79b489b502ef504a8.tar.gz scala-7a16f76673530f71bf1b8fa79b489b502ef504a8.tar.bz2 scala-7a16f76673530f71bf1b8fa79b489b502ef504a8.zip |
SI-8675 Avoid unreported error after second try using implicit view
This is specific to situations in which we first typecheck an
application `qual.m(arg)` against the method `m` directly provided
by `qual`, and then fall back to `implicitView(qual).m(arg)`.
Regressed in SI-3971 / 7fa77af, in which error reports were moved
to the innermost `Apply`, and the check for `errorInResult` was
accordingly changed to recurse through `Apply` trees.
Before that change, we did not fall back to using a view. After the
change, we do try a view. We retypecheck the arguments under the
`retyping` mode (see `tryTypedArgs`), but this doesn't seem to
be enough to avoid leaking the error typed nested trees from the
first try.
Here's an example from the enclosed test case:
a.update(0, x[A]({new isString(true)}))
`-- error typed
refArrayOps(a).update(0, x[A]({new isString(true)}))
` `-- error type persists
`-- this tree is retypecked by tryTypedArgs
This commit changes `onError` to only proceed with the second
try if the retyped argument trees are error free.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t8675.check | 11 | ||||
-rw-r--r-- | test/files/neg/t8675.scala | 24 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/files/neg/t8675.check b/test/files/neg/t8675.check new file mode 100644 index 0000000000..4e44fba918 --- /dev/null +++ b/test/files/neg/t8675.check @@ -0,0 +1,11 @@ +t8675.scala:13: error: type mismatch; + found : Boolean(true) + required: String + a.update(0, x[A]({new isString(true)})) // !!! allowed + ^ +t8675.scala:22: error: type mismatch; + found : Boolean(true) + required: String + new X().m(x[A]({new isString(true)})) // !!! allowed + ^ +two errors found diff --git a/test/files/neg/t8675.scala b/test/files/neg/t8675.scala new file mode 100644 index 0000000000..ca9bb57ffa --- /dev/null +++ b/test/files/neg/t8675.scala @@ -0,0 +1,24 @@ +class A(s: String) { + def foo(x: A) = x +} + +class isString(s: String) + +class Test { + + def x[A](a: Any): A = ??? + + def test { + val a = Array[A]() + a.update(0, x[A]({new isString(true)})) // !!! allowed + + // boils down to + class X { + def m(p: Any) {} + } + implicit class XOps(x: X) { + def m(p: Any) {} + } + new X().m(x[A]({new isString(true)})) // !!! allowed + } +} |