forked from com-lihaoyi/sourcecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImplicits.scala
More file actions
61 lines (48 loc) · 2.03 KB
/
Implicits.scala
File metadata and controls
61 lines (48 loc) · 2.03 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package sourcecode
object Implicits {
def implicitRun() = {
val name = implicitly[sourcecode.Name]
assert(name.value == "name")
val fullName = implicitly[sourcecode.FullName]
assert(fullName.value == "sourcecode.Implicits.fullName")
val enclosing = implicitly[sourcecode.Enclosing]
assert(enclosing.value == "sourcecode.Implicits.implicitRun enclosing")
val pkg = implicitly[sourcecode.Pkg]
assert(pkg.value == "sourcecode")
val file = implicitly[sourcecode.File]
assert(file.value.endsWith("/sourcecode/Implicits.scala"))
val fileName = implicitly[sourcecode.FileName]
assert(fileName.value == "Implicits.scala")
val line = implicitly[sourcecode.Line]
assert(line.value == 23)
lazy val myLazy = {
/* Bar used to be a trait, but that ran into the upstream bug
* https://github.com/scala-js/scala-js/issues/3918 in Scala.js 1.0.0-RC2
* and Scala 2.12+. We use an abstract class as a workaround.
*/
abstract class Bar{
val name = implicitly[sourcecode.Name]
assert(name.value == "name")
val fullName = implicitly[sourcecode.FullName]
assert(
fullName.value == "sourcecode.Implicits.Bar.fullName" ||
fullName.value == "sourcecode.Implicits._$Bar.fullName" // Dotty
)
val file = implicitly[sourcecode.File]
assert(file.value.endsWith("/sourcecode/Implicits.scala"))
val fileName = implicitly[sourcecode.FileName]
assert(fileName.value == "Implicits.scala")
val line = implicitly[sourcecode.Line]
assert(line.value == 47)
val enclosing = implicitly[sourcecode.Enclosing]
assert(
enclosing.value == "sourcecode.Implicits.implicitRun myLazy$lzy Bar#enclosing" ||
enclosing.value == "sourcecode.Implicits.implicitRun myLazy Bar#enclosing" || // encoding changed in Scala 2.12
enclosing.value == "sourcecode.Implicits.implicitRun myLazy Bar.enclosing" // Dotty
)
}
val b = new Bar{}
}
myLazy
}
}