summaryrefslogtreecommitdiff
path: root/test/files/neg/no-implicit-to-anyref-any-val.scala
blob: f5daf541afca1b710420e60b92e607beefa2e8b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
}