-
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.
Allow
apply
adaptation on Selectable with Fields
Just like when using a regular Selectable with refinements, this change allows: fromFlds.xs(0) to be expanded to: fromFlds.xs.apply(0)
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import scala.language.experimental.namedTuples | ||
|
||
class FromFields extends Selectable: | ||
type Fields = (i: Int) | ||
def selectDynamic(key: String) = | ||
List(1, 2, 3) | ||
|
||
trait FromRefs extends Selectable: | ||
def selectDynamic(key: String) = | ||
List(1, 2, 3) | ||
|
||
def test( | ||
fromFlds: FromFields, | ||
fromRefs: FromRefs { val i: Int } | ||
): Unit = | ||
fromFlds.i(0) // error | ||
fromRefs.i(0) // error | ||
|
||
fromFlds.i.apply(0) // error | ||
fromRefs.i.apply(0) // error | ||
|
||
fromFlds.i[Int](List(1)) // error | ||
fromRefs.i[Int](List(1)) // error | ||
|
||
fromFlds.i(List(1)) // error | ||
fromRefs.i(List(1)) // error | ||
|
||
fromFlds.i.apply(List(1)) // error | ||
fromRefs.i.apply(List(1)) // error |
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 @@ | ||
import scala.language.experimental.namedTuples | ||
|
||
class FromFields extends Selectable: | ||
type Fields = (xs: List[Int], poly: [T] => (x: List[T]) => Option[T]) | ||
def selectDynamic(key: String) = | ||
List(1, 2, 3) | ||
|
||
trait FromRefs extends Selectable: | ||
def selectDynamic(key: String) = | ||
List(1, 2, 3) | ||
|
||
def test( | ||
fromFlds: FromFields, | ||
fromRefs: FromRefs { val xs: List[Int]; val poly: [T] => (x: List[T]) => Option[T] } | ||
): Unit = | ||
fromFlds.xs(0) | ||
fromRefs.xs(0) | ||
|
||
fromFlds.xs.apply(0) | ||
fromRefs.xs.apply(0) | ||
|
||
fromFlds.poly[Int](List(1)): Option[Int] | ||
fromRefs.poly[Int](List(1)): Option[Int] | ||
|
||
fromFlds.poly(List(1)) | ||
fromRefs.poly(List(1)) | ||
|
||
fromFlds.poly.apply(List(1)) | ||
fromRefs.poly.apply(List(1)) |