From b43b3b0ba8ac55ea9c1727b8a4c5e9ad5696fe6d Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 13:49:43 +0200 Subject: SI-6335 More precise location of the implicit class synthetic method. One approach would be to disallow an implicit class in a template that already has a member with the same name. But this commit doesn't do this; instead it uses `isSynthetic` to find the synthesized implicit conversion method from the potentially overloaded alternatives. --- test/files/pos/t6335.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/files/pos/t6335.scala (limited to 'test/files/pos') diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala new file mode 100644 index 0000000000..a39c4f27f5 --- /dev/null +++ b/test/files/pos/t6335.scala @@ -0,0 +1,11 @@ +object E { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } +} + +object Test { + import E._ + 0.xx +} -- cgit v1.2.3 From 6f78b501c226bd3c24c516801a23865531591ebe Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 9 Sep 2012 14:10:53 +0200 Subject: More tests for SI-6335. --- test/files/neg/t6335.check | 9 +++++++++ test/files/neg/t6335.scala | 7 +++++++ test/files/pos/t6335.scala | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t6335.check create mode 100644 test/files/neg/t6335.scala (limited to 'test/files/pos') diff --git a/test/files/neg/t6335.check b/test/files/neg/t6335.check new file mode 100644 index 0000000000..1727a05eb2 --- /dev/null +++ b/test/files/neg/t6335.check @@ -0,0 +1,9 @@ +t6335.scala:6: error: method Z is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class Z[A](val i: A) { def zz = i } + ^ +t6335.scala:3: error: method X is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class X(val x: Int) { def xx = x } + ^ +two errors found diff --git a/test/files/neg/t6335.scala b/test/files/neg/t6335.scala new file mode 100644 index 0000000000..5c41e81ef5 --- /dev/null +++ b/test/files/neg/t6335.scala @@ -0,0 +1,7 @@ +object ImplicitClass { + def X(i: Int) {} + implicit class X(val x: Int) { def xx = x } + + def Z[A](i: A) {} + implicit class Z[A](val i: A) { def zz = i } +} \ No newline at end of file diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala index a39c4f27f5..50e34092d1 100644 --- a/test/files/pos/t6335.scala +++ b/test/files/pos/t6335.scala @@ -1,11 +1,25 @@ -object E { +object E extends Z { def X = 3 implicit class X(val i: Int) { def xx = i } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 } object Test { import E._ 0.xx + + "".yy + + true.zz } -- cgit v1.2.3