-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Labels
questionThis is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.This is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.
Description
When compiling zio-prelude with ScalaJS 1.18.x, the compilation fails with multiple errors:
error]
[error] Cannot resolve delambdafy target method $anonfun$assertion$1 at source-/home/runner/work/zio-prelude/zio-prelude/core-tests/shared/src/test/scala-2.12-2.13/zio/prelude/NewtypeSpecTypes212.scala,line-7,offset=161
[error] while compiling: /home/runner/work/zio-prelude/zio-prelude/core-tests/shared/src/test/scala-2.12-2.13/zio/prelude/NewtypeSpecTypes212.scala
[error] during phase: jscode
[error] library version: version 2.13.16
[error] compiler version: version 2.13.16
[error]
[error] last tree to typer: TypeTree(class List)
[error] tree position: line 361 of /home/runner/work/zio-prelude/zio-prelude/core-tests/shared/src/test/scala/zio/prelude/ForEachSpec.scala
[error] tree tpe: List
[error] symbol: (sealed abstract) class List in package immutable
[error] symbol definition: sealed abstract class List extends AbstractSeq with LinearSeq with LinearSeqOps with StrictOptimizedLinearSeqOps with StrictOptimizedSeqOps with IterableFactoryDefaults with DefaultSerializable (a ClassSymbol)
[error] symbol package: scala.collection.immutable
[error] symbol owners: class List
[error] call site: <$anon: Function1> in package fx in package fx
[error]
[error] == Source file context for tree position ==
[error]
[error] 358 val actual = values.foldMapM(errorOnOddNumber)
[error] 359
[error] 360 assert(actual)(equalTo(expected)) &&
[error] 3[61](https://github.com/zio/zio-prelude/actions/runs/13171977585/job/36763853813#step:6:62) assert(calledOn)(equalTo(List(3, 2)))
[error] 3[62](https://github.com/zio/zio-prelude/actions/runs/13171977585/job/36763853813#step:6:63) }
[error] 3[63](https://github.com/zio/zio-prelude/actions/runs/13171977585/job/36763853813#step:6:64) )
[error] 364 )
[error] Error while emitting NewtypeSpecTypes212.scala
[error]
[error] Cannot resolve delambdafy target method $anonfun$assertion$1 at source-/home/runner/work/zio-prelude/zio-prelude/core-tests/shared/src/test/scala-2.12-2.13/zio/prelude/NewtypeSpecTypes212.scala,line-7,offset=161
[error] while compiling: /home/runner/work/zio-prelude/zio-prelude/core-tests/shared/src/test/scala-2.12-2.13/zio/prelude/NewtypeSpecTypes212.scala
[error] during phase: jscode
[error] library version: version 2.13.16
[error] compiler version: version 2.13.16
The PR updating SclaJS can be found here: zio/zio-prelude#1462
The CI build failing can be found here: https://github.com/zio/zio-prelude/actions/runs/13171977585/job/36763853813
NewtypeSpecTypes212.scala
code is:
package zio.prelude
// scalafix:off
object NewtypeSpecTypes212 {
object Palindrome extends Newtype[String] {
override def assertion = assertCustom { str =>
if (str.reverse == str) Right(()) else Left(AssertionError.Failure("isPalindrome"))
}
}
Palindrome("racecar")
}
// scalafix:on
The code in ForEachSpec.scala
failing to compile seems to be the following one:
test("shortcircuits sideffects according to effect") {
var calledOn: List[Int] = Nil
def errorOnOddNumber(i: Int): Either[Int, Sum[Int]] = {
calledOn = i :: calledOn
if (i % 2 == 0) Right(Sum(i))
else Left(i)
}
val values = List(2, 3, 4)
val expected = Left(3)
val actual = values.foldMapM(errorOnOddNumber)
assert(actual)(equalTo(expected)) &&
assert(calledOn)(equalTo(List(3, 2)))
}
To reproduce locally, clone the repo and launch in an sbt console:
+rootJS/Test/compile
Metadata
Metadata
Assignees
Labels
questionThis is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.This is a question on using Scala.js. Closed because it should go to Stack Overflow or gitter.