diff options
author | Martin Odersky <odersky@gmail.com> | 2011-07-22 17:19:07 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-07-22 17:19:07 +0000 |
commit | f9f164d3c71aee897e7885e4c991866bd1c0c339 (patch) | |
tree | abf088eb7ce513a7c8d1d4ebeda20158859693f7 /src/compiler | |
parent | fb2e30e4728e6378136f2858da49a1b87ed7c60d (diff) | |
download | scala-f9f164d3c71aee897e7885e4c991866bd1c0c339.tar.gz scala-f9f164d3c71aee897e7885e4c991866bd1c0c339.tar.bz2 scala-f9f164d3c71aee897e7885e4c991866bd1c0c339.zip |
Reflection refactoring.ō
Diffstat (limited to 'src/compiler')
17 files changed, 146 insertions, 2002 deletions
diff --git a/src/compiler/scala/reflect/api/AnnotationInfos.scala b/src/compiler/scala/reflect/api/AnnotationInfos.scala deleted file mode 100755 index 96a65606e5..0000000000 --- a/src/compiler/scala/reflect/api/AnnotationInfos.scala +++ /dev/null @@ -1,42 +0,0 @@ -package scala.reflect -package api - -trait AnnotationInfos { self: Universe => - - type AnnotationInfo <: AnyRef - val AnnotationInfo: AnnotationInfoExtractor - - abstract class AnnotationInfoExtractor { - def apply(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)]): AnnotationInfo - def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])] - } - - type ClassfileAnnotArg <: AnyRef - implicit def classfileAnnotArgManifest: ClassManifest[ClassfileAnnotArg] // need a precise manifest to pass to UnPickle's toArray call - - type LiteralAnnotArg <: ClassfileAnnotArg - val LiteralAnnotArg: LiteralAnnotArgExtractor - - type ArrayAnnotArg <: ClassfileAnnotArg - val ArrayAnnotArg: ArrayAnnotArgExtractor - - type NestedAnnotArg <: ClassfileAnnotArg - val NestedAnnotArg: NestedAnnotArgExtractor - - abstract class LiteralAnnotArgExtractor { - def apply(const: Constant): LiteralAnnotArg - def unapply(arg: LiteralAnnotArg): Option[Constant] - } - - abstract class ArrayAnnotArgExtractor { - def apply(const: Array[ClassfileAnnotArg]): ArrayAnnotArg - def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]] - } - - abstract class NestedAnnotArgExtractor { - def apply(anninfo: AnnotationInfo): NestedAnnotArg - def unapply(arg: NestedAnnotArg): Option[AnnotationInfo] - } -} - - diff --git a/src/compiler/scala/reflect/api/Constants.scala b/src/compiler/scala/reflect/api/Constants.scala deleted file mode 100755 index 42a0fa8a27..0000000000 --- a/src/compiler/scala/reflect/api/Constants.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package api - -import java.lang.Integer.toOctalString -import annotation.switch - -trait Constants { - self: Universe => - - abstract class AbsConstant { - val value: Any - def tpe: Type - def isNaN: Boolean - - def booleanValue: Boolean - def byteValue: Byte - def shortValue: Short - def charValue: Char - def intValue: Int - def longValue: Long - def floatValue: Float - def doubleValue: Double - def stringValue: String - def typeValue: Type - def symbolValue: Symbol - - def convertTo(pt: Type): Constant - } - - type Constant <: AbsConstant - - val Constant: ConstantExtractor - - abstract class ConstantExtractor { - def apply(const: Any): Constant - def unapply(arg: Constant): Option[Any] - } -} diff --git a/src/compiler/scala/reflect/api/Mirror.scala b/src/compiler/scala/reflect/api/Mirror.scala deleted file mode 100644 index b6a9304617..0000000000 --- a/src/compiler/scala/reflect/api/Mirror.scala +++ /dev/null @@ -1,35 +0,0 @@ -package scala.reflect -package api - -/** A mirror establishes connections of - * runtime entities such as class names and object instances - * with a refexive universe. - */ -trait Mirror extends Universe { - - /** The Scala class symbol that has given fully qualified name - * @param name The fully qualified name of the class to be returned - * @throws java.lang.ClassNotFoundException if no class wiht that name exists - * to do: throws anything else? - */ - def classWithName(name: String): Symbol - - /** The Scala class symbol corresponding to the runtime class of given object - * @param The object from which the class is returned - * @throws ? - */ - def getClass(obj: AnyRef): Symbol - - /** The Scala type corresponding to the runtime type of given object. - * If the underlying class is parameterized, this will be an existential type, - * with unknown type arguments. - * - * @param The object from which the type is returned - * @throws ? - */ - def getType(obj: AnyRef): Type - - def getValue(receiver: AnyRef, field: Symbol): Any - def setValue(receiver: AnyRef, field: Symbol, value: Any): Unit - def invoke(receiver: AnyRef, meth: Symbol, args: Any*): Any -}
\ No newline at end of file diff --git a/src/compiler/scala/reflect/api/Modifier.scala b/src/compiler/scala/reflect/api/Modifier.scala deleted file mode 100644 index 5992e658c6..0000000000 --- a/src/compiler/scala/reflect/api/Modifier.scala +++ /dev/null @@ -1,11 +0,0 @@ -package scala.reflect.api - -object Modifier extends Enumeration { - - val `protected`, `private`, `override`, `abstract`, `final`, - `sealed`, `implicit`, `lazy`, `case`, `trait`, - deferred, interface, mutable, parameter, covariant, contravariant, - preSuper, abstractOverride, local, java, static, caseAccessor, - defaultParameter, defaultInit, paramAccessor, bynameParameter = Value - -}
\ No newline at end of file diff --git a/src/compiler/scala/reflect/api/Names.scala b/src/compiler/scala/reflect/api/Names.scala deleted file mode 100755 index 0ba5ad28f0..0000000000 --- a/src/compiler/scala/reflect/api/Names.scala +++ /dev/null @@ -1,22 +0,0 @@ -package scala.reflect -package api - -trait Names { - - type Name >: Null <: AbsName - type TypeName <: Name - type TermName <: Name - - abstract class AbsName { - def isTermName: Boolean - def isTypeName: Boolean - def toTermName: TermName - def toTypeName: TypeName - } - - def newTermName(s: String): TermName - def newTypeName(s: String): TypeName - - def EmptyTermName: TermName = newTermName("") - def EmptyTypeName: TypeName = EmptyTermName.toTypeName -} diff --git a/src/compiler/scala/reflect/api/Positions.scala b/src/compiler/scala/reflect/api/Positions.scala deleted file mode 100644 index 181e7c1525..0000000000 --- a/src/compiler/scala/reflect/api/Positions.scala +++ /dev/null @@ -1,9 +0,0 @@ -package scala.reflect -package api - -trait Positions { - - type Position - val NoPosition: Position - -}
\ No newline at end of file diff --git a/src/compiler/scala/reflect/api/Scopes.scala b/src/compiler/scala/reflect/api/Scopes.scala deleted file mode 100755 index d4e4e24f29..0000000000 --- a/src/compiler/scala/reflect/api/Scopes.scala +++ /dev/null @@ -1,11 +0,0 @@ -package scala.reflect -package api - -trait Scopes { self: Universe => - - type Scope <: Iterable[Symbol] - - def newScope(): Scope -} - - diff --git a/src/compiler/scala/reflect/api/StandardDefinitions.scala b/src/compiler/scala/reflect/api/StandardDefinitions.scala deleted file mode 100755 index 6b480ab83d..0000000000 --- a/src/compiler/scala/reflect/api/StandardDefinitions.scala +++ /dev/null @@ -1,67 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package api - -trait StandardDefinitions { self: Universe => - - val definitions: AbsDefinitions - - abstract class AbsDefinitions { - // outer packages and their classes - // Under consideration - // def RootPackage: Symbol - - def RootClass: Symbol - def EmptyPackage: Symbol - def EmptyPackageClass: Symbol - - def ScalaPackage: Symbol - def ScalaPackageClass: Symbol - - // top types - def AnyClass : Symbol - def AnyValClass: Symbol - def AnyRefClass: Symbol - def ObjectClass: Symbol - - // bottom types - def NullClass : Symbol - def NothingClass: Symbol - - // the scala value classes - def UnitClass : Symbol - def ByteClass : Symbol - def ShortClass : Symbol - def CharClass : Symbol - def IntClass : Symbol - def LongClass : Symbol - def FloatClass : Symbol - def DoubleClass : Symbol - def BooleanClass: Symbol - - // fundamental reference classes - def SymbolClass : Symbol - def StringClass : Symbol - def ClassClass : Symbol - - // fundamental modules - def PredefModule: Symbol - - // fundamental type constructions - def ClassType(arg: Type): Type - - /** The string representation used by the given type in the VM. - */ - def signature(tp: Type): String - - /** Is symbol one of the value classes? */ - def isValueClass(sym: Symbol): Boolean - - /** Is symbol one of the numeric value classes? */ - def isNumericValueClass(sym: Symbol): Boolean - } -} diff --git a/src/compiler/scala/reflect/api/Symbols.scala b/src/compiler/scala/reflect/api/Symbols.scala deleted file mode 100755 index c841417209..0000000000 --- a/src/compiler/scala/reflect/api/Symbols.scala +++ /dev/null @@ -1,158 +0,0 @@ -package scala.reflect -package api - -trait Symbols { self: Universe => - - type Symbol >: Null <: AbsSymbol - - abstract class AbsSymbol { this: Symbol => - - /** The modifiers of this symbol - */ - def allModifiers: Set[Modifier.Value] - - /** Does this symbol have given modifier? - */ - def hasModifier(mod: Modifier.Value): Boolean - - /** The owner of this symbol. - */ - def owner: Symbol - - /** The name of the symbol as a member of the `Name` type. - */ - def name: Name - - /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. - */ - def encodedName: String - - /** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`. - */ - def decodedName: String - - /** The encoded full path name of this symbol, where outer names and inner names - * are separated by periods. - */ - def fullName: String - - /** - * Set when symbol has a modifier of the form private[X], NoSymbol otherwise. - * - * Access level encoding: there are three scala flags (PRIVATE, PROTECTED, - * and LOCAL) which combine with value privateWithin (the "foo" in private[foo]) - * to define from where an entity can be accessed. The meanings are as follows: - * - * PRIVATE access restricted to class only. - * PROTECTED access restricted to class and subclasses only. - * LOCAL can only be set in conjunction with PRIVATE or PROTECTED. - * Further restricts access to the same object instance. - * - * In addition, privateWithin can be used to set a visibility barrier. - * When set, everything contained in the named enclosing package or class - * has access. It is incompatible with PRIVATE or LOCAL, but is additive - * with PROTECTED (i.e. if either the flags or privateWithin allow access, - * then it is allowed.) - * - * The java access levels translate as follows: - * - * java private: hasFlag(PRIVATE) && !hasAccessBoundary - * java package: !hasFlag(PRIVATE | PROTECTED) && (privateWithin == enclosing package) - * java protected: hasFlag(PROTECTED) && (privateWithin == enclosing package) - * java public: !hasFlag(PRIVATE | PROTECTED) && !hasAccessBoundary - */ - def privateWithin: Symbol - - /** Whether this symbol has a "privateWithin" visibility barrier attached. - */ - def hasAccessBoundary: Boolean - - /** A list of annotations attached to this Symbol. - */ - def annotations: List[self.AnnotationInfo] - - /** The type of the symbol - */ - def tpe: Type - - /** The info of the symbol. This is like tpe, except for class symbols where the `info` - * describes the contents of the class whereas the `tpe` is a reference to the class. - */ - def info: Type - - /** If this symbol is a class or trait, its self type, otherwise the type of the symbol itse;lf - */ - def typeOfThis: Type - - /** For a module class its linked class, for a plain class - * the module class of its linked module. - * For instance - * object Foo - * class Foo - * - * Then object Foo has a `moduleClass` (invisible to the user, the backend calls it Foo$ - * linkedClassOfClass goes from class Foo$ to class Foo, and back. - */ - def linkedClassOfClass: Symbol - - /** The module corresponding to this module class (note that this - * is not updated when a module is cloned), or NoSymbol if this is not a ModuleClass - */ - def sourceModule: Symbol - - /** If symbol is an object definition, it's implied associated class, - * otherwise NoSymbol - */ - def moduleClass: Symbol - - /** The top-level class containing this symbol. */ - def toplevelClass: Symbol - - /** - * If symbol is a lazy val, it's lazy accessor - */ - def lazyAccessor: Symbol - - /** The next enclosing class */ - def enclClass : Symbol - - /** The next enclosing method */ - def enclMethod : Symbol - - def isTerm : Boolean - def isType : Boolean - def isClass : Boolean - def isAliasType : Boolean - def isAbstractType : Boolean - - def isAbstractClass : Boolean - def isBridge : Boolean - def isConcreteClass : Boolean - def isContravariant : Boolean - def isCovariant : Boolean - def isEarlyInitialized : Boolean - def isExistentiallyBound : Boolean - def isImplClass : Boolean - def isLazyAccessor : Boolean - def isMethod : Boolean - def isModule : Boolean - def isModuleClass : Boolean - def isNumericValueClass : Boolean - def isOverloaded : Boolean - def isRefinementClass : Boolean - def isSourceMethod : Boolean - def isTypeParameter : Boolean - def isValueClass : Boolean - def isVarargsMethod : Boolean - - /** Package tests */ - def isPackage : Boolean - def isPackageClass : Boolean - def isRootPackage : Boolean - def isRoot : Boolean - def isEmptyPackage : Boolean - def isEmptyPackageClass: Boolean - } - - val NoSymbol: Symbol -} diff --git a/src/compiler/scala/reflect/api/Trees.scala b/src/compiler/scala/reflect/api/Trees.scala deleted file mode 100644 index 0dbc09c46e..0000000000 --- a/src/compiler/scala/reflect/api/Trees.scala +++ /dev/null @@ -1,1381 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package api - -import java.io.{PrintWriter, StringWriter} -import scala.collection.mutable.ListBuffer - -//import scala.tools.nsc.util.{ FreshNameCreator, HashSet, SourceFile } - -trait Trees /*extends reflect.generic.Trees*/ { self: Universe => - - private[scala] var nodeCount = 0 - - type Modifiers <: AbsModifiers - - /** Hook to define what toString means on a tree - */ - def show(tree: Tree): String - - abstract class AbsModifiers { - def hasModifier(mod: Modifier.Value): Boolean - def allModifiers: Set[Modifier.Value] - def privateWithin: Name // default: EmptyTypeName - def annotations: List[Tree] // default: List() - def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers - } - - def Modifiers(mods: Set[Modifier.Value] = Set(), - privateWithin: Name = EmptyTypeName, - annotations: List[Tree] = List()): Modifiers - - /** Tree is the basis for scala's abstract syntax. The nodes are - * implemented as case classes, and the parameters which initialize - * a given tree are immutable: however Trees have several mutable - * fields which are manipulated in the course of typechecking, - * including pos, symbol, and tpe. - * - * Newly instantiated trees have tpe set to null (though it - * may be set immediately thereafter depending on how it is - * constructed.) When a tree is passed to the typer, typically via - * `typer.typed(tree)`, under normal circumstances the tpe must be - * null or the typer will ignore it. Furthermore, the typer is not - * required to return the same tree it was passed. - * - * Trees can be easily traversed with e.g. foreach on the root node; - * for a more nuanced traversal, subclass Traverser. Transformations - * can be considerably trickier: see the numerous subclasses of - * Transformer found around the compiler. - * - * Copying Trees should be done with care depending on whether - * it need be done lazily or strictly (see LazyTreeCopier and - * StrictTreeCopier) and on whether the contents of the mutable - * fields should be copied. The tree copiers will copy the mutable - * attributes to the new tree; calling Tree#duplicate will copy - * symbol and tpe, but all the positions will be focused. - * - * Trees can be coarsely divided into four mutually exclusive categories: - * - * - TermTrees, representing terms - * - TypTrees, representing types. Note that is `TypTree`, not `TypeTree`. - * - SymTrees, which may represent types or terms. - * - Other Trees, which have none of those as parents. - * - * SymTrees include important nodes Ident and Select, which are - * used as both terms and types; they are distinguishable based on - * whether the Name is a TermName or TypeName. The correct way for - * to test for a type or a term (on any Tree) are the isTerm/isType - * methods on Tree. - * - * "Others" are mostly syntactic or short-lived constructs. Examples - * include CaseDef, which wraps individual match cases: they are - * neither terms nor types, nor do they carry a symbol. Another - * example is Parens, which is eliminated during parsing. - */ - abstract class Tree extends Product { - val id = nodeCount - nodeCount += 1 - - private[this] var rawpos: Position = NoPosition - - def pos = rawpos - def pos_=(pos: Position) = rawpos = pos - def setPos(pos: Position): this.type = { rawpos = pos; this } - - private[this] var rawtpe: Type = _ - - def tpe = rawtpe - def tpe_=(t: Type) = rawtpe = t - - /** Set tpe to give `tp` and return this. - */ - def setType(tp: Type): this.type = { rawtpe = tp; this } - - /** Like `setType`, but if this is a previously empty TypeTree - * that fact is remembered so that resetType will snap back. - */ - def defineType(tp: Type): this.type = setType(tp) - - /** Note that symbol is fixed as null at this level. In SymTrees, - * it is overridden and implemented with a var, initialized to NoSymbol. - * - * Trees which are not SymTrees but which carry symbols do so by - * overriding `def symbol` to forward it elsewhere. Examples: - * - * Super(qual, _) // has qual's symbol - * Apply(fun, args) // has fun's symbol - * TypeApply(fun, args) // has fun's symbol - * AppliedTypeTree(tpt, args) // has tpt's symbol - * TypeTree(tpe) // has tpe's typeSymbol, if tpe != null - * - * Attempting to set the symbol of a Tree which does not support - * it will induce an exception. - */ - def symbol: Symbol = null - def symbol_=(sym: Symbol) { throw new UnsupportedOperationException("symbol_= inapplicable for " + this) } - def setSymbol(sym: Symbol): this.type = { symbol = sym; this } - - def hasSymbol = false - def isDef = false - def isEmpty = false - - def hasSymbolWhich(f: Symbol => Boolean) = hasSymbol && f(symbol) - - /** The canonical way to test if a Tree represents a term. - */ - def isTerm: Boolean = this match { - case _: TermTree => true - case Bind(name, _) => name.isTermName - case Select(_, name) => name.isTermName - case Ident(name) => name.isTermName - case Annotated(_, arg) => arg.isTerm - case _ => false - } - - /** The canonical way to test if a Tree represents a type. - */ - def isType: Boolean = this match { - case _: TypTree => true - case Bind(name, _) => name.isTypeName - case Select(_, name) => name.isTypeName - case Ident(name) => name.isTypeName - case Annotated(_, arg) => arg.isType - case _ => false - } - - /** Apply `f` to each subtree */ - def foreach(f: Tree => Unit) { new ForeachTreeTraverser(f).traverse(this) } - - /** Find all subtrees matching predicate `p` */ - def filter(f: Tree => Boolean): List[Tree] = { - val ft = new FilterTreeTraverser(f) - ft.traverse(this) - ft.hits.toList - } - - /** Returns optionally first tree (in a preorder traversal) which satisfies predicate `p`, - * or None if none exists. - */ - def find(p: Tree => Boolean): Option[Tree] = { - val ft = new FindTreeTraverser(p) - ft.traverse(this) - ft.result - } - - /** Is there part of this tree which satisfies predicate `p`? */ - def exists(p: Tree => Boolean): Boolean = !find(p).isEmpty - - def equalsStructure(that : Tree) = equalsStructure0(that)(_ eq _) - def equalsStructure0(that: Tree)(f: (Tree,Tree) => Boolean): Boolean = - f(this, that) || ((this.productArity == that.productArity) && { - def equals0(this0: Any, that0: Any): Boolean = (this0, that0) match { - case (x: Tree, y: Tree) => f(x, y) || (x equalsStructure0 y)(f) - case (xs: List[_], ys: List[_]) => (xs corresponds ys)(equals0) - case _ => this0 == that0 - } - def compareOriginals() = (this, that) match { - case (x: TypeTree, y: TypeTree) if x.original != null && y.original != null => - (x.original equalsStructure0 y.original)(f) - case _ => - true - } - - (this.productIterator zip that.productIterator forall { case (x, y) => equals0(x, y) }) && compareOriginals() - }) - - /** The direct child trees of this tree. - * EmptyTrees are always omitted. Lists are flattened. - */ - def children: List[Tree] = { - def subtrees(x: Any): List[Tree] = x match { - case EmptyTree => Nil - case t: Tree => List(t) - case xs: List[_] => xs flatMap subtrees - case _ => Nil - } - productIterator.toList flatMap subtrees - } - - /** Make a copy of this tree, keeping all attributes, - * except that all positions are focused (so nothing - * in this tree will be found when searching by position). - */ - def duplicate: this.type = - duplicateTree(this).asInstanceOf[this.type] - - private[scala] def copyAttrs(tree: Tree): this.type = { - pos = tree.pos - tpe = tree.tpe - if (hasSymbol) symbol = tree.symbol - this - } - - override def toString: String = show(this) - override def hashCode(): Int = System.identityHashCode(this) - override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] - } - - /** A tree for a term. Not all terms are TermTrees; use isTerm - * to reliably identify terms. - */ - trait TermTree extends Tree - - /** A tree for a type. Not all types are TypTrees; use isType - * to reliably identify types. - */ - trait TypTree extends Tree - - /** A tree with a mutable symbol field, initialized to NoSymbol. - */ - trait SymTree extends Tree { - override def hasSymbol = true - override var symbol: Symbol = NoSymbol - } - - /** A tree which references a symbol-carrying entity. - * References one, as opposed to defining one; definitions - * are in DefTrees. - */ - trait RefTree extends SymTree { - def name: Name - } - - /** A tree which defines a symbol-carrying entity. - */ - abstract class DefTree extends SymTree { - def name: Name - override def isDef = true - } - -// ----- tree node alternatives -------------------------------------- - - /** The empty tree */ - case object EmptyTree extends TermTree { - super.tpe_=(NoType) - override def tpe_=(t: Type) = - if (t != NoType) throw new UnsupportedOperationException("tpe_=("+t+") inapplicable for <empty>") - override def isEmpty = true - } - - /** Common base class for all member definitions: types, classes, - * objects, packages, vals and vars, defs. - */ - abstract class MemberDef extends DefTree { - def mods: Modifiers - def keyword: String = this match { - case TypeDef(_, _, _, _) => "type" - case ClassDef(mods, _, _, _) => if (mods hasModifier Modifier.`trait`) "trait" else "class" - case DefDef(_, _, _, _, _, _) => "def" - case ModuleDef(_, _, _) => "object" - case PackageDef(_, _) => "package" - case ValDef(mods, _, _, _) => if (mods hasModifier Modifier.mutable) "var" else "val" - case _ => "" - } - // final def hasFlag(mask: Long): Boolean = mods hasFlag mask - } - - /** A packaging, such as `package pid { stats }` - */ - case class PackageDef(pid: RefTree, stats: List[Tree]) - extends MemberDef { - def name = pid.name - def mods = Modifiers() - } - - /** A common base class for class and object definitions. - */ - abstract class ImplDef extends MemberDef { - def impl: Template - } - - /** A class definition. - */ - case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template) - extends ImplDef - - /** An object definition, e.g. `object Foo`. Internally, objects are - * quite frequently called modules to reduce ambiguity. - */ - case class ModuleDef(mods: Modifiers, name: TermName, impl: Template) - extends ImplDef - - /** A common base class for ValDefs and DefDefs. - */ - abstract class ValOrDefDef extends MemberDef { - def name: TermName - def tpt: Tree - def rhs: Tree - } - - /** A value definition (this includes vars as well, which differ from - * vals only in having the MUTABLE flag set in their Modifiers.) - */ - case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef - - /** A method definition. - */ - case class DefDef(mods: Modifiers, name: TermName, tparams: List[TypeDef], - vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef - - /** An abstract type, a type parameter, or a type alias. - */ - case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree) - extends MemberDef - - /** A labelled expression. Not expressible in language syntax, but - * generated by the compiler to simulate while/do-while loops, and - * also by the pattern matcher. - * - * The label acts much like a nested function, where `params` represents - * the incoming parameters. The symbol given to the LabelDef should have - * a MethodType, as if it were a nested function. - * - * Jumps are apply nodes attributed with a label's symbol. The - * arguments from the apply node will be passed to the label and - * assigned to the Idents. - * - * Forward jumps within a block are allowed. - */ - case class LabelDef(name: TermName, params: List[Ident], rhs: Tree) - extends DefTree with TermTree - - /** Import selector - * - * Representation of an imported name its optional rename and their optional positions - * - * @param name the imported name - * @param namePos its position or -1 if undefined - * @param rename the name the import is renamed to (== name if no renaming) - * @param renamePos the position of the rename or -1 if undefined - */ - case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int) - - /** Import clause - * - * @param expr - * @param selectors - */ - case class Import(expr: Tree, selectors: List[ImportSelector]) - extends SymTree - // The symbol of an Import is an import symbol @see Symbol.newImport - // It's used primarily as a marker to check that the import has been typechecked. - - /** Instantiation template of a class or trait - * - * @param parents - * @param body - */ - case class Template(parents: List[Tree], self: ValDef, body: List[Tree]) - extends SymTree { - // the symbol of a template is a local dummy. @see Symbol.newLocalDummy - // the owner of the local dummy is the enclosing trait or class. - // the local dummy is itself the owner of any local blocks - // For example: - // - // class C { - // def foo // owner is C - // { - // def bar // owner is local dummy - // } - // System.err.println("TEMPLATE: " + parents) - } - - /** Block of expressions (semicolon separated expressions) */ - case class Block(stats: List[Tree], expr: Tree) - extends TermTree - - /** Case clause in a pattern match, eliminated during explicitouter - * (except for occurrences in switch statements) - */ - case class CaseDef(pat: Tree, guard: Tree, body: Tree) - extends Tree - - /** Alternatives of patterns, eliminated by explicitouter, except for - * occurrences in encoded Switch stmt (=remaining Match(CaseDef(...)) - */ - case class Alternative(trees: List[Tree]) - extends TermTree - - /** Repetition of pattern, eliminated by explicitouter */ - case class Star(elem: Tree) - extends TermTree - - /** Bind of a variable to a rhs pattern, eliminated by explicitouter - * - * @param name - * @param body - */ - case class Bind(name: Name, body: Tree) - extends DefTree - - case class UnApply(fun: Tree, args: List[Tree]) - extends TermTree - - /** Array of expressions, needs to be translated in backend, - */ - case class ArrayValue(elemtpt: Tree, elems: List[Tree]) - extends TermTree - - /** Anonymous function, eliminated by analyzer */ - case class Function(vparams: List[ValDef], body: Tree) - extends TermTree with SymTree - // The symbol of a Function is a synthetic value of name nme.ANON_FUN_NAME - // It is the owner of the function's parameters. - - /** Assignment */ - case class Assign(lhs: Tree, rhs: Tree) - extends TermTree - - /** Conditional expression */ - case class If(cond: Tree, thenp: Tree, elsep: Tree) - extends TermTree - - /** - Pattern matching expression (before explicitouter) - * - Switch statements (after explicitouter) - * - * After explicitouter, cases will satisfy the following constraints: - * - * - all guards are `EmptyTree`, - * - all patterns will be either `Literal(Constant(x:Int))` - * or `Alternative(lit|...|lit)` - * - except for an "otherwise" branch, which has pattern - * `Ident(nme.WILDCARD)` - */ - case class Match(selector: Tree, cases: List[CaseDef]) - extends TermTree - - /** Return expression */ - case class Return(expr: Tree) - extends TermTree with SymTree - // The symbol of a Return node is the enclosing method. - - case class Try(block: Tree, catches: List[CaseDef], finalizer: Tree) - extends TermTree - - /** Throw expression */ - case class Throw(expr: Tree) - extends TermTree - - /** Object instantiation - * One should always use factory method below to build a user level new. - * - * @param tpt a class type - */ - case class New(tpt: Tree) extends TermTree - - /** Type annotation, eliminated by explicit outer */ - case class Typed(expr: Tree, tpt: Tree) - extends TermTree - - /** Common base class for Apply and TypeApply. This could in principle - * be a SymTree, but whether or not a Tree is a SymTree isn't used - * to settle any interesting questions, and it would add a useless - * field to all the instances (useless, since GenericApply forwards to - * the underlying fun.) - */ - abstract class GenericApply extends TermTree { - val fun: Tree - val args: List[Tree] - } - - /** Explicit type application. - */ - case class TypeApply(fun: Tree, args: List[Tree]) - extends GenericApply { - override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol) { fun.symbol = sym } - } - - /** Value application */ - case class Apply(fun: Tree, args: List[Tree]) - extends GenericApply { - override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol) { fun.symbol = sym } - } - - class ApplyToImplicitArgs(fun: Tree, args: List[Tree]) extends Apply(fun, args) - - class ApplyImplicitView(fun: Tree, args: List[Tree]) extends Apply(fun, args) - - /** Dynamic value application. - * In a dynamic application q.f(as) - * - q is stored in qual - * - as is stored in args - * - f is stored as the node's symbol field. - */ - case class ApplyDynamic(qual: Tree, args: List[Tree]) - extends TermTree with SymTree - // The symbol of an ApplyDynamic is the function symbol of `qual`, or NoSymbol, if there is none. - - /** Super reference, qual = corresponding this reference */ - case class Super(qual: Tree, mix: TypeName) extends TermTree { - // The symbol of a Super is the class _from_ which the super reference is made. - // For instance in C.super(...), it would be C. - override def symbol: Symbol = qual.symbol - override def symbol_=(sym: Symbol) { qual.symbol = sym } - } - - /** Self reference */ - case class This(qual: TypeName) - extends TermTree with SymTree - // The symbol of a This is the class to which the this refers. - // For instance in C.this, it would be C. - - /** Designator <qualifier> . <name> */ - case class Select(qualifier: Tree, name: Name) - extends RefTree - - /** Identifier <name> */ - case class Ident(name: Name) extends RefTree { } - - class BackQuotedIdent(name: Name) extends Ident(name) - - /** Literal */ - case class Literal(value: Constant) - extends TermTree { - assert(value ne null) - } - - def Literal(value: Any): Literal = - Literal(Constant(value)) - - /** A tree that has an annotation attached to it. Only used for annotated types and - * annotation ascriptions, annotations on definitions are stored in the Modifiers. - * Eliminated by typechecker (typedAnnotated), the annotations are then stored in - * an AnnotatedType. - */ - case class Annotated(annot: Tree, arg: Tree) extends Tree - - /** Singleton type, eliminated by RefCheck */ - case class SingletonTypeTree(ref: Tree) - extends TypTree - - /** Type selection <qualifier> # <name>, eliminated by RefCheck */ - case class SelectFromTypeTree(qualifier: Tree, name: TypeName) - extends TypTree with RefTree - - /** Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck */ - case class CompoundTypeTree(templ: Template) - extends TypTree - - /** Applied type <tpt> [ <args> ], eliminated by RefCheck */ - case class AppliedTypeTree(tpt: Tree, args: List[Tree]) - extends TypTree { - override def symbol: Symbol = tpt.symbol - override def symbol_=(sym: Symbol) { tpt.symbol = sym } - } - - case class TypeBoundsTree(lo: Tree, hi: Tree) - extends TypTree - - case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree]) - extends TypTree - - /** A synthetic tree holding an arbitrary type. Not to be confused with - * with TypTree, the trait for trees that are only used for type trees. - * TypeTree's are inserted in several places, but most notably in - * `RefCheck`, where the arbitrary type trees are all replaced by - * TypeTree's. */ - case class TypeTree() extends TypTree { - private var orig: Tree = null - private[scala] var wasEmpty: Boolean = false - - override def symbol = if (tpe == null) null else tpe.typeSymbol - override def isEmpty = (tpe eq null) || tpe == NoType - - def original: Tree = orig - def setOriginal(tree: Tree): this.type = { - def followOriginal(t: Tree): Tree = t match { - case tt: TypeTree => followOriginal(tt.original) - case t => t - } - - orig = followOriginal(tree); setPos(tree.pos); - this - } - - override def defineType(tp: Type): this.type = { - wasEmpty = isEmpty - setType(tp) - } - } - - def TypeTree(tp: Type): TypeTree = TypeTree() setType tp - - // ------ traversers, copiers, and transformers --------------------------------------------- - - val treeCopy = newLazyTreeCopier - - class Traverser { - protected var currentOwner: Symbol = definitions.RootClass - - def traverse(tree: Tree): Unit = tree match { - case EmptyTree => - ; - case PackageDef(pid, stats) => - traverse(pid) - atOwner(tree.symbol.moduleClass) { - traverseTrees(stats) - } - case ClassDef(mods, name, tparams, impl) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverse(impl) - } - case ModuleDef(mods, name, impl) => - atOwner(tree.symbol.moduleClass) { - traverseTrees(mods.annotations); traverse(impl) - } - case ValDef(mods, name, tpt, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverse(tpt); traverse(rhs) - } - case DefDef(mods, name, tparams, vparamss, tpt, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverseTreess(vparamss); traverse(tpt); traverse(rhs) - } - case TypeDef(mods, name, tparams, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverse(rhs) - } - case LabelDef(name, params, rhs) => - traverseTrees(params); traverse(rhs) - case Import(expr, selectors) => - traverse(expr) - case Annotated(annot, arg) => - traverse(annot); traverse(arg) - case Template(parents, self, body) => - traverseTrees(parents) - if (!self.isEmpty) traverse(self) - traverseStats(body, tree.symbol) - case Block(stats, expr) => - traverseTrees(stats); traverse(expr) - case CaseDef(pat, guard, body) => - traverse(pat); traverse(guard); traverse(body) - case Alternative(trees) => - traverseTrees(trees) - case Star(elem) => - traverse(elem) - case Bind(name, body) => - traverse(body) - case UnApply(fun, args) => - traverse(fun); traverseTrees(args) - case ArrayValue(elemtpt, trees) => - traverse(elemtpt); traverseTrees(trees) - case Function(vparams, body) => - atOwner(tree.symbol) { - traverseTrees(vparams); traverse(body) - } - case Assign(lhs, rhs) => - traverse(lhs); traverse(rhs) - case If(cond, thenp, elsep) => - traverse(cond); traverse(thenp); traverse(elsep) - case Match(selector, cases) => - traverse(selector); traverseTrees(cases) - case Return(expr) => - traverse(expr) - case Try(block, catches, finalizer) => - traverse(block); traverseTrees(catches); traverse(finalizer) - case Throw(expr) => - traverse(expr) - case New(tpt) => - traverse(tpt) - case Typed(expr, tpt) => - traverse(expr); traverse(tpt) - case TypeApply(fun, args) => - traverse(fun); traverseTrees(args) - case Apply(fun, args) => - traverse(fun); traverseTrees(args) - case ApplyDynamic(qual, args) => - traverse(qual); traverseTrees(args) - case Super(qual, _) => - traverse(qual) - case This(_) => - ; - case Select(qualifier, selector) => - traverse(qualifier) - case Ident(_) => - ; - case Literal(_) => - ; - case TypeTree() => - ; - case SingletonTypeTree(ref) => - traverse(ref) - case SelectFromTypeTree(qualifier, selector) => - traverse(qualifier) - case CompoundTypeTree(templ) => - traverse(templ) - case AppliedTypeTree(tpt, args) => - traverse(tpt); traverseTrees(args) - case TypeBoundsTree(lo, hi) => - traverse(lo); traverse(hi) - case ExistentialTypeTree(tpt, whereClauses) => - traverse(tpt); traverseTrees(whereClauses) - case _ => xtraverse(this, tree) - } - - def traverseTrees(trees: List[Tree]) { - trees foreach traverse - } - def traverseTreess(treess: List[List[Tree]]) { - treess foreach traverseTrees - } - def traverseStats(stats: List[Tree], exprOwner: Symbol) { - stats foreach (stat => - if (exprOwner != currentOwner) atOwner(exprOwner)(traverse(stat)) - else traverse(stat) - ) - } - - def atOwner(owner: Symbol)(traverse: => Unit) { - val prevOwner = currentOwner - currentOwner = owner - traverse - currentOwner = prevOwner - } - - /** Leave apply available in the generic traverser to do something else. - */ - def apply[T <: Tree](tree: T): T = { traverse(tree); tree } - } - - protected def xtraverse(traverser: Traverser, tree: Tree): Unit = throw new MatchError(tree) - - // to be implemented in subclasses: - type TreeCopier <: TreeCopierOps - def newStrictTreeCopier: TreeCopier - def newLazyTreeCopier: TreeCopier - - trait TreeCopierOps { - def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template): ClassDef - def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]): PackageDef - def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template): ModuleDef - def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree): ValDef - def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef - def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree): TypeDef - def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree): LabelDef - def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]): Import - def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]): Template - def Block(tree: Tree, stats: List[Tree], expr: Tree): Block - def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree): CaseDef - def Alternative(tree: Tree, trees: List[Tree]): Alternative - def Star(tree: Tree, elem: Tree): Star - def Bind(tree: Tree, name: Name, body: Tree): Bind - def UnApply(tree: Tree, fun: Tree, args: List[Tree]): UnApply - def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]): ArrayValue - def Function(tree: Tree, vparams: List[ValDef], body: Tree): Function - def Assign(tree: Tree, lhs: Tree, rhs: Tree): Assign - def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree): If - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]): Match - def Return(tree: Tree, expr: Tree): Return - def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree): Try - def Throw(tree: Tree, expr: Tree): Throw - def New(tree: Tree, tpt: Tree): New - def Typed(tree: Tree, expr: Tree, tpt: Tree): Typed - def TypeApply(tree: Tree, fun: Tree, args: List[Tree]): TypeApply - def Apply(tree: Tree, fun: Tree, args: List[Tree]): Apply - def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]): ApplyDynamic - def Super(tree: Tree, qual: Tree, mix: TypeName): Super - def This(tree: Tree, qual: Name): This - def Select(tree: Tree, qualifier: Tree, selector: Name): Select - def Ident(tree: Tree, name: Name): Ident - def Literal(tree: Tree, value: Constant): Literal - def TypeTree(tree: Tree): TypeTree - def Annotated(tree: Tree, annot: Tree, arg: Tree): Annotated - def SingletonTypeTree(tree: Tree, ref: Tree): SingletonTypeTree - def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name): SelectFromTypeTree - def CompoundTypeTree(tree: Tree, templ: Template): CompoundTypeTree - def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]): AppliedTypeTree - def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree): TypeBoundsTree - def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree - } - - class StrictTreeCopier extends TreeCopierOps { - def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template) = - new ClassDef(mods, name.toTypeName, tparams, impl).copyAttrs(tree) - def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]) = - new PackageDef(pid, stats).copyAttrs(tree) - def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template) = - new ModuleDef(mods, name.toTermName, impl).copyAttrs(tree) - def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree) = - new ValDef(mods, name.toTermName, tpt, rhs).copyAttrs(tree) - def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) = - new DefDef(mods, name.toTermName, tparams, vparamss, tpt, rhs).copyAttrs(tree) - def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree) = - new TypeDef(mods, name.toTypeName, tparams, rhs).copyAttrs(tree) - def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree) = - new LabelDef(name.toTermName, params, rhs).copyAttrs(tree) - def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]) = - new Import(expr, selectors).copyAttrs(tree) - def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]) = - new Template(parents, self, body).copyAttrs(tree) - def Block(tree: Tree, stats: List[Tree], expr: Tree) = - new Block(stats, expr).copyAttrs(tree) - def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree) = - new CaseDef(pat, guard, body).copyAttrs(tree) - def Alternative(tree: Tree, trees: List[Tree]) = - new Alternative(trees).copyAttrs(tree) - def Star(tree: Tree, elem: Tree) = - new Star(elem).copyAttrs(tree) - def Bind(tree: Tree, name: Name, body: Tree) = - new Bind(name, body).copyAttrs(tree) - def UnApply(tree: Tree, fun: Tree, args: List[Tree]) = - new UnApply(fun, args).copyAttrs(tree) - def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]) = - new ArrayValue(elemtpt, trees).copyAttrs(tree) - def Function(tree: Tree, vparams: List[ValDef], body: Tree) = - new Function(vparams, body).copyAttrs(tree) - def Assign(tree: Tree, lhs: Tree, rhs: Tree) = - new Assign(lhs, rhs).copyAttrs(tree) - def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree) = - new If(cond, thenp, elsep).copyAttrs(tree) - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]) = - new Match(selector, cases).copyAttrs(tree) - def Return(tree: Tree, expr: Tree) = - new Return(expr).copyAttrs(tree) - def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree) = - new Try(block, catches, finalizer).copyAttrs(tree) - def Throw(tree: Tree, expr: Tree) = - new Throw(expr).copyAttrs(tree) - def New(tree: Tree, tpt: Tree) = - new New(tpt).copyAttrs(tree) - def Typed(tree: Tree, expr: Tree, tpt: Tree) = - new Typed(expr, tpt).copyAttrs(tree) - def TypeApply(tree: Tree, fun: Tree, args: List[Tree]) = - new TypeApply(fun, args).copyAttrs(tree) - def Apply(tree: Tree, fun: Tree, args: List[Tree]) = - (tree match { - case _: ApplyToImplicitArgs => new ApplyToImplicitArgs(fun, args) - case _: ApplyImplicitView => new ApplyImplicitView(fun, args) - case _ => new Apply(fun, args) - }).copyAttrs(tree) - def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]) = - new ApplyDynamic(qual, args).copyAttrs(tree) - def Super(tree: Tree, qual: Tree, mix: TypeName) = - new Super(qual, mix).copyAttrs(tree) - def This(tree: Tree, qual: Name) = - new This(qual.toTypeName).copyAttrs(tree) - def Select(tree: Tree, qualifier: Tree, selector: Name) = - new Select(qualifier, selector).copyAttrs(tree) - def Ident(tree: Tree, name: Name) = - new Ident(name).copyAttrs(tree) - def Literal(tree: Tree, value: Constant) = - new Literal(value).copyAttrs(tree) - def TypeTree(tree: Tree) = - new TypeTree().copyAttrs(tree) - def Annotated(tree: Tree, annot: Tree, arg: Tree) = - new Annotated(annot, arg).copyAttrs(tree) - def SingletonTypeTree(tree: Tree, ref: Tree) = - new SingletonTypeTree(ref).copyAttrs(tree) - def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name) = - new SelectFromTypeTree(qualifier, selector.toTypeName).copyAttrs(tree) - def CompoundTypeTree(tree: Tree, templ: Template) = - new CompoundTypeTree(templ).copyAttrs(tree) - def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]) = - new AppliedTypeTree(tpt, args).copyAttrs(tree) - def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree) = - new TypeBoundsTree(lo, hi).copyAttrs(tree) - def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) = - new ExistentialTypeTree(tpt, whereClauses).copyAttrs(tree) - } - - class LazyTreeCopier extends TreeCopierOps { - val treeCopy: TreeCopier = newStrictTreeCopier - def ClassDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template) = tree match { - case t @ ClassDef(mods0, name0, tparams0, impl0) - if (mods0 == mods) && (name0 == name) && (tparams0 == tparams) && (impl0 == impl) => t - case _ => treeCopy.ClassDef(tree, mods, name, tparams, impl) - } - def PackageDef(tree: Tree, pid: RefTree, stats: List[Tree]) = tree match { - case t @ PackageDef(pid0, stats0) - if (pid0 == pid) && (stats0 == stats) => t - case _ => treeCopy.PackageDef(tree, pid, stats) - } - def ModuleDef(tree: Tree, mods: Modifiers, name: Name, impl: Template) = tree match { - case t @ ModuleDef(mods0, name0, impl0) - if (mods0 == mods) && (name0 == name) && (impl0 == impl) => t - case _ => treeCopy.ModuleDef(tree, mods, name, impl) - } - def ValDef(tree: Tree, mods: Modifiers, name: Name, tpt: Tree, rhs: Tree) = tree match { - case t @ ValDef(mods0, name0, tpt0, rhs0) - if (mods0 == mods) && (name0 == name) && (tpt0 == tpt) && (rhs0 == rhs) => t - case _ => treeCopy.ValDef(tree, mods, name, tpt, rhs) - } - def DefDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) = tree match { - case t @ DefDef(mods0, name0, tparams0, vparamss0, tpt0, rhs0) - if (mods0 == mods) && (name0 == name) && (tparams0 == tparams) && - (vparamss0 == vparamss) && (tpt0 == tpt) && (rhs == rhs0) => t - case _ => treeCopy.DefDef(tree, mods, name, tparams, vparamss, tpt, rhs) - } - def TypeDef(tree: Tree, mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree) = tree match { - case t @ TypeDef(mods0, name0, tparams0, rhs0) - if (mods0 == mods) && (name0 == name) && (tparams0 == tparams) && (rhs0 == rhs) => t - case _ => treeCopy.TypeDef(tree, mods, name, tparams, rhs) - } - def LabelDef(tree: Tree, name: Name, params: List[Ident], rhs: Tree) = tree match { - case t @ LabelDef(name0, params0, rhs0) - if (name0 == name) && (params0 == params) && (rhs0 == rhs) => t - case _ => treeCopy.LabelDef(tree, name, params, rhs) - } - def Import(tree: Tree, expr: Tree, selectors: List[ImportSelector]) = tree match { - case t @ Import(expr0, selectors0) - if (expr0 == expr) && (selectors0 == selectors) => t - case _ => treeCopy.Import(tree, expr, selectors) - } - def Template(tree: Tree, parents: List[Tree], self: ValDef, body: List[Tree]) = tree match { - case t @ Template(parents0, self0, body0) - if (parents0 == parents) && (self0 == self) && (body0 == body) => t - case _ => treeCopy.Template(tree, parents, self, body) - } - def Block(tree: Tree, stats: List[Tree], expr: Tree) = tree match { - case t @ Block(stats0, expr0) - if ((stats0 == stats) && (expr0 == expr)) => t - case _ => treeCopy.Block(tree, stats, expr) - } - def CaseDef(tree: Tree, pat: Tree, guard: Tree, body: Tree) = tree match { - case t @ CaseDef(pat0, guard0, body0) - if (pat0 == pat) && (guard0 == guard) && (body0 == body) => t - case _ => treeCopy.CaseDef(tree, pat, guard, body) - } - def Alternative(tree: Tree, trees: List[Tree]) = tree match { - case t @ Alternative(trees0) - if trees0 == trees => t - case _ => treeCopy.Alternative(tree, trees) - } - def Star(tree: Tree, elem: Tree) = tree match { - case t @ Star(elem0) - if elem0 == elem => t - case _ => treeCopy.Star(tree, elem) - } - def Bind(tree: Tree, name: Name, body: Tree) = tree match { - case t @ Bind(name0, body0) - if (name0 == name) && (body0 == body) => t - case _ => treeCopy.Bind(tree, name, body) - } - def UnApply(tree: Tree, fun: Tree, args: List[Tree]) = tree match { - case t @ UnApply(fun0, args0) - if (fun0 == fun) && (args0 == args) => t - case _ => treeCopy.UnApply(tree, fun, args) - } - def ArrayValue(tree: Tree, elemtpt: Tree, trees: List[Tree]) = tree match { - case t @ ArrayValue(elemtpt0, trees0) - if (elemtpt0 == elemtpt) && (trees0 == trees) => t - case _ => treeCopy.ArrayValue(tree, elemtpt, trees) - } - def Function(tree: Tree, vparams: List[ValDef], body: Tree) = tree match { - case t @ Function(vparams0, body0) - if (vparams0 == vparams) && (body0 == body) => t - case _ => treeCopy.Function(tree, vparams, body) - } - def Assign(tree: Tree, lhs: Tree, rhs: Tree) = tree match { - case t @ Assign(lhs0, rhs0) - if (lhs0 == lhs) && (rhs0 == rhs) => t - case _ => treeCopy.Assign(tree, lhs, rhs) - } - def If(tree: Tree, cond: Tree, thenp: Tree, elsep: Tree) = tree match { - case t @ If(cond0, thenp0, elsep0) - if (cond0 == cond) && (thenp0 == thenp) && (elsep0 == elsep) => t - case _ => treeCopy.If(tree, cond, thenp, elsep) - } - def Match(tree: Tree, selector: Tree, cases: List[CaseDef]) = tree match { - case t @ Match(selector0, cases0) - if (selector0 == selector) && (cases0 == cases) => t - case _ => treeCopy.Match(tree, selector, cases) - } - def Return(tree: Tree, expr: Tree) = tree match { - case t @ Return(expr0) - if expr0 == expr => t - case _ => treeCopy.Return(tree, expr) - } - def Try(tree: Tree, block: Tree, catches: List[CaseDef], finalizer: Tree) = tree match { - case t @ Try(block0, catches0, finalizer0) - if (block0 == block) && (catches0 == catches) && (finalizer0 == finalizer) => t - case _ => treeCopy.Try(tree, block, catches, finalizer) - } - def Throw(tree: Tree, expr: Tree) = tree match { - case t @ Throw(expr0) - if expr0 == expr => t - case _ => treeCopy.Throw(tree, expr) - } - def New(tree: Tree, tpt: Tree) = tree match { - case t @ New(tpt0) - if tpt0 == tpt => t - case _ => treeCopy.New(tree, tpt) - } - def Typed(tree: Tree, expr: Tree, tpt: Tree) = tree match { - case t @ Typed(expr0, tpt0) - if (expr0 == expr) && (tpt0 == tpt) => t - case _ => treeCopy.Typed(tree, expr, tpt) - } - def TypeApply(tree: Tree, fun: Tree, args: List[Tree]) = tree match { - case t @ TypeApply(fun0, args0) - if (fun0 == fun) && (args0 == args) => t - case _ => treeCopy.TypeApply(tree, fun, args) - } - def Apply(tree: Tree, fun: Tree, args: List[Tree]) = tree match { - case t @ Apply(fun0, args0) - if (fun0 == fun) && (args0 == args) => t - case _ => treeCopy.Apply(tree, fun, args) - } - def ApplyDynamic(tree: Tree, qual: Tree, args: List[Tree]) = tree match { - case t @ ApplyDynamic(qual0, args0) - if (qual0 == qual) && (args0 == args) => t - case _ => treeCopy.ApplyDynamic(tree, qual, args) - } - def Super(tree: Tree, qual: Tree, mix: TypeName) = tree match { - case t @ Super(qual0, mix0) - if (qual0 == qual) && (mix0 == mix) => t - case _ => treeCopy.Super(tree, qual, mix) - } - def This(tree: Tree, qual: Name) = tree match { - case t @ This(qual0) - if qual0 == qual => t - case _ => treeCopy.This(tree, qual) - } - def Select(tree: Tree, qualifier: Tree, selector: Name) = tree match { - case t @ Select(qualifier0, selector0) - if (qualifier0 == qualifier) && (selector0 == selector) => t - case _ => treeCopy.Select(tree, qualifier, selector) - } - def Ident(tree: Tree, name: Name) = tree match { - case t @ Ident(name0) - if name0 == name => t - case _ => treeCopy.Ident(tree, name) - } - def Literal(tree: Tree, value: Constant) = tree match { - case t @ Literal(value0) - if value0 == value => t - case _ => treeCopy.Literal(tree, value) - } - def TypeTree(tree: Tree) = tree match { - case t @ TypeTree() => t - case _ => treeCopy.TypeTree(tree) - } - def Annotated(tree: Tree, annot: Tree, arg: Tree) = tree match { - case t @ Annotated(annot0, arg0) - if (annot0==annot) => t - case _ => treeCopy.Annotated(tree, annot, arg) - } - def SingletonTypeTree(tree: Tree, ref: Tree) = tree match { - case t @ SingletonTypeTree(ref0) - if ref0 == ref => t - case _ => treeCopy.SingletonTypeTree(tree, ref) - } - def SelectFromTypeTree(tree: Tree, qualifier: Tree, selector: Name) = tree match { - case t @ SelectFromTypeTree(qualifier0, selector0) - if (qualifier0 == qualifier) && (selector0 == selector) => t - case _ => treeCopy.SelectFromTypeTree(tree, qualifier, selector) - } - def CompoundTypeTree(tree: Tree, templ: Template) = tree match { - case t @ CompoundTypeTree(templ0) - if templ0 == templ => t - case _ => treeCopy.CompoundTypeTree(tree, templ) - } - def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]) = tree match { - case t @ AppliedTypeTree(tpt0, args0) - if (tpt0 == tpt) && (args0 == args) => t - case _ => treeCopy.AppliedTypeTree(tree, tpt, args) - } - def TypeBoundsTree(tree: Tree, lo: Tree, hi: Tree) = tree match { - case t @ TypeBoundsTree(lo0, hi0) - if (lo0 == lo) && (hi0 == hi) => t - case _ => treeCopy.TypeBoundsTree(tree, lo, hi) - } - def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) = tree match { - case t @ ExistentialTypeTree(tpt0, whereClauses0) - if (tpt0 == tpt) && (whereClauses0 == whereClauses) => t - case _ => treeCopy.ExistentialTypeTree(tree, tpt, whereClauses) - } - } - - abstract class Transformer { - val treeCopy: TreeCopier = newLazyTreeCopier - protected var currentOwner: Symbol = definitions.RootClass - protected def currentMethod = currentOwner.enclMethod - protected def currentClass = currentOwner.enclClass - protected def currentPackage = currentOwner.toplevelClass.owner - def transform(tree: Tree): Tree = tree match { - case EmptyTree => - tree - case PackageDef(pid, stats) => - treeCopy.PackageDef( - tree, transform(pid).asInstanceOf[RefTree], - atOwner(tree.symbol.moduleClass) { - transformStats(stats, currentOwner) - } - ) - case ClassDef(mods, name, tparams, impl) => - atOwner(tree.symbol) { - treeCopy.ClassDef(tree, transformModifiers(mods), name, - transformTypeDefs(tparams), transformTemplate(impl)) - } - case ModuleDef(mods, name, impl) => - atOwner(tree.symbol.moduleClass) { - treeCopy.ModuleDef(tree, transformModifiers(mods), - name, transformTemplate(impl)) - } - case ValDef(mods, name, tpt, rhs) => - atOwner(tree.symbol) { - treeCopy.ValDef(tree, transformModifiers(mods), - name, transform(tpt), transform(rhs)) - } - case DefDef(mods, name, tparams, vparamss, tpt, rhs) => - atOwner(tree.symbol) { - treeCopy.DefDef(tree, transformModifiers(mods), name, - transformTypeDefs(tparams), transformValDefss(vparamss), - transform(tpt), transform(rhs)) - } - case TypeDef(mods, name, tparams, rhs) => - atOwner(tree.symbol) { - treeCopy.TypeDef(tree, transformModifiers(mods), name, - transformTypeDefs(tparams), transform(rhs)) - } - case LabelDef(name, params, rhs) => - treeCopy.LabelDef(tree, name, transformIdents(params), transform(rhs)) //bq: Martin, once, atOwner(...) works, also change `LamdaLifter.proxy' - case Import(expr, selectors) => - treeCopy.Import(tree, transform(expr), selectors) - case Template(parents, self, body) => - treeCopy.Template(tree, transformTrees(parents), transformValDef(self), transformStats(body, tree.symbol)) - case Block(stats, expr) => - treeCopy.Block(tree, transformStats(stats, currentOwner), transform(expr)) - case CaseDef(pat, guard, body) => - treeCopy.CaseDef(tree, transform(pat), transform(guard), transform(body)) - case Alternative(trees) => - treeCopy.Alternative(tree, transformTrees(trees)) - case Star(elem) => - treeCopy.Star(tree, transform(elem)) - case Bind(name, body) => - treeCopy.Bind(tree, name, transform(body)) - case UnApply(fun, args) => - treeCopy.UnApply(tree, fun, transformTrees(args)) // bq: see test/.../unapplyContexts2.scala - case ArrayValue(elemtpt, trees) => - treeCopy.ArrayValue(tree, transform(elemtpt), transformTrees(trees)) - case Function(vparams, body) => - atOwner(tree.symbol) { - treeCopy.Function(tree, transformValDefs(vparams), transform(body)) - } - case Assign(lhs, rhs) => - treeCopy.Assign(tree, transform(lhs), transform(rhs)) - case If(cond, thenp, elsep) => - treeCopy.If(tree, transform(cond), transform(thenp), transform(elsep)) - case Match(selector, cases) => - treeCopy.Match(tree, transform(selector), transformCaseDefs(cases)) - case Return(expr) => - treeCopy.Return(tree, transform(expr)) - case Try(block, catches, finalizer) => - treeCopy.Try(tree, transform(block), transformCaseDefs(catches), transform(finalizer)) - case Throw(expr) => - treeCopy.Throw(tree, transform(expr)) - case New(tpt) => - treeCopy.New(tree, transform(tpt)) - case Typed(expr, tpt) => - treeCopy.Typed(tree, transform(expr), transform(tpt)) - case TypeApply(fun, args) => - treeCopy.TypeApply(tree, transform(fun), transformTrees(args)) - case Apply(fun, args) => - treeCopy.Apply(tree, transform(fun), transformTrees(args)) - case ApplyDynamic(qual, args) => - treeCopy.ApplyDynamic(tree, transform(qual), transformTrees(args)) - case Super(qual, mix) => - treeCopy.Super(tree, transform(qual), mix) - case This(qual) => - treeCopy.This(tree, qual) - case Select(qualifier, selector) => - treeCopy.Select(tree, transform(qualifier), selector) - case Ident(name) => - treeCopy.Ident(tree, name) - case Literal(value) => - treeCopy.Literal(tree, value) - case TypeTree() => - treeCopy.TypeTree(tree) - case Annotated(annot, arg) => - treeCopy.Annotated(tree, transform(annot), transform(arg)) - case SingletonTypeTree(ref) => - treeCopy.SingletonTypeTree(tree, transform(ref)) - case SelectFromTypeTree(qualifier, selector) => - treeCopy.SelectFromTypeTree(tree, transform(qualifier), selector) - case CompoundTypeTree(templ) => - treeCopy.CompoundTypeTree(tree, transformTemplate(templ)) - case AppliedTypeTree(tpt, args) => - treeCopy.AppliedTypeTree(tree, transform(tpt), transformTrees(args)) - case TypeBoundsTree(lo, hi) => - treeCopy.TypeBoundsTree(tree, transform(lo), transform(hi)) - case ExistentialTypeTree(tpt, whereClauses) => - treeCopy.ExistentialTypeTree(tree, transform(tpt), transformTrees(whereClauses)) - case _ => - xtransform(this, tree) - } - - def transformTrees(trees: List[Tree]): List[Tree] = - trees mapConserve (transform(_)) - def transformTemplate(tree: Template): Template = - transform(tree: Tree).asInstanceOf[Template] - def transformTypeDefs(trees: List[TypeDef]): List[TypeDef] = - trees mapConserve (tree => transform(tree).asInstanceOf[TypeDef]) - def transformValDef(tree: ValDef): ValDef = - if (tree.isEmpty) tree else transform(tree).asInstanceOf[ValDef] - def transformValDefs(trees: List[ValDef]): List[ValDef] = - trees mapConserve (transformValDef(_)) - def transformValDefss(treess: List[List[ValDef]]): List[List[ValDef]] = - treess mapConserve (transformValDefs(_)) - def transformCaseDefs(trees: List[CaseDef]): List[CaseDef] = - trees mapConserve (tree => transform(tree).asInstanceOf[CaseDef]) - def transformIdents(trees: List[Ident]): List[Ident] = - trees mapConserve (tree => transform(tree).asInstanceOf[Ident]) - def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = - stats mapConserve (stat => - if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat)) - else transform(stat)) filter (EmptyTree !=) - def transformModifiers(mods: Modifiers): Modifiers = - mods.mapAnnotations(transformTrees) - - def atOwner[A](owner: Symbol)(trans: => A): A = { - val prevOwner = currentOwner - currentOwner = owner - val result = trans - currentOwner = prevOwner - result - } - } - - protected def xtransform(transformer: Transformer, tree: Tree): Tree = throw new MatchError(tree) - - class ForeachTreeTraverser(f: Tree => Unit) extends Traverser { - override def traverse(t: Tree) { - f(t) - super.traverse(t) - } - } - - class FilterTreeTraverser(p: Tree => Boolean) extends Traverser { - val hits = new ListBuffer[Tree] - override def traverse(t: Tree) { - if (p(t)) hits += t - super.traverse(t) - } - } - - class FindTreeTraverser(p: Tree => Boolean) extends Traverser { - var result: Option[Tree] = None - override def traverse(t: Tree) { - if (result.isEmpty) { - if (p(t)) result = Some(t) - super.traverse(t) - } - } - } - - protected def duplicateTree(tree: Tree): Tree - -/* A standard pattern match - case EmptyTree => - case PackageDef(pid, stats) => - // package pid { stats } - case ClassDef(mods, name, tparams, impl) => - // mods class name [tparams] impl where impl = extends parents { defs } - case ModuleDef(mods, name, impl) => (eliminated by refcheck) - // mods object name impl where impl = extends parents { defs } - case ValDef(mods, name, tpt, rhs) => - // mods val name: tpt = rhs - // note missing type information is expressed by tpt = TypeTree() - case DefDef(mods, name, tparams, vparamss, tpt, rhs) => - // mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs - // note missing type information is expressed by tpt = TypeTree() - case TypeDef(mods, name, tparams, rhs) => (eliminated by erasure) - // mods type name[tparams] = rhs - // mods type name[tparams] >: lo <: hi, where lo, hi are in a TypeBoundsTree, - and DEFERRED is set in mods - case LabelDef(name, params, rhs) => - // used for tailcalls and like - // while/do are desugared to label defs as follows: - // while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ()) - // do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ()) - case Import(expr, selectors) => (eliminated by typecheck) - // import expr.{selectors} - // Selectors are a list of pairs of names (from, to). - // The last (and maybe only name) may be a nme.WILDCARD - // for instance - // import qual.{x, y => z, _} would be represented as - // Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null))) - case Template(parents, self, body) => - // extends parents { self => body } - // if self is missing it is represented as emptyValDef - case Block(stats, expr) => - // { stats; expr } - case CaseDef(pat, guard, body) => (eliminated by transmatch/explicitouter) - // case pat if guard => body - case Alternative(trees) => (eliminated by transmatch/explicitouter) - // pat1 | ... | patn - case Star(elem) => (eliminated by transmatch/explicitouter) - // pat* - case Bind(name, body) => (eliminated by transmatch/explicitouter) - // name @ pat - case UnApply(fun: Tree, args) (introduced by typer, eliminated by transmatch/explicitouter) - // used for unapply's - case ArrayValue(elemtpt, trees) => (introduced by uncurry) - // used to pass arguments to vararg arguments - // for instance, printf("%s%d", foo, 42) is translated to after uncurry to: - // Apply( - // Ident("printf"), - // Literal("%s%d"), - // ArrayValue(<Any>, List(Ident("foo"), Literal(42)))) - case Function(vparams, body) => (eliminated by lambdaLift) - // vparams => body where vparams:List[ValDef] - case Assign(lhs, rhs) => - // lhs = rhs - case If(cond, thenp, elsep) => - // if (cond) thenp else elsep - case Match(selector, cases) => - // selector match { cases } - case Return(expr) => - // return expr - case Try(block, catches, finalizer) => - // try block catch { catches } finally finalizer where catches: List[CaseDef] - case Throw(expr) => - // throw expr - case New(tpt) => - // new tpt always in the context: (new tpt).<init>[targs](args) - case Typed(expr, tpt) => (eliminated by erasure) - // expr: tpt - case TypeApply(fun, args) => - // fun[args] - case Apply(fun, args) => - // fun(args) - // for instance fun[targs](args) is expressed as Apply(TypeApply(fun, targs), args) - case ApplyDynamic(qual, args) (introduced by erasure, eliminated by cleanup) - // fun(args) - case Super(qual, mix) => - // qual.super[mix] if qual and/or mix is empty, ther are tpnme.EMPTY - case This(qual) => - // qual.this - case Select(qualifier, selector) => - // qualifier.selector - case Ident(name) => - // name - // note: type checker converts idents that refer to enclosing fields or methods - // to selects; name ==> this.name - case Literal(value) => - // value - case TypeTree() => (introduced by refcheck) - // a type that's not written out, but given in the tpe attribute - case Annotated(annot, arg) => (eliminated by typer) - // arg @annot for types, arg: @annot for exprs - case SingletonTypeTree(ref) => (eliminated by uncurry) - // ref.type - case SelectFromTypeTree(qualifier, selector) => (eliminated by uncurry) - // qualifier # selector, a path-dependent type p.T is expressed as p.type # T - case CompoundTypeTree(templ: Template) => (eliminated by uncurry) - // parent1 with ... with parentN { refinement } - case AppliedTypeTree(tpt, args) => (eliminated by uncurry) - // tpt[args] - case TypeBoundsTree(lo, hi) => (eliminated by uncurry) - // >: lo <: hi - case ExistentialTypeTree(tpt, whereClauses) => (eliminated by uncurry) - // tpt forSome { whereClauses } -*/ -} - diff --git a/src/compiler/scala/reflect/api/Types.scala b/src/compiler/scala/reflect/api/Types.scala deleted file mode 100755 index 646c93ad5f..0000000000 --- a/src/compiler/scala/reflect/api/Types.scala +++ /dev/null @@ -1,124 +0,0 @@ -package scala.reflect -package api - -trait Types { self: Universe => - - abstract class AbsType { - def typeSymbol: Symbol - def decl(name: Name): Symbol - } - - type Type >: Null <: AbsType - type SingletonType >: Null <: Type - - val NoType: Type - val NoPrefix: Type - - type ThisType <: SingletonType - val ThisType: ThisTypeExtractor - - type TypeRef <: Type - val TypeRef: TypeRefExtractor - - type SingleType <: SingletonType - val SingleType: SingleTypeExtractor - - type SuperType <: SingletonType - val SuperType: SuperTypeExtractor - - type TypeBounds <: Type - val TypeBounds: TypeBoundsExtractor - - type CompoundType <: Type - - type RefinedType <: CompoundType - val RefinedType: RefinedTypeExtractor - - type ClassInfoType <: CompoundType - val ClassInfoType: ClassInfoTypeExtractor - - type ConstantType <: Type - val ConstantType: ConstantTypeExtractor - - type MethodType <: Type - val MethodType: MethodTypeExtractor - - type NullaryMethodType <: Type - val NullaryMethodType: NullaryMethodTypeExtractor - - type PolyType <: Type - val PolyType: PolyTypeExtractor - - type ExistentialType <: Type - val ExistentialType: ExistentialTypeExtractor - - type AnnotatedType <: Type - val AnnotatedType: AnnotatedTypeExtractor - - abstract class ThisTypeExtractor { - def apply(sym: Symbol): Type - def unapply(tpe: ThisType): Option[Symbol] - } - - abstract class SingleTypeExtractor { - def apply(pre: Type, sym: Symbol): Type - def unapply(tpe: SingleType): Option[(Type, Symbol)] - } - - abstract class SuperTypeExtractor { - def apply(thistpe: Type, supertpe: Type): Type - def unapply(tpe: SuperType): Option[(Type, Type)] - } - - abstract class TypeRefExtractor { - def apply(pre: Type, sym: Symbol, args: List[Type]): Type - def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])] - } - - abstract class TypeBoundsExtractor { - def apply(lo: Type, hi: Type): TypeBounds - def unapply(tpe: TypeBounds): Option[(Type, Type)] - } - - abstract class RefinedTypeExtractor { - def apply(parents: List[Type], decls: Scope): RefinedType - def apply(parents: List[Type], decls: Scope, clazz: Symbol): RefinedType - def unapply(tpe: RefinedType): Option[(List[Type], Scope)] - } - - abstract class ClassInfoTypeExtractor { - def apply(parents: List[Type], decls: Scope, clazz: Symbol): ClassInfoType - def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)] - } - - abstract class ConstantTypeExtractor { - def apply(value: Constant): ConstantType - def unapply(tpe: ConstantType): Option[Constant] - } - - abstract class MethodTypeExtractor { - def apply(params: List[Symbol], resultType: Type): MethodType - def unapply(tpe: MethodType): Option[(List[Symbol], Type)] - } - - abstract class NullaryMethodTypeExtractor { - def apply(resultType: Type): NullaryMethodType - def unapply(tpe: NullaryMethodType): Option[(Type)] - } - - abstract class PolyTypeExtractor { - def apply(typeParams: List[Symbol], resultType: Type): PolyType - def unapply(tpe: PolyType): Option[(List[Symbol], Type)] - } - - abstract class ExistentialTypeExtractor { - def apply(quantified: List[Symbol], underlying: Type): ExistentialType - def unapply(tpe: ExistentialType): Option[(List[Symbol], Type)] - } - - abstract class AnnotatedTypeExtractor { - def apply(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol): AnnotatedType - def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)] - } -} - diff --git a/src/compiler/scala/reflect/api/Universe.scala b/src/compiler/scala/reflect/api/Universe.scala deleted file mode 100755 index ad145b12ac..0000000000 --- a/src/compiler/scala/reflect/api/Universe.scala +++ /dev/null @@ -1,17 +0,0 @@ -package scala.reflect -package api - -abstract class Universe extends Symbols - with Types - with Constants - with Scopes - with Names - with Trees - with Positions - with AnnotationInfos - with StandardDefinitions { - type Position - val NoPosition: Position - -} - diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 92bd656ed2..f9afd164f5 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -1426,7 +1426,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => * (5) companionSymbol */ - /** For a module or case factory: the class with the same name in the same package. + /** For a module: the class with the same name in the same package. * For all others: NoSymbol * Note: does not work for classes owned by methods, see Namers.companionClassOf * diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala index 33f4b08d74..60e14ecec7 100644 --- a/src/compiler/scala/reflect/runtime/JavaToScala.scala +++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala @@ -1,15 +1,24 @@ package scala.reflect package runtime -import java.lang.{Class => jClass, Package => jPackage} +import java.lang.{ Class => jClass, Package => jPackage } import java.lang.reflect.{ - Method => jMethod, Constructor => jConstructor, Modifier => jModifier, Field => jField, - Member => jMember, Type => jType, TypeVariable => jTypeVariable, - GenericDeclaration, ParameterizedType, WildcardType, AnnotatedElement} + Method => jMethod, + Constructor => jConstructor, + Modifier => jModifier, + Field => jField, + Member => jMember, + Type => jType, + TypeVariable => jTypeVariable, + GenericDeclaration, + ParameterizedType, + WildcardType, + AnnotatedElement +} import internal.pickling.ByteCodecs import internal.ClassfileConstants._ import internal.pickling.UnPickler -import collection.mutable.{HashMap, ListBuffer} +import collection.mutable.{ HashMap, ListBuffer } import internal.Flags._ trait JavaToScala extends ConversionUtil { self: Universe => @@ -20,7 +29,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => val global: JavaToScala.this.type = self } - /** Generate types for top-level Scala root class and root companion object + /** + * Generate types for top-level Scala root class and root companion object * from the pickled information stored in a corresponding Java class * @param clazz The top-level Scala class for which info is unpickled * @param module The top-level Scala companion object for which info is unpickled @@ -28,7 +38,7 @@ trait JavaToScala extends ConversionUtil { self: Universe => * ScalaSignature or ScalaLongSignature annotation. */ def unpickleClass(clazz: Symbol, module: Symbol, jclazz: jClass[_]): Unit = { - println("unpickling "+clazz+" "+module) + println("unpickling " + clazz + " " + module) val ssig = jclazz.getAnnotation(classOf[scala.reflect.ScalaSignature]) if (ssig != null) { val bytes = ssig.bytes.getBytes @@ -48,13 +58,14 @@ trait JavaToScala extends ConversionUtil { self: Universe => println("long sig") unpickler.unpickle(bytes, 0, clazz, module, jclazz.getName) } else { // class does not have a Scala signature; it's a Java class - println("no sig found for "+jclazz) + println("no sig found for " + jclazz) initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz)) } } } - /** A fresh Scala type parameter that corresponds to a Java type variable. + /** + * A fresh Scala type parameter that corresponds to a Java type variable. * The association between Scala type parameter and Java type variable is entered in the cache. * @param jtvar The Java type variable */ @@ -65,7 +76,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => tparam } - /** A completer that fills in the type of a Scala type parameter from the bounds of a Java type variable. + /** + * A completer that fills in the type of a Scala type parameter from the bounds of a Java type variable. * @param jtvar The Java type variable */ private class TypeParamCompleter(jtvar: jTypeVariable[_ <: GenericDeclaration]) extends LazyType { @@ -74,7 +86,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => } } - /** Copy all annotations of Java annotated element `jann` over to Scala symbol `sym`. + /** + * Copy all annotations of Java annotated element `jann` over to Scala symbol `sym`. * Pre: `sym` is already initialized with a concrete type. * Note: If `sym` is a method or constructor, its parameter annotations are copied as well. */ @@ -82,7 +95,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => // to do: implement } - /** A completer that fills in the types of a Scala class and its companion object + /** + * A completer that fills in the types of a Scala class and its companion object * by copying corresponding type info from a Java class. This completer is used * to reflect classes in Scala that do not have a Scala pickle info, be it * because they are local classes or have been compiled from Java sources. @@ -92,7 +106,7 @@ trait JavaToScala extends ConversionUtil { self: Universe => */ private class FromJavaClassCompleter(clazz: Symbol, module: Symbol, jclazz: jClass[_]) extends LazyType { override def complete(sym: Symbol) = { - println("completing from Java "+sym+"/"+clazz.fullName) + println("completing from Java " + sym + "/" + clazz.fullName) assert(sym == clazz || sym == module || sym == module.moduleClass, sym) val flags = toScalaFlags(jclazz.getModifiers, isClass = true) clazz setFlag (flags | JAVA) @@ -125,44 +139,52 @@ trait JavaToScala extends ConversionUtil { self: Universe => } } - /** If Java modifiers `mods` contain STATIC, return the module class + /** + * If Java modifiers `mods` contain STATIC, return the module class * of the companion module of `clazz`, otherwise the class `clazz` itself. */ private def followStatic(clazz: Symbol, mods: Int) = if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz - /** The Scala owner of the Scala class corresponding to the Java class `jclazz` + /** + * The Scala owner of the Scala class corresponding to the Java class `jclazz` */ private def sOwner(jclazz: jClass[_]): Symbol = { if (jclazz.isMemberClass) followStatic(classToScala(jclazz.getEnclosingClass), jclazz.getModifiers) else if (jclazz.isLocalClass) methodToScala(jclazz.getEnclosingMethod) orElse constrToScala(jclazz.getEnclosingConstructor) + else if (jclazz.isPrimitive || jclazz.isArray) + ScalaPackageClass else { assert(jclazz.getPackage != null, jclazz) packageToScala(jclazz.getPackage) } } - /** The Scala owner of the Scala symbol corresponding to the Java member `jmember` + /** + * The Scala owner of the Scala symbol corresponding to the Java member `jmember` */ private def sOwner(jmember: jMember): Symbol = { followStatic(classToScala(jmember.getDeclaringClass), jmember.getModifiers) } - /** The Scala owner of the Scala type parameter corresponding to the Java type variable `jtvar` + /** + * The Scala owner of the Scala type parameter corresponding to the Java type variable `jtvar` */ private def sOwner(jtvar: jTypeVariable[_ <: GenericDeclaration]): Symbol = genericDeclarationToScala(jtvar.getGenericDeclaration) - /** Returns `true` if Scala name `name` equals Java name `jstr`, possibly after + /** + * Returns `true` if Scala name `name` equals Java name `jstr`, possibly after * make-not-private expansion. */ private def approximateMatch(sym: Symbol, jstr: String): Boolean = (sym.name.toString == jstr) || - sym.isPrivate && nme.expandedName(sym.name, sym.owner).toString == jstr + sym.isPrivate && nme.expandedName(sym.name, sym.owner).toString == jstr - /** Find declarations or definition in class `clazz` that maps to a Java + /** + * Find declarations or definition in class `clazz` that maps to a Java * entity with name `jname`. Because of name-mangling, this is more difficult * than a simple name-based lookup via `decl`. If `decl` fails, members * that start with the given name are searched instead. @@ -170,13 +192,14 @@ trait JavaToScala extends ConversionUtil { self: Universe => private def lookup(clazz: Symbol, jname: String): Symbol = clazz.info.decl(newTermName(jname)) orElse { (clazz.info.decls.iterator filter (approximateMatch(_, jname))).toList match { - case List() => NoSymbol + case List() => NoSymbol case List(sym) => sym - case alts => clazz.newOverloaded(alts.head.tpe.prefix, alts) + case alts => clazz.newOverloaded(alts.head.tpe.prefix, alts) } } - /** The Scala method corresponding to given Java method. + /** + * The Scala method corresponding to given Java method. * @param jmeth The Java method * @return A Scala method object that corresponds to `jmeth`. */ @@ -185,7 +208,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => lookup(owner, jmeth.getName) suchThat (erasesTo(_, jmeth)) orElse jmethodAsScala(jmeth) } - /** The Scala constructor corresponding to given Java constructor. + /** + * The Scala constructor corresponding to given Java constructor. * @param jconstr The Java constructor * @return A Scala method object that corresponds to `jconstr`. */ @@ -194,20 +218,23 @@ trait JavaToScala extends ConversionUtil { self: Universe => lookup(owner, "<init>") suchThat (erasesTo(_, jconstr)) orElse jconstrAsScala(jconstr) } - /** The Scala package corresponding to given Java package + /** + * The Scala package corresponding to given Java package */ def packageToScala(jpkg: jPackage): Symbol = packageCache.toScala(jpkg) { makeScalaPackage(jpkg.getName) } - /** The Scala package with given fully qualified name. + /** + * The Scala package with given fully qualified name. */ def packageNameToScala(fullname: String): Symbol = { val jpkg = jPackage.getPackage(fullname) if (jpkg != null) packageToScala(jpkg) else makeScalaPackage(fullname) } - /** The Scala package with given fully qualified name. Unlike `packageNameToScala`, + /** + * The Scala package with given fully qualified name. Unlike `packageNameToScala`, * this one bypasses the cache. */ private def makeScalaPackage(fullname: String): Symbol = { @@ -219,7 +246,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => pkg.moduleClass } - /** The Scala class that corresponds to a given Java class. + /** + * The Scala class that corresponds to a given Java class. * @param jclazz The Java class * @return A Scala class symbol that reflects all elements of the Java class, * in the form they appear in the Scala pickling info, or, if that is @@ -230,14 +258,28 @@ trait JavaToScala extends ConversionUtil { self: Universe => sOwner(jclazz).info.decl(newTypeName(jclazz.getSimpleName)).asInstanceOf[ClassSymbol] } else if (jclazz.isLocalClass) { // local classes not preserved by unpickling - treat as Java jclassAsScala(jclazz) - } else { // jclazz is top-level - get signature - val (clazz, module) = createClassModule( + } else if (jclazz.isArray) { + ArrayClass + } else jclazz match { + case java.lang.Void.TYPE => UnitClass + case java.lang.Byte.TYPE => ByteClass + case java.lang.Character.TYPE => CharClass + case java.lang.Short.TYPE => ShortClass + case java.lang.Integer.TYPE => IntClass + case java.lang.Long.TYPE => LongClass + case java.lang.Float.TYPE => FloatClass + case java.lang.Double.TYPE => DoubleClass + case java.lang.Boolean.TYPE => BooleanClass + case _ => + // jclazz is top-level - get signature + val (clazz, module) = createClassModule( sOwner(jclazz), newTypeName(jclazz.getSimpleName), new TopClassCompleter(_, _)) - clazz + clazz } } - /** The Scala type parameter that corresponds to a given Java type parameter. + /** + * The Scala type parameter that corresponds to a given Java type parameter. * @param jparam The Java type parameter * @return A Scala type parameter symbol that has the same owner and name as the Java type parameter */ @@ -248,25 +290,27 @@ trait JavaToScala extends ConversionUtil { self: Universe => } } - /** The Scala symbol that corresponds to a given Java generic declaration (class, method, or constructor) + /** + * The Scala symbol that corresponds to a given Java generic declaration (class, method, or constructor) */ def genericDeclarationToScala(jdecl: GenericDeclaration) = jdecl match { - case jclazz: jClass[_] => classToScala(jclazz) - case jmeth: jMethod => methodToScala(jmeth) + case jclazz: jClass[_] => classToScala(jclazz) + case jmeth: jMethod => methodToScala(jmeth) case jconstr: jConstructor[_] => constrToScala(jconstr) } - /** Given some Java type arguments, a corresponding list of Scala types, plus potentially + /** + * Given some Java type arguments, a corresponding list of Scala types, plus potentially * some existentially bound type variables that represent wildcard arguments. */ private def targsToScala(owner: Symbol, args: List[jType]): (List[Type], List[Symbol]) = { val tparams = new ListBuffer[Symbol] def targToScala(arg: jType): Type = arg match { case jwild: WildcardType => - val tparam = owner.newExistential(NoPosition, newTypeName("T$"+tparams.length)) + val tparam = owner.newExistential(NoPosition, newTypeName("T$" + tparams.length)) .setInfo(TypeBounds( - lub(jwild.getLowerBounds.toList map typeToScala), - glb(jwild.getUpperBounds.toList map typeToScala))) + lub(jwild.getLowerBounds.toList map typeToScala), + glb(jwild.getUpperBounds.toList map typeToScala))) tparams += tparam typeRef(NoPrefix, tparam, List()) case _ => @@ -275,20 +319,13 @@ trait JavaToScala extends ConversionUtil { self: Universe => (args map targToScala, tparams.toList) } - /** The Scala type that corresponds to given Java type + /** + * The Scala type that corresponds to given Java type */ def typeToScala(jtpe: jType): Type = jtpe match { - case java.lang.Void.TYPE => UnitClass.tpe - case java.lang.Byte.TYPE => ByteClass.tpe - case java.lang.Character.TYPE => CharClass.tpe - case java.lang.Short.TYPE => ShortClass.tpe - case java.lang.Integer.TYPE => IntClass.tpe - case java.lang.Long.TYPE => LongClass.tpe - case java.lang.Float.TYPE => FloatClass.tpe - case java.lang.Double.TYPE => DoubleClass.tpe - case java.lang.Boolean.TYPE => BooleanClass.tpe case jclazz: jClass[_] => - if (jclazz.isArray) arrayType(typeToScala(jclazz.getComponentType)) + if (jclazz.isArray) + arrayType(typeToScala(jclazz.getComponentType)) else { val clazz = classToScala(jclazz) rawToExistential(typeRef(clazz.owner.thisType, clazz, List())) @@ -296,7 +333,7 @@ trait JavaToScala extends ConversionUtil { self: Universe => case japplied: ParameterizedType => val (pre, sym) = typeToScala(japplied.getRawType) match { case ExistentialType(tparams, TypeRef(pre, sym, _)) => (pre, sym) - case TypeRef(pre, sym, _) => (pre, sym) + case TypeRef(pre, sym, _) => (pre, sym) } val args0 = japplied.getActualTypeArguments val (args, bounds) = targsToScala(pre.typeSymbol, args0.toList) @@ -306,18 +343,20 @@ trait JavaToScala extends ConversionUtil { self: Universe => typeRef(NoPrefix, tparam, List()) } - /** The Scala class that corresponds to given Java class without taking + /** + * The Scala class that corresponds to given Java class without taking * Scala pickling info into account. * @param jclazz The Java class * @return A Scala class symbol that wraps all reflection info of `jclazz` */ private def jclassAsScala(jclazz: jClass[_]): Symbol = { val (clazz, module) = createClassModule( - sOwner(jclazz), newTypeName(jclazz.getSimpleName), new FromJavaClassCompleter(_, _, jclazz)) + sOwner(jclazz), newTypeName(jclazz.getSimpleName), new FromJavaClassCompleter(_, _, jclazz)) clazz } - /** The Scala field that corresponds to given Java field without taking + /** + * The Scala field that corresponds to given Java field without taking * Scala pickling info into account. * @param jfield The Java field * @return A Scala value symbol that wraps all reflection info of `jfield` @@ -330,7 +369,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => field } - /** The Scala method that corresponds to given Java method without taking + /** + * The Scala method that corresponds to given Java method without taking * Scala pickling info into account. * @param jmeth The Java method * @return A Scala method symbol that wraps all reflection info of `jmethod` @@ -347,7 +387,8 @@ trait JavaToScala extends ConversionUtil { self: Universe => meth } - /** The Scala constructor that corresponds to given Java constructor without taking + /** + * The Scala constructor that corresponds to given Java constructor without taking * Scala pickling info into account. * @param jconstr The Java constructor * @return A Scala constructor symbol that wraps all reflection info of `jconstr` diff --git a/src/compiler/scala/reflect/runtime/Loaders.scala b/src/compiler/scala/reflect/runtime/Loaders.scala index bb2f628041..3cab02706a 100644 --- a/src/compiler/scala/reflect/runtime/Loaders.scala +++ b/src/compiler/scala/reflect/runtime/Loaders.scala @@ -1,6 +1,8 @@ package scala.reflect package runtime +import internal.Flags + import java.lang.{Class => jClass, Package => jPackage} trait Loaders { self: Universe => @@ -21,9 +23,10 @@ trait Loaders { self: Universe => class TopClassCompleter(clazz: Symbol, module: Symbol) extends LazyType { def makePackage() { val ptpe = new PackageType(module.moduleClass) - clazz setInfo ptpe - module setInfo ptpe - module.moduleClass setInfo ptpe + for (sym <- List(clazz, module, module.moduleClass)) { + sym setFlag Flags.PACKAGE + sym setInfo ptpe + } } override def complete(sym: Symbol) = { println("completing "+sym+"/"+clazz.fullName) @@ -54,6 +57,7 @@ trait Loaders { self: Universe => * @param completer The completer to be used to set the info of the class and the module */ protected def createClassModule(owner: Symbol, name: TypeName, completer: (Symbol, Symbol) => LazyType) = { + assert(!(name.toString endsWith "[]"), name) val clazz = owner.newClass(NoPosition, name) val module = owner.newModule(NoPosition, name.toTermName) owner.info.decls enter clazz diff --git a/src/compiler/scala/reflect/runtime/Mirror.scala b/src/compiler/scala/reflect/runtime/Mirror.scala index 18283f3898..3d6d330cfe 100644 --- a/src/compiler/scala/reflect/runtime/Mirror.scala +++ b/src/compiler/scala/reflect/runtime/Mirror.scala @@ -2,27 +2,43 @@ package scala.reflect package runtime import internal.{SomePhase, NoPhase, Phase, TreeGen} +import java.lang.reflect.Array /** The mirror for standard runtime reflection from Java. */ class Mirror extends Universe with api.Mirror { + import definitions._ + def classWithName(name: String): Symbol = classToScala(java.lang.Class.forName(name)) def getClass(obj: AnyRef): Symbol = classToScala(obj.getClass) def getType(obj: AnyRef): Type = typeToScala(obj.getClass) // to do add getClass/getType for instances of primitive types, probably like this: // def getClass[T <: AnyVal : Manifest](x: T): Symbol = manifest[T].getClass - def getValue(receiver: AnyRef, field: Symbol): Any = fieldToJava(field).get(receiver) - def setValue(receiver: AnyRef, field: Symbol, value: Any): Unit = fieldToJava(field).set(receiver, value) - def invoke(receiver: AnyRef, meth: Symbol, args: Any*): Any = methodToJava(meth).invoke(receiver, args) + def getValue(receiver: AnyRef, field: Symbol): Any = { + fieldToJava(field).get(receiver) + } + def setValue(receiver: AnyRef, field: Symbol, value: Any): Unit = { + fieldToJava(field).set(receiver, value) + } + def invoke(receiver: AnyRef, meth: Symbol, args: Any*): Any = { + if (meth.owner == ArrayClass) { + meth.name match { + case nme.length => return Array.getLength(receiver) + case nme.apply => return Array.get(receiver, args(0).asInstanceOf[Int]) + case nme.update => return Array.set(receiver, args(0).asInstanceOf[Int], args(1)) + } + } + methodToJava(meth).invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + } } object Mirror extends Mirror /** test code; should go to tests once things settle down a bit - */ + * object Test extends Mirror with App { val sym = classToScala(classOf[scala.collection.Iterable[_]]) println(sym) @@ -30,4 +46,5 @@ object Test extends Mirror with App { println("decls = "+(sym.info.decls.toList map (_.defString))) val ms = sym.info.members.toList map (_.initialize) println("members = "+(ms map (_.defString) mkString ("\n "))) -}
\ No newline at end of file +} +*/
\ No newline at end of file diff --git a/src/compiler/scala/reflect/runtime/ScalaToJava.scala b/src/compiler/scala/reflect/runtime/ScalaToJava.scala index b3f898e709..4155d7ee06 100644 --- a/src/compiler/scala/reflect/runtime/ScalaToJava.scala +++ b/src/compiler/scala/reflect/runtime/ScalaToJava.scala @@ -22,12 +22,27 @@ trait ScalaToJava extends ConversionUtil { self: Universe => * - top-level classes * - Scala classes that were generated via jclassToScala * - classes that have a class owner that has a corresponding Java class - * @throws A `NoClassDefFoundError` for all Scala classes not in one of these categories. + * @throws A `ClassNotFoundException` for all Scala classes not in one of these categories. */ + @throws(classOf[ClassNotFoundException]) def classToJava(clazz: Symbol): jClass[_] = classCache.toJava(clazz) { - def noClass = throw new NoClassDefFoundError("no Java class corresponding to "+clazz+" found") + def noClass = throw new ClassNotFoundException("no Java class corresponding to "+clazz+" found") println("classToJava "+clazz+" "+clazz.owner+" "+clazz.owner.isPackageClass) - if (clazz.owner.isPackageClass) + if (clazz.isValueClass) + clazz match { + case UnitClass => java.lang.Void.TYPE + case ByteClass => java.lang.Byte.TYPE + case CharClass => java.lang.Character.TYPE + case ShortClass => java.lang.Short.TYPE + case IntClass => java.lang.Integer.TYPE + case LongClass => java.lang.Long.TYPE + case FloatClass => java.lang.Float.TYPE + case DoubleClass => java.lang.Double.TYPE + case BooleanClass => java.lang.Boolean.TYPE + } + else if (clazz == ArrayClass) + noClass + else if (clazz.owner.isPackageClass) jClass.forName(clazz.fullName) else if (clazz.owner.isClass) classToJava(clazz.owner) @@ -76,20 +91,7 @@ trait ScalaToJava extends ConversionUtil { self: Universe => def typeToJavaClass(tpe: Type): jClass[_] = tpe match { case ExistentialType(_, rtpe) => typeToJavaClass(rtpe) case TypeRef(_, ArrayClass, List(elemtpe)) => jArrayClass(typeToJavaClass(elemtpe)) - case TypeRef(_, sym, _) => typeSymToJavaClass(sym) + case TypeRef(_, sym, _) => classToJava(sym) case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found") } - - private def typeSymToJavaClass(sym: Symbol): jClass[_] = sym match { - case UnitClass => java.lang.Void.TYPE - case ByteClass => java.lang.Byte.TYPE - case CharClass => java.lang.Character.TYPE - case ShortClass => java.lang.Short.TYPE - case IntClass => java.lang.Integer.TYPE - case LongClass => java.lang.Long.TYPE - case FloatClass => java.lang.Float.TYPE - case DoubleClass => java.lang.Double.TYPE - case BooleanClass => java.lang.Boolean.TYPE - case _ => jClass.forName(sym.fullName) - } }
\ No newline at end of file |