-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add dynamic access to value classes field
- Loading branch information
Showing
3 changed files
with
46 additions
and
10 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,4 @@ | ||
1 | ||
2 | ||
3 | ||
qux |
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,20 @@ | ||
class Foo(val value: Int) extends AnyVal | ||
class Bar[A](val value: A) extends AnyVal | ||
|
||
class Container1 extends reflect.Selectable | ||
|
||
class Container2 extends Selectable: | ||
def selectDynamic(name: String) = Bar(name) | ||
|
||
val cont1 = new Container1: | ||
def foo = new Foo(1) | ||
val bar = new Bar(Foo(2)) | ||
def fooFromInt(i: Int) = new Foo(i) | ||
|
||
val cont2 = (new Container2).asInstanceOf[Container2 { def qux: Bar[String] }] | ||
|
||
@main def Test: Unit = | ||
println(cont1.foo.value) | ||
println(cont1.bar.value.value) | ||
println(cont1.fooFromInt(3).value) | ||
println(cont2.qux.value) |