Skip to content

Refinements lost in inferred type #19749

Closed
@wz7982

Description

@wz7982

Compiler version

3.4.0

Minimized code

import scala.deriving.Mirror

case class A(x: Int, y: String)

trait SomeTrait[T]

object SomeTrait:
    given [T]: SomeTrait[T] with {}

def f1[T](using p: Mirror.ProductOf[T]): Tuple.Elem[p.MirroredElemTypes, 0] = ???

def f2[T, R](f: T => R)(using SomeTrait[R]) = ???

// Scala3.3 is fine, 3.4 has compilation errors, p MirroredElemTypes type is missing and has been changed to Nothing
val x = f2(_ => f1[A])

Output

-- [E172] Type Error: ----------------------------------------------------------
13 |val x = f2(_ => f1[A])
   |                      ^
   |            No given instance of type SomeTrait[
   |              <error Match type reduction failed since selector Nothing
   |            matches none of the cases
   |
   |                case x *: xs => (0 : Int) match {
   |              case (0 : Int) => x
   |              case scala.compiletime.ops.int.S[n1] => Tuple.Elem[xs, n1]
   |            }>
   |              ] was found for parameter x$2 of method f2
1 error found

Expectation

The code is working properly

Metadata

Metadata

Assignees

Labels

area:inferitype:bugregressionThis worked in a previous version but doesn't anymorestat:needs bisectionNeed to use nightly builds and git bisect to find out the commit where this issue was introduced

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions