File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
library/src/scala/reflect Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,13 @@ trait Selectable extends scala.Selectable:
20
20
/** Select member with given name */
21
21
final def selectDynamic (name : String ): Any =
22
22
val rcls = selectedValue.getClass
23
+ val encodedName = NameTransformer .encode(name)
23
24
try
24
- val fld = rcls.getField(name ).nn
25
+ val fld = rcls.getField(encodedName ).nn
25
26
ensureAccessible(fld)
26
27
fld.get(selectedValue)
27
28
catch case ex : NoSuchFieldException =>
28
- applyDynamic(name )()
29
+ applyDynamic(encodedName )()
29
30
30
31
// The Scala.js codegen relies on this method being final for correctness
31
32
/** Select method and apply to arguments.
Original file line number Diff line number Diff line change
1
+ class X extends scala.reflect.Selectable :
2
+ val `+` = " 1"
3
+
4
+ @ main def Test =
5
+ val x = X ()
6
+ assert(x.selectDynamic(" +" ) == " 1" )
Original file line number Diff line number Diff line change
1
+ class X extends scala.reflect.Selectable :
2
+ val plus = " 1"
3
+
4
+ @ main def Test =
5
+ val x = X ()
6
+ assert(x.selectDynamic(" plus" ) == " 1" )
You can’t perform that action at this time.
0 commit comments