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 2.12 -> 2.13 regression in type inference dealising #11660

Open
japgolly opened this issue Aug 4, 2019 · 0 comments

Comments

@japgolly
Copy link

commented Aug 4, 2019

Hello. I have a case in scalajs-react where code compiles under 2.12 but results in a compilation error in 2.13.

// This doesn't compile in either 2.12 or 2.13
val x1: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.None                  ] = start
val x2: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.Some[x1.SnapshotValue]] = x1.componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))
val x3: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.Some[x1.SnapshotValue]] = x2.componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))
implicitly[x1.SnapshotValue =:= Unit]

// This compiles in both 2.12 and 2.13, we've just unalised y1.SnapshotValue to Unit
val y1: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.None      ] = start
val y2: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.Some[Unit]] = y1.componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))
val y3: Step4[InferenceUtil.P,Children.None,Unit,Unit,UpdateSnapshot.Some[Unit]] = y2.componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))
implicitly[y1.SnapshotValue =:= Unit]

// If we let type inference do its thing on the following block...
//   - on Scala 2.13.0 it infers the types in the first case above, and fails to compile
//   - on Scala 2.12.8 it infers the types in the second case above, and compiles
start
  .componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))
  .componentDidUpdate($ => Callback(testExpr($.snapshot).expect[Unit]))

Reproduction here:

https://github.com/japgolly/scalajs-react/blob/scala213-bug/test/src/test/scala/japgolly/scalajs/react/core/ScalaBuilderTest.scala#L80-L102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.