summaryrefslogtreecommitdiff
path: root/sources/scalac/checkers/CheckNames.java
blob: a129aa02369f301062d2da9bc909761b2c9a5b99 (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
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package scalac.checkers;

import scalac.ast.Tree;
import scalac.util.Name;
import scalac.util.Debug;
import scalac.symtab.Symbol;

/**
 * Check that the of symbols are of the appropriate kind
 *
 * @author Nikolay Mihaylov
 * @version 1.0
 */

public class CheckNames extends Checker {

    public CheckNames(scalac.Global global) {
	super(global);
    }

    public void check(Tree tree) {
	switch (tree) {
	case ClassDef(_, Name name, _, _, _, _):
	    verify(tree,
		   name.isTypeName(),
		   "name kinds",
		   "class " + Debug.show(tree.symbol()) +
		   "should have a type name");

	    Symbol constr = tree.symbol().constructor();
	    verify(tree,
		   constr.name.isConstrName(),
		   "name kinds",
		   "the class constructor " + Debug.show(constr)
		   + " should have a constructor name");
	    break;
	}
    }
}