-
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 selectDynamic and applyDynamic to be extension methods (#17106)
Allow selectDynamic and applyDynamic to be extension methods when dispatching structurally. Fixes #17100
- Loading branch information
Showing
5 changed files
with
40 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,14 @@ | ||
trait Sel extends Selectable | ||
|
||
extension (s: Sel) | ||
def selectDynamic(name: String) = ??? | ||
def applyDynamic(name: String)(x: Int) = ??? | ||
def applyDynamic(name: String)() = ??? | ||
|
||
val sel = (new Sel {}).asInstanceOf[Sel{ def foo: String; def bar(x: Int): Int; def baz(): Int }] | ||
val foo = sel.selectDynamic("foo") | ||
val foo2 = sel.foo | ||
val foo3 = sel.bar(2) | ||
val foo4 = sel.baz() | ||
|
||
|
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,12 @@ | ||
|
||
import scala.language.dynamics | ||
trait Sel extends Dynamic | ||
|
||
extension (s: Sel) | ||
def selectDynamic(name: String) = ??? | ||
|
||
val sel = new Sel {} | ||
val foo = sel.foo | ||
val sel2 = (new Sel {}).asInstanceOf[Sel{ def foo: String }] | ||
val foo2 = sel2.foo | ||
|
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