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
|
package dotty.tools
package dotc
package ast
import org.junit.Test
import core.Names._
import core.Types._
import core.Symbols._
import org.junit.Assert._
class TreeInfoTest extends DottyTest {
import tpd._
@Test
def testDefPath = checkCompile("frontend", "class A { def bar = { val x = { val z = 0; 0} }} ") {
(tree, context) =>
implicit val ctx = context
val xTree = tree.find(tree => tree.symbol.name == termName("x")).get
val path = defPath(xTree.symbol, tree)
assertEquals(List(
("PackageDef", EMPTY_PACKAGE),
("TypeDef", typeName("A")),
("Template", termName("<local A>")),
("DefDef", termName("bar")),
("Block", NoSymbol.name),
("ValDef", termName("x"))
), path.map(x => (x.productPrefix, x.symbol.name)))
}
}
|