diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 9 | ||||
-rw-r--r-- | test/files/pos/t2994a.scala | 27 | ||||
-rw-r--r-- | test/files/pos/t2994b.scala | 7 |
4 files changed, 40 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 1c5fb05a72..8b9ed69f47 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1840,7 +1840,7 @@ self => } val nameOffset = in.offset val pname = - (if (in.token == USCORE) { // @M! also allow underscore + (if (in.token == USCORE) { // TODO AM: freshName(o2p(in.skipToken()), "_$$"), will need to update test suite in.nextToken() nme.WILDCARD } else ident()).toTypeName diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 855e6951d0..665239a2a0 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1689,14 +1689,14 @@ A type's typeSymbol should never be inspected directly. val xform = transform(sym.info.resultType) assert(xform ne this, this) xform.normalize // cycles have been checked in typeRef - } else { - PolyType(typeParams, transform(sym.info.resultType).normalize) // eta-expand + } else { // should rarely happen, if at all + PolyType(sym.info.typeParams, transform(sym.info.resultType).normalize) // eta-expand -- for regularity, go through sym.info for typeParams // @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function* } } else if (isHigherKinded) { // @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function* - // @M: initialize needed (see test/files/pos/ticket0137.scala) - PolyType(typeParams, typeRef(pre, sym.initialize, dummyArgs)) + // @M: initialize (by sym.info call) needed (see test/files/pos/ticket0137.scala) + PolyType(sym.info.typeParams, typeRef(pre, sym, dummyArgs)) // must go through sym.info for typeParams } else if (sym.isRefinementClass) { sym.info.normalize // @MO to AM: OK? //@M I think this is okay, but changeset 12414 (which fixed #1241) re-introduced another bug (#2208) @@ -1918,6 +1918,7 @@ A type's typeSymbol should never be inspected directly. */ case class PolyType(override val typeParams: List[Symbol], override val resultType: Type) extends Type { + // assert(!(typeParams contains NoSymbol), this) override def paramSectionCount: Int = resultType.paramSectionCount override def paramss: List[List[Symbol]] = resultType.paramss diff --git a/test/files/pos/t2994a.scala b/test/files/pos/t2994a.scala new file mode 100644 index 0000000000..cb4a389e2f --- /dev/null +++ b/test/files/pos/t2994a.scala @@ -0,0 +1,27 @@ +object Naturals { + trait NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] <: NAT + type v = a[SUCC, ZERO] + } + final class ZERO extends NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] = z + } + final class SUCC[n <: NAT] extends NAT { + type a[s[_ <: NAT] <: NAT, z <: NAT] = s[n#a[s, z]] + } + type _0 = ZERO + type _1 = SUCC[_0] + type _2 = SUCC[_1] + type _3 = SUCC[_2] + type _4 = SUCC[_3] + type _5 = SUCC[_4] + type _6 = SUCC[_5] + + + // crashes scala-2.8.0 beta1 + trait MUL[n <: NAT, m <: NAT] extends NAT { + trait curry[n[_[_], _], s[_]] { type f[z <: NAT] = n[s, z] } + type a[s[_ <: NAT] <: NAT, z <: NAT] = n#a[curry[m#a, s]#f, z] + } + +}
\ No newline at end of file diff --git a/test/files/pos/t2994b.scala b/test/files/pos/t2994b.scala new file mode 100644 index 0000000000..c9d9cc812b --- /dev/null +++ b/test/files/pos/t2994b.scala @@ -0,0 +1,7 @@ +object Test { + trait Bar[X[_]] + trait Baz[S[_] <: Bar[S]] { + type Apply[T] + } + trait Foo[V[_] <: Bar[V]] extends Bar[Baz[V]#Apply] +}
\ No newline at end of file |