Skip to content
Permalink
Browse files
make generated case classes final by default.
  • Loading branch information
stewSquared committed Dec 9, 2016
1 parent bd3c24b commit 0e869e94b1523cae2774c078d274fd706d6ae3bb
@@ -117,8 +117,10 @@ abstract class AbstractGenerator[Code,TermName,TypeName](model: m.Model)
trait EntityTypeDef extends TypeDef{
/** Column types */
def types: Code = compoundType(columns.map(_.exposedType))
/** Indicated whether a case class should be generated. Otherwise a type alias. */
/** Indicates whether a case class should be generated. Otherwise a type alias. */
def classEnabled = mappingEnabled
/** Indicates whether a generated case class should be final. */
def caseClassFinal = true
def doc =
if(classEnabled){
s"Entity class storing rows of table ${TableValue.name}\n" +
@@ -78,6 +78,7 @@ abstract class AbstractSourceCodeGenerator(model: m.Model)
).mkString(", ")
if(classEnabled){
val prns = (parents.take(1).map(" extends "+_) ++ parents.drop(1).map(" with "+_)).mkString("")
(if(caseClassFinal) "final " else "") +
s"""case class $name($args)$prns"""
} else {
s"""

3 comments on commit 0e869e9

@dmarwick

This comment has been minimized.

Copy link

@dmarwick dmarwick replied Apr 27, 2017

We just upgraded to 3.2.0 and this change produces a compiler warning:

The outer reference in this type test cannot be checked at run time.

Is this expected by default? Thanks

@stewSquared

This comment has been minimized.

Copy link
Contributor Author

@stewSquared stewSquared replied Apr 27, 2017

@dmarwick Setting default to true was a mistake because of the errors in the default code generator. It's set to false in 3.2.1. See #1709

For now, you'll have to either (1) not generate case classes inside the table trait or (2) override caseClassFinal to default to false.

@dmarwick

This comment has been minimized.

Copy link

@dmarwick dmarwick replied Apr 28, 2017

Thanks, @stewSquared! We overrode it to false for now and will plan to revert the override in 3.2.1+.

Please sign in to comment.