Closed WojciechMazur closed 4 months ago
The bisect points to the same commit also in typelevel/kittens
(build logs) when companion object defining type alias is defined AFTER class/trait refers to type alias in implicit search
trait Alternative[F[_]]
opaque type Derived[A] = A
object Derived:
extension [A](derived: Derived[A]) def instance: A = derived
infix type <<<[F[_], G[_]] = [x] =>> F[G[x]]
import Derived.*
import scala.compiletime.summonInline
type DerivedAlternative[F[_]] = Derived[Alternative[F]]
object DerivedAlternative:
inline def apply[F[_]]: Alternative[F] =
import DerivedAlternative.given
summonInline[DerivedAlternative[F]].instance
given nested[F[_], G[_]]: DerivedAlternative[F <<< G] = ???
object auto:
object alternative:
transparent inline given [F[_]]: Alternative[F] = DerivedAlternative[F]
trait Test:
import Test.*
import auto.alternative.given
val fails = summon[Alternative[OptList]]
// Fails if companion object defined AFTER trait
object Test:
type OptList[A] = Option[List[A]]
-- [E172] Type Error: /Users/wmazur/projects/scala3/bisect/main.scala:25:42 ----
25 | val fails = summon[Alternative[OptList]]
| ^
|No given instance of type main$package$_this.DerivedAlternative[[A] =>> Test.OptList[A]] was found.
|I found:
|
| auto.alternative.given_Alternative_F[[A] =>> Test.OptList[A]]
|
|But given instance given_Alternative_F in object alternative does not match type main$package$_this.DerivedAlternative[[A] =>> Test.OptList[A]].
|----------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from main.scala:15
15 | summonInline[DerivedAlternative[F]].instance
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from main.scala:15
20 | transparent inline given [F[_]]: Alternative[F] = DerivedAlternative[F]
| ^^^^^^^^^^^^^^^^^^^^^
----------------------------------------------------------------------------
1 error found
Based on Open CB failure found in
7mind/izumi
- build logs When theIdentity
type is placed in different scope then rest of the code, implicit cannot be found.Compiler version
Last good release: 3.4.2-RC1-bin-20240222-98efdab-NIGHTLY First bad release: 3.4.2-RC1-bin-20240226-e0cb1e7-NIGHTLY Bisect points to 729e5ba099688a1e92c7d5cdf9611e7d1469379c
Minimized code
Output
Expectation
Should compile