Skip to content

Commit 76ae989

Browse files
sjrdWojciechMazur
authored andcommitted
Fix #17115: Try to normalize while computing typeSize.
[Cherry-picked ad29ce8]
1 parent c6ade8b commit 76ae989

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -6397,7 +6397,9 @@ object Types {
63976397
seen += tp
63986398
tp match {
63996399
case tp: AppliedType =>
6400-
foldOver(n + 1, tp)
6400+
val tpNorm = tp.tryNormalize
6401+
if tpNorm.exists then apply(n, tpNorm)
6402+
else foldOver(n + 1, tp)
64016403
case tp: RefinedType =>
64026404
foldOver(n + 1, tp)
64036405
case tp: TypeRef if tp.info.isTypeAlias =>

tests/pos/i17115.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait A[T <: Tuple] { val x: Int }
2+
given empty: A[EmptyTuple] with { val x = 1 }
3+
given inductive[Tup <: NonEmptyTuple](using A[Tuple.Tail[Tup]]): A[Tup] with { val x = summon[A[Tuple.Tail[Tup]]].x + 1 }
4+
5+
object Test:
6+
def main(args: Array[String]): Unit =
7+
println(summon[A[(String, String, String)]].x) //this line is fine
8+
println(summon[A[(String, String, String, String)]].x) //this line gives error
9+
end Test

0 commit comments

Comments
 (0)