forked from com-lihaoyi/sourcecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApply.scala
More file actions
57 lines (44 loc) · 1.58 KB
/
Apply.scala
File metadata and controls
57 lines (44 loc) · 1.58 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
package sourcecode
object Apply {
def applyRun() = {
val name = sourcecode.Name()
assert(name == "name")
val fullName = sourcecode.FullName()
assert(fullName == "sourcecode.Apply.fullName")
val enclosing = sourcecode.Enclosing()
assert(enclosing == "sourcecode.Apply.applyRun enclosing")
val pkg = sourcecode.Pkg()
assert(pkg == "sourcecode")
val file = sourcecode.File()
assert(file.endsWith("/sourcecode/Apply.scala"))
val fileName = sourcecode.FileName()
assert(fileName == "Apply.scala")
val line = sourcecode.Line()
assert(line == 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 = sourcecode.Name()
assert(name == "name")
val fullName = sourcecode.FullName()
assert(fullName == "sourcecode.Apply.Bar.fullName")
val file = sourcecode.File()
assert(file.endsWith("/sourcecode/Apply.scala"))
val fileName = sourcecode.FileName()
assert(fileName == "Apply.scala")
val line = sourcecode.Line()
assert(line == 44)
val enclosing = sourcecode.Enclosing()
assert(
enclosing == "sourcecode.Apply.applyRun myLazy$lzy Bar#enclosing" ||
enclosing == "sourcecode.Apply.applyRun myLazy Bar#enclosing" // encoding changed in Scala 2.12
)
}
val b = new Bar{}
}
myLazy
}
}