Skip to content

Commit

Permalink
Backport "Fix failing bounds check on default getter" to LTS (#20658)
Browse files Browse the repository at this point in the history
Backports #18419 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 20, 2024
2 parents 5f4cb20 + 6eaf2c9 commit d089950
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 15 additions & 0 deletions tests/pos/i18253.orig.scala
Original file line number Diff line number Diff line change
@@ -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))
14 changes: 14 additions & 0 deletions tests/pos/i18253.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit d089950

Please sign in to comment.