Project

General

Profile

Bug #15797

Updated by François ARMAND over 4 years ago

See https://docs.scala-lang.org/overviews/core/value-classes.html#summary_of_limitations 

 => most of our IDs are suitable. May lead to far less pressure on GC.  


 Limitation are: 
 <pre>  
 A value class … 
  … must have only a primary constructor with exactly one public, val parameter whose type is not a user-defined value class. (From Scala 2.11.0, the parameter may be non-public.) 
  … may not have specialized type parameters. 
  … may not have nested or local classes, traits, or objects 
  … may not define a equals or hashCode method. 
  … must be a top-level class or a member of a statically accessible object 
  … can only have defs as members. In particular, it cannot have lazy vals, vars, or vals as members. 
  … cannot be extended by another class. 
 </pre> 

 We also need to remove hashcodeCaching as the general feedback for it is that the JVM knows what it does on hashcode which is perhaps the most optimized code in it, and having a lazy val (or val) forced calculated at object creation has major perf impact. 

Back