diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t9527a.check | 7 | ||||
-rw-r--r-- | test/files/neg/t9527a.scala | 8 | ||||
-rw-r--r-- | test/files/neg/t9527b.check | 4 | ||||
-rw-r--r-- | test/files/neg/t9527b.scala | 9 |
5 files changed, 31 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index c9d3b3da96..b7c72f5373 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1250,13 +1250,14 @@ trait ContextErrors { ) } - def treeTypeArgs(annotatedTree: Tree) = annotatedTree match { + def treeTypeArgs(annotatedTree: Tree): List[String] = annotatedTree match { case TypeApply(_, args) => args.map(_.toString) + case Block(_, Function(_, treeInfo.Applied(_, targs, _))) => targs.map(_.toString) // eta expansion, see neg/t9527b.scala case _ => Nil } context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, - (tree1.symbol, tree2.symbol) match { + (info1.sym, info2.sym) match { case (ImplicitAmbiguousMsg(msg), _) => msg.format(treeTypeArgs(tree1)) case (_, ImplicitAmbiguousMsg(msg)) => msg.format(treeTypeArgs(tree2)) case (_, _) if isView => viewMsg diff --git a/test/files/neg/t9527a.check b/test/files/neg/t9527a.check new file mode 100644 index 0000000000..e756518bed --- /dev/null +++ b/test/files/neg/t9527a.check @@ -0,0 +1,7 @@ +t9527a.scala:5: error: ambiguous implicit values: + both method f in class C of type (x: Int)String + and method g in class C of type (x: Int)String + match expected type Int => String + implicitly[Int => String] + ^ +one error found diff --git a/test/files/neg/t9527a.scala b/test/files/neg/t9527a.scala new file mode 100644 index 0000000000..35c58fc9a6 --- /dev/null +++ b/test/files/neg/t9527a.scala @@ -0,0 +1,8 @@ +class C { + implicit def f(x: Int): String = "f was here" + implicit def g(x: Int): String = "f was here" + def test: Unit = { + implicitly[Int => String] + } +} + diff --git a/test/files/neg/t9527b.check b/test/files/neg/t9527b.check new file mode 100644 index 0000000000..4529ec83ea --- /dev/null +++ b/test/files/neg/t9527b.check @@ -0,0 +1,4 @@ +t9527b.scala:6: error: msg A=Nothing + implicitly[Int => String] + ^ +one error found diff --git a/test/files/neg/t9527b.scala b/test/files/neg/t9527b.scala new file mode 100644 index 0000000000..b40a4dca9e --- /dev/null +++ b/test/files/neg/t9527b.scala @@ -0,0 +1,9 @@ +class C { + @annotation.implicitAmbiguous("msg A=${A}") + implicit def f[A](x: Int): String = "f was here" + implicit def g(x: Int): String = "f was here" + def test: Unit = { + implicitly[Int => String] + } +} + |