-
Notifications
You must be signed in to change notification settings - Fork 26
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
Switch from abstract val to def in traits #788
base: main
Are you sure you want to change the base?
Conversation
protected def isEmpty(v: T): Boolean | ||
def write(c: RecordConsumer, v: T)(cm: CaseMapper): Unit | ||
def newConverter: TypeConverter[T] | ||
def newConverter(): TypeConverter[T] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function has a side effect and should hence be defined with parenthesis
7e5f32f
to
8054da3
Compare
@@ -133,7 +133,7 @@ object ProtobufField { | |||
new ProtobufField[T] { | |||
override type FromT = tc.FromT | |||
override type ToT = tc.ToT | |||
override val hasOptional: Boolean = tc.hasOptional | |||
override def hasOptional: Boolean = tc.hasOptional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these implementation cases, isn't it preferable to define these fields as val
(or maybe lazy val
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only case where there is some computation is in Record
where it is already a val. IMHO here it is not worth caching another constant
e05f535
to
7d1b796
Compare
Prefer using
def
over abstractval
in traits.This increases implementation flexibility and avoid unnecessary serialization and memory usage (when referring to a constant for instance)