ScalaPB icon indicating copy to clipboard operation
ScalaPB copied to clipboard

Support -Yexplicit-nulls compiler option

Open PhoenixmitX opened this issue 1 year ago • 0 comments

Originally posted in https://github.com/apache/pekko-grpc/issues/335

Problem

The generated code by the sbt plugin does not support compiling with the -Yexplicit-nulls compiler option

Expected behavior

Auto generated code does compile without errors when using -Yexplicit-nulls compiler option

Steps to reproduce

add this to your build.sbt, and try to compile:

ThisBuild / scalacOptions += "-Yexplicit-nulls"

even an empty .proto file causes the compilation to fail

example log when trying to compile with one empty proto file

[error] 20 |    com.google.protobuf.Descriptors.FileDescriptor.buildFrom(javaProto, _root_.scala.Array(
[error]    |    ^
[error]    |    Found:    com.google.protobuf.Descriptors#FileDescriptor | Null
[error]    |    Required: com.google.protobuf.Descriptors.FileDescriptor
[error] 21 |    ))
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[warn] 9 |  lazy val messagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty
[warn]   |                                                                            ^
[warn]   |`_` is deprecated for wildcard arguments of types: use `?` instead
[warn]   |This construct can be rewritten automatically under -rewrite -source 3.4-migration.

PhoenixmitX avatar Jun 23 '24 14:06 PhoenixmitX