blob: 81a6659b3c9d7a6da8cee2aea42e7ca278a4cabb (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* NSC -- new Scala compiler
* Copyright 2005-2011 LAMP/EPFL
* @author Martin Odersky
*/
package scala.tools.nsc
package ast
import reflect.internal.HasFlags
import reflect.internal.Flags._
import symtab._
/** This class ...
*
* @author Martin Odersky
* @version 1.0
*/
abstract class TreeInfo extends reflect.internal.TreeInfo {
val global: Global
import global._
import definitions.ThrowableClass
/** Is tree legal as a member definition of an interface?
*/
override def isInterfaceMember(tree: Tree): Boolean = tree match {
case DocDef(_, definition) => isInterfaceMember(definition)
case _ => super.isInterfaceMember(tree)
}
/** Is tree a pure (i.e. non-side-effecting) definition?
*/
override def isPureDef(tree: Tree): Boolean = tree match {
case DocDef(_, definition) => isPureDef(definition)
case _ => super.isPureDef(tree)
}
/** Does list of trees start with a definition of
* a class of module with given name (ignoring imports)
*/
override def firstDefinesClassOrObject(trees: List[Tree], name: Name): Boolean = trees match {
case ClassDef(_, `name`, _, _) :: Nil => true
case _ => super.firstDefinesClassOrObject(trees, name)
}
def isInterface(mods: HasFlags, body: List[Tree]) =
mods.hasTraitFlag && (body forall isInterfaceMember)
def isAllowedInAnyTrait(stat: Tree): Boolean = stat match {
case _: ValDef => false
case Import(_, _) | EmptyTree => true
case _: DefTree => true
case _ => false
}
}
|