Search code examples
scalaliftscala-2.8

Strange type mismatch error in a legacy LiftWeb application


In a legacy application that I'm debugging I have

import _root_.net.liftweb.mapper._;
import _root_.java.math.MathContext

class User
extends LongKeyedMapper[User]
with IdPK
{
  import User._;

  def getSingleton = User;

  object name       extends MappedString(this, 80);
}

object User
extends User
with LongKeyedMetaMapper[User]
{
  override def fieldOrder = List(id, name);
}

which quite literally follows https://exploring.liftweb.net/master/index-8.html.

The code used to compile (using Maven), but now when I'm trying to recompile it years later (and with a newer JDK version) it fails with a strange type error:

[ERROR] ...User.scala:21: error: type mismatch;
[INFO]  found   : ....User.id.type (with underlying type object ....User.id)
[INFO]  required: net.liftweb.mapper.MappedField[_ >: String with scala.Long, ....User]{def jdbcFriendly(field: String): java.lang.Comparable[_ >: java.lang.String with java.
lang.Long <: java.io.Serializable] with java.io.Serializable; def dbFieldClass: java.lang.Class[_ >: String with scala.Long] with java.lang.reflect.GenericDeclaration}
[INFO]   override def fieldOrder = List(id, name);
[INFO]                                  ^

And a similar error for name. To me the types seem to be right, as Mapped... classes extend MappedField (https://liftweb.net/api/26/api/#net.liftweb.mapper.MappedString).

Versions:

  • Lift 2.2 (I tried 2.4 as well).
  • Scala 2.8 (I tried 2.8.1. as well).

Any suggestions or ideas what might have gone wrong?


Solution

  • With the help of @MateuszKubuszok (comments) I managed to compile the project. Indeed the solution was to use JDK7, with some fiddling: