liufengyun / gestalt

gestalt : portable and solid macros for Scala
https://github.com/scalacenter/macros
31 stars 3 forks source link

fix #48: implement and test initial semantic API #52

Closed liufengyun closed 7 years ago

liufengyun commented 7 years ago

Fix #48: Implement first set of semantic APIs.

  /** are the two types equal? */
  def =:=(tp1: Type, tp2: Type): Boolean

  /** is `tp1` a subtype of `tp2` */
  def <:<(tp1: Type, tp2: Type): Boolean

  /** returning a type referring to a type definition */
  def typeRef(path: String): Type

  /** returning a type referring to a value definition */
  def termRef(path: String): Type

  /** type associated with the tree */
  def typeOf(tree: Tree): Type

  /** does the type refer to a case class? */
  def isCaseClass(tp: Type): Boolean

  /** val fields of a case class Type -- only the ones declared in primary constructor */
  def caseFields(tp: Type): Seq[Member]

  /* field with the given name */
  def field(tp: Type, name: String): Option[Member]

  /** name of a member */
  def name(mem: Member): String

  /** type of a member with respect to a prefix */
  def asSeenFrom(mem: Member, prefix: Type): Type