Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala.JS: Cannot call lookupMethod(init___sc_Seq) on non Scala class sjs_js_Function #78

Open
pme123 opened this issue May 11, 2018 · 12 comments

Comments

@pme123
Copy link

pme123 commented May 11, 2018

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

@Atry
Copy link
Collaborator

Atry commented May 11, 2018

Could you make the bug report be minimized and reproducible?

@pme123
Copy link
Author

pme123 commented May 11, 2018

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.

@Atry
Copy link
Collaborator

Atry commented May 11, 2018

Maybe it's reproducible, but still far from minimized. It would be easier to find the cause if it is minimized.

@Atry
Copy link
Collaborator

Atry commented May 11, 2018

Also adding a -Xprint:typer flag should help if you want to investigate it.

@pme123
Copy link
Author

pme123 commented May 11, 2018

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.

@Atry
Copy link
Collaborator

Atry commented May 11, 2018

@sjrd How do you think?

@sjrd
Copy link

sjrd commented May 11, 2018

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.

@pme123
Copy link
Author

pme123 commented May 15, 2018

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

    1. log is with -Xprint:typer
    1. log is with -Xprint:mixin
    1. log is with scalajsp

The long class is called: DemoWithLongerNameRunJobDialog

@Atry
Copy link
Collaborator

Atry commented May 15, 2018

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())))
  }

@Atry
Copy link
Collaborator

Atry commented May 15, 2018

@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.

@pme123
Copy link
Author

pme123 commented May 15, 2018

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")

@Atry
Copy link
Collaborator

Atry commented May 15, 2018

Interesting...
I used to think that other expressions like println would not create init___sc_Seq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants