4

I have proto files and generated Scala classes using ScalaPB. The output looks like:

@SerialVersionUID(0L)
final case class MetaData extends scalapb.GeneratedMessage {

    object HeightReferencePointEnum extends _root_.scalapb.GeneratedEnumCompanion[HeightReferencePointEnum] {
      implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[HeightReferencePointEnum] = this
        // generated code
     }
  }

Because of this Scala issue, I got an exception when calling getSimpleName for HeightReferencePointEnum class.

Is there any way to configure ScalaPB for avoiding inner classes?

The message proto is:

message MetaData {
    message HeightDetail {
        optional HeightReferencePointEnum heightReferencePoint = 1;
        enum HeightReferencePointEnum {
            // enums
        }
        optional heightReferencePointEnum heightReferencePoint = 2;
    }
    repeated HeightDetail heightDetail = 1;
}
Andriy Budzinskyy
  • 1,971
  • 22
  • 28
  • Can you please add code for the message defined in `proto` that reproduces the problem? – Ivan Stanislavciuc Feb 11 '19 at 12:37
  • @IvanStanislavciuc added message proto code – Andriy Budzinskyy Feb 11 '19 at 12:51
  • ScalaPB only generates classes at the top-level, or within companion objects, it should never generate nested classes like in the code you provided above. For the specific question, there is currently no way to make it flatten the hierarchy. Do you have workarounds such as using descriptors instead of `getSimpleName`? – thesamet Feb 12 '19 at 17:17

0 Answers0