summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-04-02 11:24:27 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-04-02 11:59:02 +0200
commitd1c7f8d451d29f6f5d7ccf665c35acbe96ed4680 (patch)
treed2de3478d169f1e96ce39aaa8ef3e13d9ccfc152 /src
parent8489be16b57a08f51bf3655c99cede52477b3022 (diff)
downloadscala-d1c7f8d451d29f6f5d7ccf665c35acbe96ed4680.tar.gz
scala-d1c7f8d451d29f6f5d7ccf665c35acbe96ed4680.tar.bz2
scala-d1c7f8d451d29f6f5d7ccf665c35acbe96ed4680.zip
SI-8463 Avoid unpositioned errors from search for views
Ideally, I'd like to fix this using `saveErrors = false` here to firewall the enclosing context from the ambiguiouty error encountered during implicit search. I originally proposed that patch as a fix for SI-8419 in https://github.com/scala/scala/pull/3460 but withdrew from that approach as I uncovered a deeper bug that meant that we actually shouldn't have even been looking for views in that case. But, this runs into SI-8230 and these failures: test/partest --update-check \ /Users/jason/code/scala/test/files/pos/t2504.scala \ /Users/jason/code/scala/test/files/pos/t4457_1.scala \ /Users/jason/code/scala/test/files/neg/t4457_2.scala Turns out that typechecking the ostensible straight forward application, `Array("abc")`, hinges on us leaking an ambiguity error from `viewExists` to find a path through overload resolution! This commit takes a tiny step forward by using `context.tree` rather than `EmptyTree` as the argument to `inferImplicit`. This avoids unpositioned type errors.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 9f557f4aa5..070c24ac8f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -197,7 +197,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
!from.isError
&& !to.isError
&& context.implicitsEnabled
- && (inferView(EmptyTree, from, to, reportAmbiguous = false) != EmptyTree)
+ && (inferView(context.tree, from, to, reportAmbiguous = false, saveErrors = true) != EmptyTree)
+ // SI-8230 / SI-8463 We'd like to change this to `saveErrors = false`, but can't.
+ // For now, we can at least pass in `context.tree` rather then `EmptyTree` so as
+ // to avoid unpositioned type errors.
)
def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean): Tree =