summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-23 14:44:08 -0700
committerPaul Phillips <paulp@improving.org>2012-10-23 14:51:09 -0700
commitcd6ad8929d49dc77ade17bd1a4cab9a7c7494366 (patch)
tree2ecbce954ad743e46cdfcfb81a6e1c5a8e306df8 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent56b23776f14499e96078be403a423f23ba50dbbb (diff)
downloadscala-cd6ad8929d49dc77ade17bd1a4cab9a7c7494366.tar.gz
scala-cd6ad8929d49dc77ade17bd1a4cab9a7c7494366.tar.bz2
scala-cd6ad8929d49dc77ade17bd1a4cab9a7c7494366.zip
Added some symbol lookup convenience methods.
Greasing the wheels for Typer's well-being.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d0c4d6d65f..d7607ae383 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3971,15 +3971,30 @@ trait Typers extends Modes with Adaptations with Tags {
}
def typed1(tree: Tree, mode: Int, pt: Type): Tree = {
- def isPatternMode = inPatternMode(mode)
+ def isPatternMode = inPatternMode(mode)
+ def inPatternConstructor = inAllModes(mode, PATTERNmode | FUNmode)
+ def isQualifierMode = (mode & QUALmode) != 0
- //Console.println("typed1("+tree.getClass()+","+Integer.toHexString(mode)+","+pt+")")
//@M! get the type of the qualifier in a Select tree, otherwise: NoType
def prefixType(fun: Tree): Type = fun match {
case Select(qualifier, _) => qualifier.tpe
-// case Ident(name) => ??
- case _ => NoType
+ case _ => NoType
}
+ // Lookup in the given class using the root mirror.
+ def lookupInOwner(owner: Symbol, name: Name): Symbol =
+ if (isQualifierMode) rootMirror.missingHook(owner, name) else NoSymbol
+
+ // Lookup in the given qualifier. Used in last-ditch efforts by typedIdent and typedSelect.
+ def lookupInRoot(name: Name): Symbol = lookupInOwner(rootMirror.RootClass, name)
+ def lookupInEmpty(name: Name): Symbol = lookupInOwner(rootMirror.EmptyPackageClass, name)
+ def lookupInQualifier(qual: Tree, name: Name): Symbol = (
+ if (name == nme.ERROR || qual.tpe.widen.isErroneous)
+ NoSymbol
+ else lookupInOwner(qual.tpe.typeSymbol, name) orElse {
+ NotAMemberError(tree, qual, name)
+ NoSymbol
+ }
+ )
def typedAnnotated(atd: Annotated): Tree = {
val ann = atd.annot