Skip to content

Upper bound lost from Int to Any on Scala 3.1.2 and later #18253

Closed
@soronpo

Description

@soronpo

Pretty weird error. It disappears when removing the clue parameter from check.

Compiler version

3.1.1 - compiles
3.1.2 and later - compilation error

Minimized code

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))

Output

Type argument Any does not conform to upper bound Int in subpart compiletime.ops.int.Max[(8 : Int), Any] of inferred type 
  Playground.DFSInt[?
     >: compiletime.ops.int.Max[(8 : Int), Any] & (8 : Int) <: 
      compiletime.ops.int.Max[(8 : Int), Any]
     | (8 : Int)
  ]

Expectation

Should compile.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions