Pull request to remove as much warnings as possible

38 views
Skip to first unread message

Scaalp

unread,
Dec 11, 2021, 7:47:53 AM12/11/21
to Lift
Hello,

I just created a pull request to remove as much warnings as possible.  Here is a summary of the modifications I made:
  • Replace using deprecated constructors of boxed java base types by Type.valueOf. E.g "new java.lang.Long(l)" becomes "java.lang.Long.valueOf(l)".
  • Use new versions of deprecated lift functions (except in mongodb_record).
  • Use Class.getDeclaredConstructor().newInstance() instead of deprecated function Class.newInstance.
  • Add empty argument list where needed. Procedure syntax is deprecated.
  • Add default case in pattern matching, by throwing an IllegalArgumentException exception, to satisfy the compiler. This could be a breaking change? Better to add the @unchecked annotation?
  • Remove deprecated (since 3.3.0) object DontMergeAttributes. Use its replacement object DontMergeClass. This could be a breaking change, but these objects are probably only used internally.
  • Use RoundingMode.HALF_UP instead of deprecated BigDecimal.ROUND_HALF_UP.
  • Remove unused imports.
  • Use method foldLeft instead of deprecated "/:".
  • Replace method TestHandler.then by TestHandler.andThen. "then" is a reserved word (since scala 2.10.0); usage as an identifier is deprecated. This could be a breaking change.
  • Don't use deprecated implicit conversion from Long to TimeSpan. Make explicit conversion.
  • Delete empty files XmlMenu.scala and JSONComet.scala.
  • Remove some final modifiers, for some case classes. The compiler reports warning for these cases. To keep the final keyword, the classes should be declared in the companion object, but that would need the addition of a new import to the users, which would be a breaking change. This concerns the classes LiftScreen, SHtml and RestHelper.
  • Remove tests concerning deprecated trait NodeSeqFunc, so that the test don't show deprecated warnings. (should it be kept ?)
  • Replace deprecated view bounds by implicit arguments.
  • Replace deprecated Travesable by Iterable.
  • Use scala.jdk.CollectionConverters instead of scala.collection.JavaConverters. Add scala-compat-library to make it work in scala 2.11 and scala 2.12.
  • Conversion from Array to List (or Set) changed from List(a:_*) to a.toList.
  • Replace local variable names "enum" by "e", because enum will become a reserved keyword in scala 3.
  • Add backticks in class EnumWithDescription, instead of renaming it, to avoid a breaking change. This class should maybe be deprecated?
  • Remove dead code.
  • Replace "0l" by "0L".
  • Didn't care about use of deprecated warnings in mongodb_record (concerning code that should be replaced with BsonableField).
  • Replace deprecated syntax 'rec by Symbol("rec").
  • Scala 2.13 cannot compile record (method displayName in object RecordRules). I am not proficient enough in scala to know how to rewrite the code.
  • squeryl-record cannot be compiled in scala 2.13. Available squeryl librairies for scala 2.13 have dropped many methods used by the code.
  • Activated compiler options to report unused imports, private and local variables and methods and remove them. Some compiler flags have been added to replace some imports.
There are many open questions.  I would be glad to discuss them with maintainers of lift.  I hope that this is not too huge for a pull request.

I am using Lift for a personel project since 2013.

Scaalp

unread,
Dec 13, 2021, 6:35:16 AM12/13/21
to Lift
With version 2.13.7 of the compiler, I have a compilation error in the code of the record project.  The class is RecordRules in package net.liftweb.record.  Here is the version that compiles in 2.12:

  val displayName: FactoryMaker[(Record[_], Locale, String) => String] =
    new FactoryMaker[(Record[_], Locale, String) => String]((m: Record[_], l: Locale, name: String) => name) {}


This generate the following compiler error with scala 2.13:

[error] …/liftweb/persistence/record/src/main/scala/net/liftweb/record/RecordRules.scala:50:9: type arguments [_$2] do not conform to trait Record's type parameter bounds [MyType <: net.liftweb.record.Record[MyType]]
[error]     new FactoryMaker[(Record[_], Locale, String) => String]((m: Record[_], l: Locale, name: String) => name) {}
[error]         ^


I tried to use an existantial type:

  import scala.language.existentials
  type RecordImpl = Record[T] forSome {type T <: Record[T]}
  val displayName: FactoryMaker[(RecordImpl, Locale, String) => String] =
    new FactoryMaker[(RecordImpl, Locale, String) => String]((m: RecordImpl, l: Locale, name: String) => name) {}


But this crashes the compiler with a StackOverflow.

   
I tried to add @unchecked annotations:

  val displayName: FactoryMaker[(Record[_] @unchecked, Locale, String) => String] =
    new FactoryMaker[(Record[_] @unchecked, Locale, String) => String]((m: Record[_] @unchecked, l: Locale, name: String) => name) {}


But the compiler still complains about unbound wildcard type:
   
[error] …/liftweb/persistence/record/src/main/scala/net/liftweb/record/RecordRules.scala:50:83: unbound wildcard type
[error]     new FactoryMaker[(Record[_] @unchecked, Locale, String) => String]((m: Record[_] @unchecked, l: Locale, name: String) => name) {}
[error]                                                                                   ^


I am not proficient enough in Scala to find how to give enough clues to satisfy the compiler.  If you have any suggestion, I would be glad to here about it.

Reply all
Reply to author
Forward
0 new messages