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 fails in Scala 2.11.7 project #6

Open
benedictleejh opened this issue Oct 31, 2015 · 4 comments
Open

Compile fails in Scala 2.11.7 project #6

benedictleejh opened this issue Oct 31, 2015 · 4 comments

Comments

@benedictleejh
Copy link

I'm using Scala 2.11.7 with UndoFX in my project, and when I try to compile, the compile fails with assertion failed: TVar<?0=null>.

This only happens with UndoFX 1.2, and it was fine before on UndoFX 1.1.1, and the only changes I've made are to comply with 1.2's new interface. I've even changed from using SAM conversion to instantiate the undo manager to anonymous classes, and the failure still takes place. Even a stacktrace simply spits out internal Scala compiler errors, so I can't quite debug what's causing the error.

My build tool is Gradle 2.7, if it means anything.

I've also tried this on a fresh Gradle Scala project, and the same error results.

This is the sample code for the fresh project that fails to compile:

import java.util.function.{Consumer, Function}

import org.fxmisc.undo.UndoManagerFactory
import org.reactfx.EventSource

object Main {
  val changes = new EventSource[Change]

  val undoManager = UndoManagerFactory.unlimitedHistoryUndoManager(
  changes,
  new Function[Change, Change] {
    override def apply(t: Change): Change = t.invert
  },
  new Consumer[Change] {
    override def accept(t: Change): Unit = t.apply()
  }
  )

}

case class Change(oldVal: Boolean, newVal: Boolean) {
  def invert: Change = Change(newVal, oldVal)

  def apply(): Unit = println(newVal)
}
@TomasMikula
Copy link
Member

Well, if there is an assertion error during compilation, that either means there is a bug in the Scala compiler, or the bytecode of UndoFX is somehow malformed (which is less likely because Java compiler seems to work with it just fine). I would try Scala 2.12.0-M3 and if it still fails, try reporting it to the Scala team.

@benedictleejh
Copy link
Author

I've tried it on 2.12.0-M3, and the bug still appears. As you've suggested, I've filed an issue to the Scala issue tracker here: https://issues.scala-lang.org/browse/SI-9543

@TomasMikula
Copy link
Member

👍

@benedictleejh
Copy link
Author

As I've noted in the comment in the Scala language issue, introducing a type parameter to the method call instead of letting Scala infer it allows the code to compile. That is, specifying what T is in UndoManagerFactory.unlimitedHistoryUndoManager[T]() allows working around the type inference failure for the moment.

On a related note, SAM conversion doesn't work for the new method signature in 1.2 as well.

Hopefully, this information is useful to someone working with UndoFX in Scala.

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

No branches or pull requests

2 participants