-
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.
Fix use of class terms in match analysis (#21848)
- Loading branch information
Showing
4 changed files
with
118 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
trait Init[ScopeType]: | ||
sealed trait Initialize[A1] | ||
final class Bind[S, A1](val f: S => Initialize[A1], val in: Initialize[S]) | ||
extends Initialize[A1] | ||
final class Value[A1](val value: () => A1) extends Initialize[A1] | ||
final class ValidationCapture[A1](val key: ScopedKey[A1], val selfRefOk: Boolean) | ||
extends Initialize[ScopedKey[A1]] | ||
final class TransformCapture(val f: [x] => Initialize[x] => Initialize[x]) | ||
extends Initialize[[x] => Initialize[x] => Initialize[x]] | ||
final class Optional[S, A1](val a: Option[Initialize[S]], val f: Option[S] => A1) | ||
extends Initialize[A1] | ||
object StaticScopes extends Initialize[Set[ScopeType]] | ||
|
||
sealed trait Keyed[S, A1] extends Initialize[A1] | ||
trait KeyedInitialize[A1] extends Keyed[A1, A1] | ||
sealed case class ScopedKey[A](scope: ScopeType, key: AttributeKey[A]) extends KeyedInitialize[A] | ||
sealed trait AttributeKey[A] | ||
|
||
abstract class EvaluateSettings[ScopeType]: | ||
protected val init: Init[ScopeType] | ||
import init._ | ||
|
||
val transform: [A] => Initialize[A] => Unit = [A] => | ||
(fa: Initialize[A]) => | ||
fa match | ||
case k: Keyed[s, A] => ??? | ||
case b: Bind[s, A] => ??? | ||
case v: Value[A] => ??? | ||
case v: ValidationCapture[a] => ??? // unrearchable warning | ||
case t: TransformCapture => ??? // unrearchable warning | ||
case o: Optional[s, A] => ??? // unrearchable warning | ||
case StaticScopes => ??? // unrearchable warning | ||
|
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,15 @@ | ||
trait Outer[O1]: | ||
sealed trait Foo[A1] | ||
final class Bar[A2] extends Foo[A2] | ||
final class Baz[A4] extends Foo[Bar[A4]] | ||
final class Qux extends Foo[[a5] => Foo[a5] => Foo[a5]] | ||
|
||
trait Test[O2]: | ||
val outer: Outer[O2] | ||
import outer.* | ||
|
||
def test[X](fa: Foo[X]): Unit = | ||
fa match // was: inexhaustive: fail on _: (Outer[<?>] & (Test#outer : Outer[Test#O2]))#Qux | ||
case _: Bar[X] => ??? | ||
case _: Baz[x] => ??? // was: unrearchable warning | ||
case _: Qux => ??? // was: unrearchable warning |