-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refinements lost in inferred type #19749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
area:infer
itype:bug
regression
This worked in a previous version but doesn't anymore
stat:needs bisection
Need to use nightly builds and git bisect to find out the commit where this issue was introduced
Milestone
Comments
changing some definitions around, it seems like the refinements to the mirror are not being kept: scala> 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]): p.type = p
|
| def f2[T, R](f: T => R)(using SomeTrait[R]): R = ???
|
| def x = f2(_ => f1[A])
// defined case class A
// defined trait SomeTrait
// defined object SomeTrait
def f1[T](using p: scala.deriving.Mirror.ProductOf[T]): p.type
def f2[T, R](f: T => R)(using x$2: SomeTrait[R]): R
def x: scala.deriving.Mirror.ProductOf[A] |
more verbosely: scala -S 3 -Xprint:typer
Welcome to Scala 3.4.0 (21.0.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> 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]): p.type = p
|
| def f2[T, R](f: T => R)(using SomeTrait[R]): R = ???
|
| def x = f2(_ => f1[A])
[[syntax trees at end of typer]] // rs$line$1
package <empty> {
final lazy module val rs$line$1: rs$line$1 = new rs$line$1()
final module class rs$line$1() extends Object() { this: rs$line$1.type =>
import scala.deriving.Mirror
case class A(x: Int, y: String) extends Object(), _root_.scala.Product,
_root_.scala.Serializable {
val x: Int
val y: String
def copy(x: Int, y: String): A = new A(x, y)
def copy$default$1: Int @uncheckedVariance = A.this.x
def copy$default$2: String @uncheckedVariance = A.this.y
def _1: Int = this.x
def _2: String = this.y
}
final lazy module val A: A = new A()
final module class A() extends AnyRef() { this: A.type =>
def apply(x: Int, y: String): A = new A(x, y)
def unapply(x$1: A): A = x$1
override def toString: String = "A"
}
trait SomeTrait[T >: Nothing <: Any]() extends Object {
T
}
final lazy module val SomeTrait: SomeTrait = new SomeTrait()
final module class SomeTrait() extends Object() { this: SomeTrait.type =>
given class given_SomeTrait_T[T >: Nothing <: Any]() extends Object(),
SomeTrait[given_SomeTrait_T.this.T] {
T
}
final given def given_SomeTrait_T[T >: Nothing <: Any]:
SomeTrait.given_SomeTrait_T[T] = new SomeTrait.given_SomeTrait_T[T]()
}
def f1[T >: Nothing <: Any](using p: scala.deriving.Mirror.ProductOf[T]):
p.type = p
def f2[T >: Nothing <: Any, R >: Nothing <: Any](f: T => R)(using
x$2: SomeTrait[R]): R = ???
def x: scala.deriving.Mirror.ProductOf[A] =
f2[Any, scala.deriving.Mirror.ProductOf[A]](
{
def $anonfun(_$1: Any): scala.deriving.Mirror.ProductOf[A] =
f1[A](
A.$asInstanceOf[
scala.deriving.Mirror.Product{
type MirroredMonoType = A; type MirroredType = A;
type MirroredLabel = ("A" : String);
type MirroredElemTypes = (Int, String);
type MirroredElemLabels = (("x" : String), ("y" : String))
}
]
)
closure($anonfun)
}
)(
SomeTrait.given_SomeTrait_T[
scala.deriving.Mirror.Product{
type MirroredType = A; type MirroredMonoType = A;
type MirroredElemTypes <: Tuple
}
]
)
}
}
// defined case class A
// defined trait SomeTrait
// defined object SomeTrait
def f1[T](using p: scala.deriving.Mirror.ProductOf[T]): p.type
def f2[T, R](f: T => R)(using x$2: SomeTrait[R]): R
def x: scala.deriving.Mirror.ProductOf[A] |
EugeneFlesselle
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 13, 2024
Closes scala#19749 Closes scala#18558 Closes scala#16208
Merged
EugeneFlesselle
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 14, 2024
Closes scala#19749 Closes scala#16208
hamzaremmal
added a commit
that referenced
this issue
Apr 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:infer
itype:bug
regression
This worked in a previous version but doesn't anymore
stat:needs bisection
Need to use nightly builds and git bisect to find out the commit where this issue was introduced
Compiler version
3.4.0
Minimized code
Output
Expectation
The code is working properly
The text was updated successfully, but these errors were encountered: