Skip to content

Add support for Scala.js #1

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

Merged
merged 2 commits into from
May 23, 2021
Merged

Add support for Scala.js #1

merged 2 commits into from
May 23, 2021

Conversation

milessabin
Copy link
Member

@milessabin milessabin commented May 22, 2021

This is mainly the addition of Scala.js build/publish infrastructure, however building for Scala.js revealed a couple of issues.

  • The handling of boxed primitives for Typeable was missing some instances which was only apparent when the corresponding tests failed for js.
  • The mini Eval that @TimWSpence put together for Foldable#foldRight test derivation blew up on js. When that was swapped out for a test dependency on cats-core it still failed, revealing that the use of Eval in the Foldable derivation was incorrect (a missing flatMap). This will also be an issue with the prototype Foldable implementation in Kittens for Scala 3.

@milessabin milessabin requested a review from joroKr21 May 22, 2021 20:35
@milessabin milessabin self-assigned this May 22, 2021
Copy link
Member

@joroKr21 joroKr21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@milessabin milessabin merged commit a7f2379 into main May 23, 2021
@joroKr21 joroKr21 deleted the topic/scalajs branch May 24, 2021 17:04
@joroKr21
Copy link
Member

Hmm I'm getting an error on main:

[error] Referring to non-existent class java.lang.constant.Constable
[error]   called from shapeless3.typeable.Typeable$ValueTypeable.productElement(int)java.lang.Object
[error]   called from scala.runtime.ScalaRunTime$$anon$1.next()java.lang.Object
[error]   called from scala.util.hashing.MurmurHash3.unorderedHash(scala.collection.IterableOnce,int)int
[error]   called from constructor scala.util.hashing.MurmurHash3$.<init>()void
[error]   called from scala.runtime.ScalaRunTime$._hashCode(scala.Product)int
[error]   called from scala.scalajs.js.JavaScriptException.hashCode()int
[error]   called from java.lang.Object.toString()java.lang.String
[error]   exported to JavaScript with @JSExport

Is this a Mac thing?

@milessabin
Copy link
Member Author

Have you got something standalone that reproduces that?

@joroKr21
Copy link
Member

I'm just running test

@milessabin
Copy link
Member Author

Interesting! I can't reproduce that on Linux.

@gzm0
Copy link

gzm0 commented May 25, 2021

Looks like this is more about the JDK version. Starting with JDK12, String (and probably other types) extend Constable and ConstantDesc. These interfaces are not implemented in Scala.js.

So basically, another way to look at it is that Scala.js does not support building on JDK12.

@sjrd
Copy link

sjrd commented May 25, 2021

It should be possible to avoid the reference to Constable. I assume it comes up as an inferred LUB of String and Class. It should be possible to avoid it being inferred with some explicit type somewhere.

Perhaps Scala 3 should also consider Constable as a transparent trait to avoid that problem once and for all.

@joroKr21
Copy link
Member

It should be possible to avoid the reference to Constable. I assume it comes up as an inferred LUB of String and Class. It should be possible to avoid it being inferred with some explicit type somewhere.

Except that productElement is generated code by the compiler: https://github.com/typelevel/shapeless-3/blob/main/modules/typeable/src/main/scala/shapeless3/typeable/typeable.scala#L71

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

Successfully merging this pull request may close these issues.

4 participants