File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
library/src/scala/reflect Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,12 @@ 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)
24
23
try
25
- val fld = rcls.getField(encodedName ).nn
24
+ val fld = rcls.getField(NameTransformer .encode(name) ).nn
26
25
ensureAccessible(fld)
27
26
fld.get(selectedValue)
28
27
catch case ex : NoSuchFieldException =>
29
- applyDynamic(encodedName )()
28
+ applyDynamic(name )()
30
29
31
30
// The Scala.js codegen relies on this method being final for correctness
32
31
/** Select method and apply to arguments.
@@ -36,7 +35,7 @@ trait Selectable extends scala.Selectable:
36
35
*/
37
36
final def applyDynamic (name : String , paramTypes : Class [? ]* )(args : Any * ): Any =
38
37
val rcls = selectedValue.getClass
39
- val mth = rcls.getMethod(name, paramTypes* ).nn
38
+ val mth = rcls.getMethod(NameTransformer .encode( name) , paramTypes* ).nn
40
39
ensureAccessible(mth)
41
40
mth.invoke(selectedValue, args.asInstanceOf [Seq [AnyRef ]]* )
42
41
Original file line number Diff line number Diff line change
1
+ class X extends scala.reflect.Selectable :
2
+ def + = " 1"
3
+
4
+ @ main def Test =
5
+ val x = X ()
6
+ assert(x.selectDynamic(" +" ) == " 1" )
7
+ assert(x.applyDynamic(" +" )() == " 1" )
Original file line number Diff line number Diff line change
1
+ class X extends scala.reflect.Selectable :
2
+ def plus = " 1"
3
+
4
+ @ main def Test =
5
+ val x = X ()
6
+ assert(x.selectDynamic(" plus" ) == " 1" )
7
+ assert(x.applyDynamic(" plus" )() == " 1" )
You can’t perform that action at this time.
0 commit comments