-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure typeParams returns a stable result even in the presence of …
…completions (#19974) Fixes #19942 Based on #19960 @dwijnand I would have pushed onto the original PR if it had been on staging. Better to always push to staging, not your own repo.
- Loading branch information
Showing
5 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
type LifecycleF = [_] =>> Any | ||
trait Lifecycle[+F[_], +A] | ||
|
||
trait LifecycleTag[R] | ||
object LifecycleTag: | ||
implicit def resourceTag[R <: Lifecycle[F0, A0], F0[_], A0]: LifecycleTag[R] = ??? | ||
|
||
trait MakeDSL[T]: | ||
final def fromResource[R <: Lifecycle[LifecycleF, T]](implicit tag: LifecycleTag[R]): Any = ??? | ||
|
||
object distage: | ||
// Cannot be defined in the same scope as rest of code | ||
final type Identity[+A] = A | ||
import distage.* | ||
|
||
trait Resource | ||
trait DependentResource() extends Lifecycle[Identity, Resource] | ||
|
||
@main def Test = { | ||
val dsl: MakeDSL[Resource] = ??? | ||
val fails = dsl.fromResource[DependentResource] | ||
val works = dsl.fromResource[DependentResource](using LifecycleTag.resourceTag[DependentResource, Identity, Resource]) | ||
} |