diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index e30fefe5d9c9..8466504dc8fe 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -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 diff --git a/tests/run/named-patterns.scala b/tests/run/named-patterns.scala index 7c24dc8d683a..5b4000a00825 100644 --- a/tests/run/named-patterns.scala +++ b/tests/run/named-patterns.scala @@ -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))