From cc9e8eda3364dcb7bf5b92a3d3824b66c85ef05f Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 26 Feb 2010 09:16:22 +0000 Subject: closes #2797 -- no review (already done in tick... closes #2797 -- no review (already done in ticket by Martin) 1) isHigherKindedType is now false for singletontype 2) toInstance recurses when pre is a typevar: the problem is that pre.widen.typeSymbol isNonBottomSubClass symclazz is true while pre.baseType(symclazz) is NoType --- src/compiler/scala/tools/nsc/symtab/Types.scala | 15 ++++++--------- test/files/pos/t2797.scala | 9 +++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 test/files/pos/t2797.scala diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index aa88996876..509f9b3835 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -968,6 +968,7 @@ trait Types extends reflect.generic.Types { self: SymbolTable => incCounter(singletonBaseTypeSeqCount) underlying.baseTypeSeq prepend this } + override def isHigherKinded = false // singleton type classifies objects, thus must be kind * override def safeToString: String = prefixString + "type" /* override def typeOfThis: Type = typeSymbol.typeOfThis @@ -1082,9 +1083,9 @@ trait Types extends reflect.generic.Types { self: SymbolTable => underlyingPeriod = currentPeriod if (!isValid(period)) { underlyingCache = pre.memberType(sym).resultType; + assert(underlyingCache ne this, this) } } - assert(underlyingCache ne this, this) underlyingCache } @@ -3051,17 +3052,13 @@ A type's typeSymbol should never be inspected directly. var capturedPre = emptySymMap - def stabilize(pre: Type, clazz: Symbol): Type = { - capturedPre get clazz match { - case Some(qvar) => - qvar - case _ => + def stabilize(pre: Type, clazz: Symbol): Type = + capturedPre.getOrElse(clazz, { val qvar = clazz freshExistential ".type" setInfo singletonBounds(pre) capturedPre += (clazz -> qvar) capturedParams = qvar :: capturedParams qvar - } - }.tpe + }).tpe /** Return pre.baseType(clazz), or if that's NoType and clazz is a refinement, pre itself. * See bug397.scala for an example where the second alternative is needed. @@ -3122,7 +3119,7 @@ A type's typeSymbol should never be inspected directly. appliedType(as.head, args mapConserve (this)) // @M: was as.head else instParam(ps.tail, as.tail); val symclazz = sym.owner - if (symclazz == clazz && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) { + if (symclazz == clazz && !pre.isInstanceOf[TypeVar] && (pre.widen.typeSymbol isNonBottomSubClass symclazz)) { pre.baseType(symclazz) match { case TypeRef(_, basesym, baseargs) => //Console.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs+", pre = "+pre+", symclazz = "+symclazz);//DEBUG diff --git a/test/files/pos/t2797.scala b/test/files/pos/t2797.scala new file mode 100644 index 0000000000..4323664e91 --- /dev/null +++ b/test/files/pos/t2797.scala @@ -0,0 +1,9 @@ +class MyVector[A] { + def map[B](f: A => B): MyVector[B] = error("") +} + +object Test { + def unzip[B, C](_this: MyVector[(B, C)]): (MyVector[B], MyVector[C]) = { + (_this.map{ bc => bc._1 }, _this.map{ bc => bc._2 }) + } +} \ No newline at end of file -- cgit v1.2.3