From 3b8129c77b9426a621163d4e5bf54943f58692a1 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 14 Sep 2010 14:23:28 +0000 Subject: closes #1693: improve implicit conversion disam... closes #1693: improve implicit conversion disambiguation by incorporating the expected type of the member that triggered the conversion back-ported fix by Martin in embeddings branch. review by odersky (just in case it shouldn't have been back-ported) --- test/files/neg/implicits.check | 11 +---------- test/files/pos/t1693.scala | 9 +++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 test/files/pos/t1693.scala (limited to 'test/files') diff --git a/test/files/neg/implicits.check b/test/files/neg/implicits.check index 337560f423..d975ccfa84 100644 --- a/test/files/neg/implicits.check +++ b/test/files/neg/implicits.check @@ -1,12 +1,3 @@ -implicits.scala:21: error: type mismatch; - found : Pos - required: ?{val +: ?} -Note that implicit conversions are not applicable because they are ambiguous: - both method any2plus in object Sub of type (x: Any)Sub.Plus - and method pos2int in object Super of type (p: Pos)Int - are possible conversion functions from Pos to ?{val +: ?} - f(p+1) - ^ implicits.scala:38: error: type mismatch; found : test2.HSome[java.lang.String,test2.HMap] required: Int @@ -17,4 +8,4 @@ implicits.scala:46: error: type mismatch; required: scala.List[Mxml] children.toList.flatMap ( e => { ^ -three errors found +two errors found diff --git a/test/files/pos/t1693.scala b/test/files/pos/t1693.scala new file mode 100644 index 0000000000..f3615f4756 --- /dev/null +++ b/test/files/pos/t1693.scala @@ -0,0 +1,9 @@ +object Test { + class Foo + class SomeOps(x : Foo) { def foo(x: String) = 1 } + class OtherOps(x : Foo) { def foo(x: Int) = 1 } + implicit def mkSomeOps(x: Foo) : SomeOps = new SomeOps(x) + implicit def mkOtherOps(x: Foo) : OtherOps = new OtherOps(x) + + (new Foo).foo(1) +} \ No newline at end of file -- cgit v1.2.3