summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-04-21 22:24:07 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-04-21 22:24:07 +0200
commit178e9abe7b2481c010496f2d15f389fef0320e0a (patch)
tree566e58257b97a5d870e1c3bfe5c7aea26d6608c5
parent969e22f601d18c76ffbe22d994948874c60ebec0 (diff)
parentd1c7f8d451d29f6f5d7ccf665c35acbe96ed4680 (diff)
downloadscala-178e9abe7b2481c010496f2d15f389fef0320e0a.tar.gz
scala-178e9abe7b2481c010496f2d15f389fef0320e0a.tar.bz2
scala-178e9abe7b2481c010496f2d15f389fef0320e0a.zip
Merge pull request #3670 from retronym/ticket/8463
SI-8463 Avoid unpositioned errors from search for views
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
-rw-r--r--test/files/neg/t8463.check10
-rw-r--r--test/files/neg/t8463.scala38
3 files changed, 52 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e3901be546..6231ba2ed2 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 =
diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check
new file mode 100644
index 0000000000..1a3eea2870
--- /dev/null
+++ b/test/files/neg/t8463.check
@@ -0,0 +1,10 @@
+t8463.scala:5: error: type mismatch;
+ found : Long
+ required: ?T[Long]
+Note that implicit conversions are not applicable because they are ambiguous:
+ both method longWrapper in class LowPriorityImplicits of type (x: Long)scala.runtime.RichLong
+ and method ArrowAssoc in object Predef of type [A](self: A)ArrowAssoc[A]
+ are possible conversion functions from Long to ?T[Long]
+ insertCell(Foo(5))
+ ^
+one error found
diff --git a/test/files/neg/t8463.scala b/test/files/neg/t8463.scala
new file mode 100644
index 0000000000..7c954fd834
--- /dev/null
+++ b/test/files/neg/t8463.scala
@@ -0,0 +1,38 @@
+object Test {
+ case class Foo[+T[_]](activity:T[Long])
+ type Cell[T] = T
+ def insertCell(u:Foo[Cell]) = ???
+ insertCell(Foo(5))
+}
+
+/* If SI-8230 is fixed, and `viewExists` is changed to no longer leak
+ ambiguity errors, you might expect the check file for this test to
+ change as folloes:
+
+@@ -1,18 +1,10 @@
+-t8463.scala:5: error: no type parameters for method apply: (activity:
+- --- because ---
+-argument expression's type is not compatible with formal parameter ty
++t8463.scala:5: error: type mismatch;
+ found : Long
+ required: ?T[Long]
++Note that implicit conversions are not applicable because they are am
++ both method longWrapper in class LowPriorityImplicits of type (x: Lo
++ and method ArrowAssoc in object Predef of type [A](self: A)ArrowAsso
++ are possible conversion functions from Long to ?T[Long]
+ insertCell(Foo(5))
+- ^
+-t8463.scala:5: error: type mismatch;
+- found : Long(5L)
+- required: T[Long]
+- insertCell(Foo(5))
+- ^
+-t8463.scala:5: error: type mismatch;
+- found : Test.Foo[T]
+- required: Test.Foo[Test.Cell]
+- insertCell(Foo(5))
+- ^
+-three errors found
++ ^
++one error found
+*/