aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/NameInfos.scala
blob: 4bbc5bbcfc421fd60baf03f75edb5e8e0ec820aa (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
package dotty.tools.dotc
package core

import Names._

/** Additional info associated with a name. At a minimum its kind and
 *  a way to turn it into a string.
 */
abstract class NameInfo {
  def kind: NameInfo.Kind
  def oneOfAKind = true
  def mkString(underlying: TermName): String
}

object NameInfo {

  type Kind = Int

  val TermNameKind = 0
  val QualifiedKind = 1

  /** TermNames have the lowest possible kind */
  val TermName = new NameInfo {
    def kind = 0
    def mkString(underlying: TermName) = underlying.toString // will cause an unsupptored exception
  }

  case class Qualified(name: TermName) extends NameInfo {
    def kind = 1
    override def oneOfAKind = false
    def mkString(underlying: TermName) = s"$underlying.$name"
  }

  val ModuleClass = new NameInfo {
    def kind = 10
    def mkString(underlying: TermName) = underlying + "$"
  }

}