scalapb/ScalaPB

Scalapb.proto would result in a name clash for clearExtension method in OneofOptionsBuilder

Closed this issue · 8 comments

Attached is the stack trace for the issue

scala-2.12/src_managed/main/scalapb/options/Scalapb.java:22721:1: name clash: clearExtension(com.google.protobuf.GeneratedMessage.GeneratedExtension<scalapb.options.Scalapb.OneofOptions,?>) in scalapb.options.Scalapb.OneofOptions.Builder and clearExtension(com.google.protobuf.GeneratedMessage.GeneratedExtension<scalapb.options.Scalapb.OneofOptions,T>) in com.google.protobuf.GeneratedMessageV3.ExtendableBuilder have the same erasure, yet neither overrides the other
[error] @java.lang.Override
[error]       public <Type> Builder clearExtension(
[error]           com.google.protobuf.GeneratedMessage.GeneratedExtension<
[error]               scalapb.options.Scalapb.OneofOptions, ?> extension) {
[error]         return super.clearExtension(extension);
[error]       }
[error] /builds/snd/schemas/tools/scala/target/scala-2.12/src_managed/main/scalapb/options/Scalapb.java:22720:1: method does not override or implement a method from a supertype

Wondering if anyone faced the same issue before?

This issue came about as we upgraded to use 0.11.14

Scala: 2.12.12
sbt-protoc: 1.0.6

Can you provide step-by-step instructions on how to reproduce the problem you are seeing?

I've setup a small sample project here: https://github.com/shikai93/scalapb-test
I hope thats helpful ~
It only contains the scalapb.proto and google well-known protos.

Can you include the project directory and build.sbt files? Is it possible that you are trying to generate Scala or Java code for protos in protos/google/protobuf which already have classes generated for?

It looks like it is generating code for messages that are already included with protobuf-java here: https://github.com/shikai93/scalapb-test/blob/24c0e187c5d9aa9e1ea15eb78d792c85d7bab630/scala/project/Settings.scala#L18

They can be made available by adding:

libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"

they are actually within the scala folder, let me pull them up one level.

you are right that i am trying to generate the messages already included. But i did not integrate in the relevant dependencies for common-proto
libraryDependencies ++= Seq( "com.thesamet.scalapb.common-protos" %% "proto-google-common-protos-scalapb_0.11" % "2.9.6-0" % "protobuf", "com.thesamet.scalapb.common-protos" %% "proto-google-common-protos-scalapb_0.11" % "2.9.6-0" )
so i was under the impression that this clash would not occur

But i did not integrate in the relevant dependencies for common-proto

The one causing the problem are the one in google/protobuf which are included in scalapb-runtime for Scala and protobuf-java for Java.

I see, i think this was a change induced in 0.11.14?
But yes, changing them to includePath worked for my case, updated my test case repo, thanks for the help! I shall close this issue

The error seems to appear in the Java generated code, maybe there's a bump in the protoc version somewhere in your toolchain that triggered it, but it's odd that this set up ever worked.