diff options
author | Burak Emir <emir@epfl.ch> | 2006-11-29 08:28:24 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-11-29 08:28:24 +0000 |
commit | 0f20a51754b58798bf4b21f45e5c8ab4d03b5dae (patch) | |
tree | 7889e068533695d6744f26b904e563272570cbf8 /src/compiler | |
parent | 899a7adfe51ff14f8c1beb45e7dd7c5dee14a0b6 (diff) | |
download | scala-0f20a51754b58798bf4b21f45e5c8ab4d03b5dae.tar.gz scala-0f20a51754b58798bf4b21f45e5c8ab4d03b5dae.tar.bz2 scala-0f20a51754b58798bf4b21f45e5c8ab4d03b5dae.zip |
fixed 2 bugs in unapply tc-ing and definitions
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 8bffa1e8f5..fe7c4d5cf5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -124,7 +124,9 @@ trait Definitions requires SymbolTable { false } def productType(elems: List[Type]) = - if (elems.length <= MaxProductArity) { + if (elems.isEmpty) + UnitClass.tpe + else if (elems.length <= MaxProductArity) { val sym = ProductClass(elems.length) typeRef(sym.typeConstructor.prefix, sym, elems) } else NoType diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 7a2b6b9b03..3bc35b2067 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -580,7 +580,9 @@ trait Typers requires Analyzer { obj } if (definitions.unapplyMember(consp.tpe).exists) - atPos(tree.pos) {Ident(consp).setType(consp.tpe)} + atPos(tree.pos) { + gen.mkAttributedRef(consp.tpe.prefix,consp) + } // needs member type, but member of what? ^^^ // see test/pending/pos/unapplyNeedsMemberType.scala else errorTree(tree, "" + clazz + " is not a case class, nor does it have unapply/unapplySeq method") @@ -1425,7 +1427,8 @@ trait Typers requires Analyzer { val funPt = appliedType(OptionClass.typeConstructor, List(prod)) val fun0 = Ident(fun.symbol) setPos fun.pos setType otpe // would this change when patterns are terms??? - val fun1 = typed(atPos(fun.pos) { Apply(Select(Ident(fun.symbol), unapp), List(arg)) }, EXPRmode, funPt) + val fun1 = typed(atPos(fun.pos) { Apply(Select( + gen.mkAttributedRef(fun.tpe.prefix,fun.symbol), unapp), List(arg)) }, EXPRmode, funPt) if (fun1.tpe.isErroneous) setError(tree) else { val formals0 = if(unapp.name == nme.unapply) optionOfProductElems(fun1.tpe) |