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

Compile error in a Scala.js project #52

Open
fthomas opened this issue Jul 17, 2015 · 7 comments
Open

Compile error in a Scala.js project #52

fthomas opened this issue Jul 17, 2015 · 7 comments
Labels

Comments

@fthomas
Copy link
Collaborator

fthomas commented Jul 17, 2015

I'm trying to use sbt-doctest in refined which is a JVM/JS cross project. Compiling the test sources for Scala.js (sbt refinedJS/test) yields the following error:

[error] refined/js/target/scala-2.11/src_managed/test/eu/timepit/refined/numericDoctest.scala:16: You may not export a local class
[error] include(new org.scalacheck.Properties("numeric") {
[error] ^
[error] one error found
@fthomas fthomas added the bug label Jul 17, 2015
@fthomas
Copy link
Collaborator Author

fthomas commented Jul 18, 2015

I should mention that this can be reproduced by enabling sbt-doctest here: https://github.com/fthomas/refined/blob/d200633c714de3dcb980f55a35520129b1bc91c8/build.sbt#L178

@fthomas
Copy link
Collaborator Author

fthomas commented Jul 29, 2015

The above error can be fixed with

--- a/src/main/scala/com/github/tkawachi/doctest/ScalaCheckGen.scala
+++ b/src/main/scala/com/github/tkawachi/doctest/ScalaCheckGen.scala
@@ -22,9 +22,9 @@ object ScalaCheckGen extends TestGen {
   }

   def generateExample(basename: String, parsed: ParsedDoctest): String = {
-    s"""  include(new org.scalacheck.Properties("${parsed.symbol}") {
+    s"""  {
        |${parsed.components.map(gen(parsed.lineNo, _)).mkString("\n\n")}
-       |  })""".stripMargin
+       |  }""".stripMargin
   }

But now I'm getting runtime errors because of the usage of scala.runtime.ScalaRunTime in

  def sbtDoctestReplString(any: Any): String = {
    val s = scala.runtime.ScalaRunTime.replStringOf(any, 1000).init
    if (s.headOption == Some('\n')) s.tail else s
  }

The errors look like this:

[error] Referring to non-existent method jl_Class.getPackage__jl_Package
[error]   called from sr_ScalaRunTime$.packageOf$1__p1__O__T
[error]   called from sr_ScalaRunTime$.isScalaClass$1__p1__O__Z
[error]   called from sr_ScalaRunTime$.useOwnToString$1__p1__O__Z
[error]   called from sr_ScalaRunTime$.inner$1__p1__O__I__T
[error]   called from sr_ScalaRunTime$.$$anonfun$7__p1__I__O__T
[error]   called from sr_ScalaRunTime$.inner$1__p1__O__I__T
[error]     (already seen, not repeating call stack)
[error] involving instantiated classes:
[error]   sr_ScalaRunTime$

@ceedubs
Copy link
Contributor

ceedubs commented Dec 9, 2015

I think this is related: typelevel/scalacheck#208

@tkawachi
Copy link
Collaborator

tkawachi commented Dec 9, 2015

scala.runtime.ScalaRunTime.replStringOf() is used to get the same string representation as in REPL.
It uses methods which is not implemented by Scala.js.
https://github.com/scala/scala/blob/v2.11.7/src/library/scala/runtime/ScalaRunTime.scala#L264-L340

I'm afraid it's hard to port replStringOf() to scala.js.

@tkawachi
Copy link
Collaborator

The next version will require JvmPlugin.
08473ab#diff-80f647238c7cff18df190250d41c16eeR35

@frgomes
Copy link
Contributor

frgomes commented Jun 19, 2017

You guys may eventually be interested on #78, #80, #84, #85

@frgomes
Copy link
Contributor

frgomes commented Jul 11, 2017

The compilation error reported initially is over.
But there's still some remaining leftovers.
Evidences of that at fthomas/refined#306

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

No branches or pull requests

4 participants