diff options
author | Burak Emir <emir@epfl.ch> | 2006-11-06 18:09:42 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-11-06 18:09:42 +0000 |
commit | 7632c7172daad811f37eb972dc1e836ad8f68181 (patch) | |
tree | 19a6771c671f4cb079e281cfb03c80e5eb129f98 | |
parent | 3125604fb0fad1f7d2e72498076c966402489f70 (diff) | |
download | scala-7632c7172daad811f37eb972dc1e836ad8f68181.tar.gz scala-7632c7172daad811f37eb972dc1e836ad8f68181.tar.bz2 scala-7632c7172daad811f37eb972dc1e836ad8f68181.zip |
contd: revisited fix #796 + ident handling for ...
contd: revisited fix #796 + ident handling for unapply (can compile
library with -Xunapply now)
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 70618a04c0..e7620ce54c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1631,18 +1631,7 @@ trait Typers requires Analyzer { if (defSym == NoSymbol) cx = cx.outer } } - /*<unapply>*/ - if(settings.Xunapply.value) - // unapply: in patterns, look for an object if can't find type - if(name.isTypeName && defSym == NoSymbol && (mode & PATTERNmode) != 0) { - typedIdent(name.toTermName) match { - case t if t.symbol.isTerm /*isModule*/ => - return t - case _ => - // when can this happen? - } - } - /*</unapply>*/ + val symDepth = if (defEntry == null) cx.depth else cx.depth - (cx.scope.nestingLevel - defEntry.owner.nestingLevel) var impSym: Symbol = NoSymbol; // the imported symbol @@ -1665,6 +1654,29 @@ trait Typers requires Analyzer { context.unit != null && defSym.sourceFile != context.unit.source.file)) defSym = NoSymbol + /*<unapply>*/ + if(settings.Xunapply.value) + // unapply: in patterns, look for an object if can't find type + if(!defSym.exists && !impSym.exists && name.isTypeName && (mode & PATTERNmode) != 0) { + typedIdent(name.toTermName) match { + case t if t.symbol.isTerm /*isModule*/ => + //Console.println("special treatment for "+name+" yields "+t) + t.tpe match { + case PolyType(_,MethodType(_,_)) => + //Console.println("ugh!") + // for instance Predef.Pair + //Console.println("no special treatment for "+name) + case _ => + //return t + defSym = t.symbol + } + case _ => + Console.println("no special treatment for "+name) + // when can this happen? + } + } + /*</unapply>*/ + if (defSym.exists) { if (impSym.exists) ambiguousError( |