diff options
author | Martin Odersky <odersky@gmail.com> | 2007-03-08 11:51:00 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-03-08 11:51:00 +0000 |
commit | acacbf69ba64017137c8483ba43daa62057f73a7 (patch) | |
tree | 1b770d58b4e7f20397c5a38d87690caed50aee7f | |
parent | 3269ad2aff74d1d7feec1206020b51e599fbb35c (diff) | |
download | scala-acacbf69ba64017137c8483ba43daa62057f73a7.tar.gz scala-acacbf69ba64017137c8483ba43daa62057f73a7.tar.bz2 scala-acacbf69ba64017137c8483ba43daa62057f73a7.zip |
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 12 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 71522aae4e..fadd37f66c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1961,6 +1961,10 @@ trait Parsers requires SyntaxAnalyzer { val implicitViewBuf = new ListBuffer[Tree] val tparams = typeParamClauseOpt(name, implicitViewBuf) implicitClassViews = implicitViewBuf.toList + if (!implicitClassViews.isEmpty && mods.hasFlag(Flags.TRAIT)) { + syntaxError("traits cannot have type parameters with <% bounds", false) + implicitClassViews = List() + } //if (mods.hasFlag(Flags.CASE) && in.token != LPAREN) accept(LPAREN) val constrAnnots = annotations() val (constrMods, vparamss) = diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 70c1521953..c359d166d9 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1428,6 +1428,12 @@ trait Types requires SymbolTable { if (healTypes && variance == 1 && !(sym1.info.bounds.hi contains sym1)) transform(sym1.info.bounds.hi) //else if (variance == -1 && !(sym1.info.bounds.lo contains sym1)) transform(sym1.info.bounds.lo) else throw new MalformedType(pre, sym1.nameString) + } else if (sym1.isClass && pre.isInstanceOf[CompoundType]) { + // sharpen prefix so that it is maximal and still contains the class. + var p = pre.parents.reverse + while (!p.isEmpty && p.head.member(sym1.name) != sym1) p = p.tail + if (p.isEmpty) rawTypeRef(pre, sym1, args) + else typeRef(p.head, sym1, args, variance) } else { rawTypeRef(pre, sym1, args) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f8698511ef..5962ef7d99 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -600,7 +600,6 @@ trait Typers requires Analyzer { if (extractor != NoSymbol) { tree setSymbol extractor } else { - Console.println(tree.symbol+tree.symbol.locationString+":"+tree.symbol.tpe) errorTree(tree, tree.symbol + " is not a case class constructor, nor does it have an unapply/unapplySeq method") } } @@ -1509,13 +1508,9 @@ trait Typers requires Analyzer { /* --- begin unapply --- */ case otpe if (mode & PATTERNmode) != 0 && definitions.unapplyMember(otpe).exists => - // !!! this is fragile, maybe needs to be revised when unapply patterns become terms val unapp = definitions.unapplyMember(otpe) assert(unapp.exists, tree) val unappType = otpe.memberType(unapp) - - // this is no longer needed! - val argDummyType = pt // was unappArg val argDummy = context.owner.newValue(fun.pos, nme.SELECTOR_DUMMY) .setFlag(SYNTHETIC) @@ -1545,7 +1540,12 @@ trait Typers requires Analyzer { } val fun1untyped = atPos(fun.pos) { - Apply(Select(gen.mkAttributedRef(fun.tpe.prefix,fun.symbol), unapp), List(arg)) + Apply( + Select( + gen.mkAttributedRef(fun.tpe.prefix, fun.symbol) setType null, + // setType null is necessary so that ref will be stabilized; see bug 881 + unapp), + List(arg)) } //Console.println("UNAPPLY2 "+fun+"/"+fun.tpe+" "+fun1untyped) val fun1 = typed(fun1untyped) |