Skip to content

Commit d6f9361

Browse files
committed
Fixed hang in typechecker.
Another page in the storied history of "check the normalized type, then act on the unnormalized type", in this case leading to a tight loop of foreverness. Closes SI-5156, review by moors.
1 parent d56a8a5 commit d6f9361

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ trait Implicits {
305305
case NoPrefix =>
306306
0
307307
case SingleType(pre, sym) =>
308-
if (sym.isPackage) 0 else complexity(tp.widen)
308+
if (sym.isPackage) 0 else complexity(tp.normalize.widen)
309309
case TypeRef(pre, sym, args) =>
310310
complexity(pre) + sum(args map complexity) + 1
311311
case RefinedType(parents, _) =>

test/files/pos/t5156.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
sealed trait HList
2+
final case class HCons[H, T <: HList](head : H, tail : T) extends HList
3+
case object HNil extends HList
4+
5+
object HList {
6+
type ::[H, T <: HList] = HCons[H, T]
7+
type HNil = HNil.type
8+
9+
implicit def hlistOps[L <: HList](l : L) = new {
10+
def ::[H](h : H) : H :: L = HCons(h, l)
11+
def last(implicit last : Last[L]) {}
12+
}
13+
14+
class Last[L <: HList]
15+
implicit def hsingleLast[H] = new Last[H :: HNil]
16+
implicit def hlistLast[H, T <: HList](implicit lt : Last[T]) = new Last[H :: T]
17+
18+
type III = Int :: Int :: Int :: HNil
19+
val iii : III = 0 :: 0 :: 0 :: HNil
20+
val l = iii.last
21+
}

0 commit comments

Comments
 (0)