diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2010-05-26 11:52:11 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2010-05-26 11:52:11 +0000 |
commit | bf7eee08892aa38130dda75cfb6099fdc8b5bcd4 (patch) | |
tree | 03a384d198db3443c056abe2bcecec852843812d /test | |
parent | 0301bcfa431cceb6fbf55c7a6c31c611e17e6066 (diff) | |
download | scala-bf7eee08892aa38130dda75cfb6099fdc8b5bcd4.tar.gz scala-bf7eee08892aa38130dda75cfb6099fdc8b5bcd4.tar.bz2 scala-bf7eee08892aa38130dda75cfb6099fdc8b5bcd4.zip |
also consider non-implicit locals when checking...
also consider non-implicit locals when checking shadowing of implicits:
closes #3453
nonImplicitSynonymInScope implements the predicate that is used in
tryImplicit's checks for shadowing of locally defined implicits
benchmarking shows the predicate does not significantly affect quick.comp+quick.lib (goes from 11min to 11min2s on my machine -- no optimisations)
review by odersky
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t3453.check | 21 | ||||
-rw-r--r-- | test/files/neg/t3453.scala | 66 |
2 files changed, 87 insertions, 0 deletions
diff --git a/test/files/neg/t3453.check b/test/files/neg/t3453.check new file mode 100644 index 0000000000..52c948128c --- /dev/null +++ b/test/files/neg/t3453.check @@ -0,0 +1,21 @@ +t3453.scala:18: error: type mismatch; + found : A + required: B + new A + ^ +t3453.scala:36: error: type mismatch; + found : A + required: B + new A + ^ +t3453.scala:50: error: type mismatch; + found : A + required: B + new A + ^ +t3453.scala:64: error: type mismatch; + found : A + required: B + new A + ^ +four errors found diff --git a/test/files/neg/t3453.scala b/test/files/neg/t3453.scala new file mode 100644 index 0000000000..090b777151 --- /dev/null +++ b/test/files/neg/t3453.scala @@ -0,0 +1,66 @@ +// test shadowing of implicits by synonymous non-implicit symbols +// whether they be inherited, imported (explicitly or using a wildcard) or defined directly +class A +class B + +trait S { + implicit def aToB(a: A): B = new B +} + +class T1 extends S { + def x: B = { + val aToB = 3 + // ok: doesn't compile, because aToB method requires 'T.this.' prefix + //aToB(new A) + + // bug: compiles, using T.this.aToB, + // despite it not being accessible without a prefix + new A + } +} + +object O { + implicit def aToB(a: A): B = new B +} + +class T2a { + import O._ + + def x: B = { + val aToB = 3 + // ok: doesn't compile, because aToB method requires 'T.this.' prefix + //aToB(new A) + + // bug: compiles, using T.this.aToB, + // despite it not being accessible without a prefix + new A + } +} + +class T2b { + import O.aToB + + def x: B = { + val aToB = 3 + // ok: doesn't compile, because aToB method requires 'T.this.' prefix + //aToB(new A) + + // bug: compiles, using T.this.aToB, + // despite it not being accessible without a prefix + new A + } +} + +class T3 { + implicit def aToB(a: A): B = new B + + def x: B = { + val aToB = 3 + // ok: doesn't compile, because aToB method requires 'T.this.' prefix + //aToB(new A) + + // bug: compiles, using T.this.aToB, + // despite it not being accessible without a prefix + new A + } +}
\ No newline at end of file |