diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-01-30 13:29:14 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-01-30 13:29:14 -0800 |
commit | 50f38393af6d5aee3739cc73fdd5c7d22361390a (patch) | |
tree | 795166dc94035a5d9bfa608a5d3cd2c9a10cd7d2 /test/files/neg/no-implicit-to-anyref-any-val.scala | |
parent | 0e578e693196f93b1ba4f972a2c96d468bef464a (diff) | |
parent | 327eea839e97e1d7cac92aa9cd61e3338d12cb12 (diff) | |
download | scala-50f38393af6d5aee3739cc73fdd5c7d22361390a.tar.gz scala-50f38393af6d5aee3739cc73fdd5c7d22361390a.tar.bz2 scala-50f38393af6d5aee3739cc73fdd5c7d22361390a.zip |
Merge pull request #3416 from retronym/topic/any-val-implicit
Prohibit views targeting AnyVal
Diffstat (limited to 'test/files/neg/no-implicit-to-anyref-any-val.scala')
-rw-r--r-- | test/files/neg/no-implicit-to-anyref-any-val.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/files/neg/no-implicit-to-anyref-any-val.scala b/test/files/neg/no-implicit-to-anyref-any-val.scala new file mode 100644 index 0000000000..f5daf541af --- /dev/null +++ b/test/files/neg/no-implicit-to-anyref-any-val.scala @@ -0,0 +1,33 @@ +// Checks that the state of standard implicits in Predef._ and scala._ +// doesn't allow us to unambiguously and implicitly convert AnyVal +// and subtypes to AnyRef. +// +// In the days before value classes, this was precariously held be +// the competing implicits Any => StringAdd and Any => StringFormat. +// Since then, these have both become value classes, but seeing as +// this happened simultaneously, we're still okay. +object Test { + locally { + 1: AnyRef + } + + locally { + // before this test case was added and ContextErrors was tweaked, this + // emitted: "Note that Any extends Any, not AnyRef." + (null: Any): AnyRef + } + + locally { + (0: AnyVal): AnyRef + } + + class AV(val a: Int) extends AnyVal + + locally { + new AV(0): AnyRef + } + + "": AnyVal + + new Object() : AnyVal +} |