Closed
Description
Regression found in OpenCB for tarao/record4s
- build logs
All transparent inline given
instances used in match block are loosing information about dependent type, it does not happen when calling unapply outside match block.
Compiler version
Last good release: 3.4.1-RC1-bin-20240129-b20747d-NIGHTLY
First bad release: 3.4.1-RC1-bin-20240130-7a5cb6e-NIGHTLY
Bisect points to 5648f12
Minimized code
import scala.compiletime.*
import scala.language.dynamics
abstract class % extends Selectable
trait Select { type Out <: % }
trait Selector extends Dynamic {
def selectDynamic[S <: Singleton & String](label: S): Any = ???
def unapply[R: RecordLike](record: R)(using
t: Select,
r: RecordLike[t.Out]
): r.ElemTypes = ???
}
trait RecordLike[R] {
type ElemTypes <: Tuple
}
@main def Test = {
val r: %{ val name: String; } = ???
// originally derived in macro, use dummy instance instead
transparent inline given outputRecordLike[R <: %]: RecordLike[R] = null.asInstanceOf[
RecordLike[R] {
type ElemTypes = String *: EmptyTuple
}
]
type FieldSelector = Select { type Out = % { val name: String } }
given fieldSelector: FieldSelector = ???
val selector: Selector = ???
val works = selector.unapply(r)
val works2 = selector.unapply(r)(using summon, fieldSelector, summon)
r match {
case selector(value) => value // compilation error
}
}
Output
- [E108] Declaration Error: /Users/wmazur/projects/dotty/bisect/main.scala:38:17
38 | case selector(value) => value // compilation error
| ^^^^^^^^^^^^^^^
| ?1.ElemTypes is not a valid result type of an unapply method of an extractor.
|
|where: ?1 is an unknown value of type RecordLike[%{val name: String}]
|
| longer explanation available when compiling with `-explain`
-- [E006] Not Found Error: /Users/wmazur/projects/dotty/bisect/main.scala:38:28
38 | case selector(value) => value // compilation error
| ^^^^^
| Not found: value - did you mean valueOf?
|
| longer explanation available when compiling with `-explain`
2 errors found
Expectation
Should compile