Closed
Description
I actually first found this regression when upgrading from 3.4.0 to 3.4.1-RC1, but during minimization I reached a point where the error always surfaced until I went back to 3.0.0 and saw no error. Aux pattern can be used as a workaround. I bisected it to the versions below.
Compiler version
Last good release: 3.0.2-RC1-bin-20210609-fdbb94f-NIGHTLY
First bad release: 3.0.2-RC1-bin-20210610-fe2fcc4-NIGHTLY
bisect: ff8659e
Minimized code
trait Summon[R, T <: R]:
type Out
object Summon:
given [R, T <: R]: Summon[R, T] with
type Out = R
trait DFTypeAny
trait DFBits[W <: Int] extends DFTypeAny
class DFVal[+T <: DFTypeAny]
type DFValAny = DFVal[DFTypeAny]
type DFValOf[+T <: DFTypeAny] = DFVal[T]
trait Candidate[R]:
type OutW <: Int
object Candidate:
type Aux[R, O <: Int] = Candidate[R] { type OutW = O }
given [W <: Int, R <: DFValOf[DFBits[W]]]: Candidate[R] with
type OutW = W
extension [L](lhs: L) def foo(using es: Summon[L, lhs.type]): Unit = ???
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L]) def baz: DFValOf[DFBits[icL.OutW]] = ???
extension [L <: DFValAny, W <: Int](lhs: L)(using icL: Candidate.Aux[L, W])
def bazAux: DFValOf[DFBits[W]] = ???
val x = new DFVal[DFBits[4]]
val works = x.bazAux.foo
val fails = x.baz.foo
Output
26 |val fails = x.baz.foo
| ^^^^^^^^^
|value foo is not a member of DFVal[DFBits[?1.OutW]].
|An extension method was tried, but could not be fully constructed:
|
| foo[DFVal[DFBits[?1.OutW]]](
| baz[DFVal[DFBits[(4 : Int)]]](x)(Candidate.given_Candidate_R[(4 : Int), R])
| )(Summon.given_Summon_R_T[R, T]) failed with
|
| no implicit argument of type Summon[DFVal[DFBits[?1.OutW]], (?2 : DFVal[DFBits[?1.OutW]])] was found for parameter es of method foo
|
| where: ?1 is an unknown value of type Candidate.given_Candidate_R[(4 : Int), DFVal[DFBits[(4 : Int)]]]
| ?2 is an unknown value of type DFVal[DFBits[?1.OutW]]
| .
| I found:
|
| Summon.given_Summon_R_T[R, T]
|
| But given instance given_Summon_R_T in object Summon does not match type Summon[DFVal[DFBits[?1.OutW]], (?2 : DFVal[DFBits[?1.OutW]])].
|
|where: ?1 is an unknown value of type Candidate.given_Candidate_R[(4 : Int), R]
1 error found
Expectation
No error.