Skip to content

Commit

Permalink
Fix #17115: Try to normalize while computing typeSize.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrd committed Aug 11, 2023
1 parent fed94f3 commit ad29ce8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6459,7 +6459,9 @@ object Types {
seen += tp
tp match {
case tp: AppliedType =>
foldOver(n + 1, tp)
val tpNorm = tp.tryNormalize
if tpNorm.exists then apply(n, tpNorm)
else foldOver(n + 1, tp)
case tp: RefinedType =>
foldOver(n + 1, tp)
case tp: TypeRef if tp.info.isTypeAlias =>
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i17115.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait A[T <: Tuple] { val x: Int }
given empty: A[EmptyTuple] with { val x = 1 }
given inductive[Tup <: NonEmptyTuple](using A[Tuple.Tail[Tup]]): A[Tup] with { val x = summon[A[Tuple.Tail[Tup]]].x + 1 }

object Test:
def main(args: Array[String]): Unit =
println(summon[A[(String, String, String)]].x) //this line is fine
println(summon[A[(String, String, String, String)]].x) //this line gives error
end Test

0 comments on commit ad29ce8

Please sign in to comment.