Skip to content

Commit

Permalink
Don't force type vars while typing (named) tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Feb 5, 2024
1 parent 5583593 commit 2230e58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,10 @@ object desugar {
var names = elems.collect:
case NamedArg(name, arg) => name
if names.isEmpty then
typer.Inferencing.isFullyDefined(pt, typer.ForceDegree.failBottom)
names = pt.namedTupleNames
val pt1 = pt.stripTypeVar match
case p: TypeParamRef => ctx.typerState.constraint.entry(p).hiBound
case _ => NoType
names = pt1.orElse(pt).namedTupleNames
if names.isEmpty || ctx.mode.is(Mode.Pattern) then
tup
else
Expand Down
9 changes: 9 additions & 0 deletions tests/run/named-patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ object Test1:
p3 match
case (Person2(nn, a), Address(c, z, s, number)) =>
println(s"$nn, aged $a in $z $c, $s $number")

// don't force type vars too early (while typing named tuples)
def ifBefore[T](end: Int)(op: => T, default: T): T = ???
def ifBeforeTest(end: Int) =
sealed trait Type
case class TypeRef() extends Type
case object NoType extends Type
def readQualId(): (Int, TypeRef) = ???
val (mixId, mixTpe) = ifBefore(end)(readQualId(), (2, NoType))

0 comments on commit 2230e58

Please sign in to comment.