Linker error in ScalaJS: “Referring to non-existent class”

允我心安 提交于 2019-12-11 05:07:26

问题


I am getting a bunch of linker errors when trying to link to FastParse in a Scala project which I've just tried to build a ScalaJS web app in.

I added the ScalaJS dependency for FastParse into my build.sbt: here's approximately the relevant line (full file here):

libraryDependencies ++= Seq(
  "com.lihaoyi" %%% "fastparse" % "0.4.1"
)

My errors are voluminous, but here's a representative one:

[error] Referring to non-existent class fastparse.Implicits$Repeater$
[error]   called from parsers.MainParser$$anonfun$impls$1.apply()fastparse.core.Parser
[error]   called from parsers.MainParser$$anonfun$impls$1.apply()java.lang.Object
[error]   called from scala.Option.getOrElse(scala.Function0)java.lang.Object
[error]   called from fastparse.StringReprOps$.errorMessage(fastparse.utils.ParserInput,java.lang.String,scala.Int)java.lang.String
[error]   called from fastparse.core.ParseError.<init>(fastparse.core.Parsed$Failure)
[error]   called from fastparse.Api.<init>(scala.reflect.ClassTag,fastparse.utils.ElemSetHelper,fastparse.utils.ReprOps,scala.math.Ordering)
[error]   called from fastparse.StringApi.<init>()
[error]   called from fastparse.all$.<init>()
[error]   called from parsers.MainParser$.<init>()
[error]   called from webapp.WebApp$.makeChoices(java.lang.String,java.lang.String)scala.collection.immutable.List
[error]   called from webapp.WebApp$.$$js$exported$meth$makeChoices(java.lang.String,java.lang.String)java.lang.Object
[error]   called from webapp.WebApp$.makeChoices
[error]   exported to JavaScript with @JSExport
[error] involving instantiated classes:
[error]   parsers.MainParser$$anonfun$impls$1
[error]   scala.None$
[error]   scala.Some
[error]   fastparse.StringReprOps$
[error]   webapp.WebApp$

What am I doing wrong?


回答1:


The problem was that I was requiring the JVM version of FastParse two lines up in my build.sbt. This broke my build apparently. I removed that line and cleaned my build and now both the ScalaJS and ScalaJVM versions of the project are building nicely.

(Thanks heaps to Li Haoyi for spotting the problem for me)



来源:https://stackoverflow.com/questions/39586752/linker-error-in-scalajs-referring-to-non-existent-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!