Binding.scala
Binding.scala copied to clipboard
Scala.JS: Cannot call lookupMethod(init___sc_Seq) on non Scala class sjs_js_Function
I ran in a strange behavior, that I describe here: https://stackoverflow.com/questions/50269126/scala-js-cannot-call-lookupmethodinit-sc-seq-on-non-scala-class-sjs-js-func
According to the comment of the creator of Scala.js that might be a bug in Binding.scala
Could you make the bug report be minimized and reproducible?
Yes - as described - in Stackoverflow.
I created a branch: https://github.com/pme123/scala-adapters/tree/binding-issue-78
Master branch with a 'shorter' name works.
Maybe it's reproducible, but still far from minimized. It would be easier to find the cause if it is minimized.
Also adding a -Xprint:typer flag should help if you want to investigate it.
As it works now for me (Using shorter class name) - it is not so high in the priority list anymore. If I get some time I will try to minimize it.
@sjrd How do you think?
The relevant output from -Xprint:typer would be critical to evaluate this. And perhaps -Xprint:mixin as well. Also, the output of scalajsp the/problematic/Class.sjsir could be useful too.
I tried to minimize the project - without success - a basic project with a case class that has a long name was not failing.
Then I did what @sjrd suggested. These created huge logs that I added to a gist:
https://gist.github.com/pme123/aadcc0fd101f6f7cf81e62f6f43d4fa1
-
- log is with
-Xprint:typer
- log is with
-
- log is with
-Xprint:mixin
- log is with
-
- log is with
scalajsp
- log is with
The long class is called: DemoWithLongerNameRunJobDialog
I think the relevant code and logs are:
https://github.com/pme123/scala-adapters/blob/063b9e8/client/src/main/scala/pme123/adapters/client/demo/DemoRunJobDialog.scala#L83
final <artifact> def $anonfun$demoForm$140(x$3: org.scalajs.dom.raw.UIEvent, demoDescr$1: org.scalajs.dom.raw.HTMLInputElement, reader$1: org.scalajs.dom.raw.FileReader): Unit = DemoWithLongerNameRunJobDialog.this.socket().runAdapter(new Some(play.api.libs.json.Json.toJson(new pme123.adapters.shared.demo.ImageUpload(demoDescr$1.value(), new StringContext(scala.Predef.wrapRefArray(Array[String]{"", ""}.$asInstanceOf[Array[Object]]())).s(scala.Predef.genericWrapArray(Array[Object]{reader$1.result()}))), demo.this.ImageUpload.jsonFormat())));
def pme123$adapters$client$demo$DemoWithLongerNameRunJobDialog$$$anonfun$demoForm$140__Lorg_scalajs_dom_raw_UIEvent__Lorg_scalajs_dom_raw_HTMLInputElement__Lorg_scalajs_dom_raw_FileReader__V(x$3: any, demoDescr$1: any, reader$1: any) {
this.socket__Lpme123_adapters_client_ClientWebsocket().runAdapter__s_Option__V(new s_Some().init___O(mod:Lplay_api_libs_json_Json$.toJson__O__Lplay_api_libs_json_Writes__Lplay_api_libs_json_JsValue(new Lpme123_adapters_shared_demo_ImageUpload().init___T__T(demoDescr$1["value"].asInstanceOf[T], new s_StringContext().init___sc_Seq(new sjs_js_WrappedArray().init___sjs_js_Array(["", ""])).s__sc_Seq__T(new sjs_js_WrappedArray().init___sjs_js_Array([reader$1["result"]]))), mod:Lpme123_adapters_shared_demo_ImageUpload$.jsonFormat__Lplay_api_libs_json_OFormat())))
}
@pme123 The init___sc_Seq is actually the constructor of StringContext (used for string interpolation). I don't think your StackOverflow code will cause this error, considering your StackOverflow code does not use string interpolation at all.
As described in the Stackoverflow question:
If I comment /*reader.onload = (_: UIEvent) => ... } */ it works.
It doesn't matter what is in the onload function. I tried empty, println("hello")
Interesting...
I used to think that other expressions like println would not create init___sc_Seq.