diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index d1dffdbc9f9c..5acb067939cc 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -333,7 +333,7 @@ object Applications { // it's crucial that the type tree is not copied directly as argument to // `cpy$default$1`. If it was, the variable `X'` would already be interpolated // when typing the default argument, which is too early. - spliceMeth(meth, fn).appliedToTypes(targs.tpes) + spliceMeth(meth, fn).appliedToTypeTrees(targs.map(targ => TypeTree(targ.tpe).withSpan(targ.span))) case _ => meth } diff --git a/tests/pos/i18253.orig.scala b/tests/pos/i18253.orig.scala new file mode 100644 index 000000000000..9efe1224ebfd --- /dev/null +++ b/tests/pos/i18253.orig.scala @@ -0,0 +1,15 @@ +import compiletime.ops.int.Max + +trait DFSInt[W <: Int] +trait Candidate[R]: + type OutW <: Int +object Candidate: + given [W <: Int, R <: DFSInt[W]]: Candidate[R] with + type OutW = W + +def foo[R](rhs: R)(using icR: Candidate[R]): DFSInt[Max[8, icR.OutW]] = ??? + +object Test: + def check[A](a: A, clue: Int = 1): Unit = ??? + val x: DFSInt[8] = ??? + check(foo(x)) diff --git a/tests/pos/i18253.scala b/tests/pos/i18253.scala new file mode 100644 index 000000000000..8f395ee8e943 --- /dev/null +++ b/tests/pos/i18253.scala @@ -0,0 +1,14 @@ +import scala.compiletime.ops.int.Max + +trait Foo[A] +trait Bar[B]: + type Out <: Int +object Bar: + given inst[C <: Int]: Bar[C] with + type Out = C + +class Test: + def mkFoo(using bx: Bar[2]): Foo[Max[1, bx.Out]] = ??? + def check[Y](yy: Y, clue: Int = 1): Unit = () + + def test: Unit = check(mkFoo)