File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
compiler/src/dotty/tools/backend/sjs Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -793,6 +793,9 @@ class JSCodeGen()(using genCtx: Context) {
793793 name.name
794794 }.toSet
795795
796+ val staticNames = moduleClass.companionClass.info.allMembers
797+ .collect { case d if d.name.isTermName && d.symbol.isScalaStatic => d.name }.toSet
798+
796799 val members = {
797800 moduleClass.info.membersBasedOnFlags(required = Flags .Method ,
798801 excluded = Flags .ExcludedForwarder ).map(_.symbol)
@@ -815,6 +818,7 @@ class JSCodeGen()(using genCtx: Context) {
815818 || hasAccessBoundary
816819 || isOfJLObject
817820 || m.hasAnnotation(jsdefn.JSNativeAnnot ) || isDefaultParamOfJSNativeDef // #4557
821+ || staticNames(m.name)
818822 }
819823
820824 val forwarders = for {
@@ -4769,7 +4773,7 @@ class JSCodeGen()(using genCtx: Context) {
47694773 }
47704774
47714775 private def isMethodStaticInIR (sym : Symbol ): Boolean =
4772- sym.is(JavaStatic )
4776+ sym.is(JavaStatic ) || sym.isScalaStatic
47734777
47744778 /** Generate a Class[_] value (e.g. coming from classOf[T]) */
47754779 private def genClassConstant (tpe : Type )(implicit pos : Position ): js.Tree =
Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ object Bar:
1313object Test :
1414 def main (args : Array [String ]): Unit =
1515 assert(Foo .foo == " foo" )
16- assert(classOf [Foo ].getMethod(" foo" ).invoke(null ) == " foo" ) // static
17- assert(Foo .getClass.getMethod(" foo" ).invoke(Foo ) == " foo" ) // instance, on module class
18-
1916 assert(Bar .bar == " bar" )
20- assert(classOf [Bar ].getMethod(" bar" ).invoke(null ) == " bar" )
21- assert(Bar .getClass.getMethod(" bar" ).invoke(Bar ) == " bar" )
17+
18+ import scala .reflect .Selectable .reflectiveSelectable
19+ assert(Foo .asInstanceOf [{ def foo : String }].foo == " foo" )
20+ assert(Bar .asInstanceOf [{ def bar : String }].bar == " bar" )
You can’t perform that action at this time.
0 commit comments