Skip to content

Commit c62f666

Browse files
committed
Added missing file.
1 parent 274ce61 commit c62f666

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package scala.reflect.runtime
2+
3+
trait TreeBuildUtil extends Universe {
4+
5+
def staticClass(name: String): Symbol = definitions.getClass(newTypeName(name))
6+
def staticModule(name: String): Symbol = definitions.getModule(newTermName(name))
7+
8+
def thisModuleType(name: String) =
9+
definitions.getModule(name).moduleClass.thisType
10+
11+
/** Selects type symbol with given name from the defined members of prefix type
12+
*/
13+
def selectType(owner: Symbol, name: String): Symbol =
14+
owner.info.decl(newTypeName(name))
15+
16+
/** Selects term symbol with given name and type from the defined members of prefix type
17+
* @pre The prefix type
18+
* @name The name of the selected member
19+
*/
20+
def selectTerm(owner: Symbol, name: String): Symbol = {
21+
val sym = owner.info.decl(newTermName(name))
22+
if (sym.isOverloaded) sym suchThat (!_.isMethod)
23+
else sym
24+
}
25+
26+
def selectOverloadedMethod(owner: Symbol, name: String, index: Int): Symbol =
27+
owner.info.decl(newTermName(name)).alternatives(index)
28+
29+
def selectParam(owner: Symbol, idx: Int): Symbol = {
30+
def selectInList(params: List[Symbol], idx: Int, fallback: Type): Symbol = {
31+
if (params.isEmpty) selectIn(fallback, idx)
32+
else if (idx == 0) params.head
33+
else selectInList(params.tail, idx - 1, fallback)
34+
}
35+
def selectIn(tpe: Type, idx: Int): Symbol = tpe match {
36+
case PolyType(tparams, res) => selectInList(tparams, idx, res)
37+
case MethodType(params, res) => selectInList(params, idx, res)
38+
case _ => NoSymbol
39+
}
40+
selectIn(owner.info, idx)
41+
}
42+
43+
44+
def freeVar(name: String, info: Type, value: Any) = new FreeVar(name, info, value)
45+
46+
def newScopeWith(decls: List[Symbol]) = new Scope(decls)
47+
48+
}

0 commit comments

Comments
 (0)