diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index bbec037ebef1..f5e128dd070d 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -6026,7 +6026,7 @@ object Types { case _ => if args.exists(isRange) then if variance > 0 then - tp.derivedAppliedType(tycon, args.map(rangeToBounds)) match + tp.derivedAppliedType(tycon, args.map(rangeToBounds))(using ctx.addMode(Mode.AllowLambdaWildcardApply)) match case tp1: AppliedType if tp1.isUnreducibleWild && ctx.phase != checkCapturesPhase => // don't infer a type that would trigger an error later in // Checking.checkAppliedType; fall through to default handling instead diff --git a/tests/pos/16583.scala b/tests/pos/16583.scala index adf67f5d469a..45410fb9e065 100644 --- a/tests/pos/16583.scala +++ b/tests/pos/16583.scala @@ -12,3 +12,27 @@ inline def labels[Labels <: Tuple](using ev: Tuple.Union[Labels] <:< String): Li def test = labels[("one", "two", "three")].mkString("<", ", ", ">") def test2(tup: ("one", "two", "three")) = tup.toList + +def toList(x: Tuple): List[Tuple.Union[x.type]] = ??? +def test3[Labels <: Tuple] = toList((???): Labels) +// Previously would fail with: +// Found: List[Tuple.Union[(?1 : Labels)]] +// Required: List[ +// Labels match { +// case EmptyTuple => Nothing +// case h *: t => h | scala.Tuple.Fold[t, Nothing, [x, y] =>> x | y] +// } +// ] +// Now, both the inferred return type and the type of the right-hand side are List[Any]. + +type F2[X, Y] +type F[X] = F2[X, X] +def toF(x: Any): F[x.type] = ??? +def test4[T] = toF((???): T) +// Previously would fail with: +// def test3[T] = toF((???): T) +// ^^^^^^^^^^^^^ +// Found: F[(?1 : T)] +// Required: F2[T, T] +// where: ?1 is an unknown value of type T +// Now, both the inferred return type and the type of the right-hand side are Any.