Scalapb: Invalid Scala code generated if extension fields contain Scala reserved words

Created on 21 May 2019  路  9Comments  路  Source: scalapb/ScalaPB

Forgive me if this has been addressed in newer releases - I did a quick issue search but nothing has come up. With the akka-grpc codegen (compilerplugin 0.8.4) I get this:

Result:

target/scala-2.12/src_managed/main/myext/MyextProto.scala:34:7: illegal start of simple pattern
[error]   val type: _root_.scalapb.GeneratedExtension[com.google.protobuf.descriptor.FieldOptions, _root_.scala.Option[myext.TypeOpts]] =
[error]       ^
[error] /Users/econlon/Downloads/akka-grpc-quickstart-scala/target/scala-2.12/src_managed/main/myext/MyextProto.scala:36:1: '=' expected but '}' found.
[error] }

Repro:

myext.proto:

syntax="proto2";

import "google/protobuf/descriptor.proto";

package myext;

message TypeOpts {
    oneof type {
      bool option_a  =  7;
      bool option_b  =  8;
    }
  }

extend google.protobuf.FieldOptions {
    optional TypeOpts type = 90210;
}

helloworld.proto:

syntax = "proto3";

import "myext.proto";

message HelloRequest {
    string name = 1 [(myext.type).option_b = true];
}

Most helpful comment

@ejconlon - I've just released 0.9.0-M6

All 9 comments

I will try to repro tonight with the standard scalapb codegen at version 0.9.0-RC1 .

Reproduced with latest 0.9.0-RC1. https://github.com/ejconlon/spbrepro

I can try to fix this if someone can help me figure out where to make the change, where to put the test cases, etc.

I think 0.9.0-M5 is more recent, does it still repro in there?

Thanks for reporting and putting together a test case!

Great work @thesamet ! Thank you!

@thesamet What's the timeline for new milestones or RCs? I would love to get this upstream to akka-grpc. (I'm finding it hard to plumb the change through git deps...)

I'll cut another release this weekend and update here.

@ejconlon - I've just released 0.9.0-M6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timo-schmid picture timo-schmid  路  38Comments

ngbinh picture ngbinh  路  4Comments

mroth picture mroth  路  10Comments

jon-morra-zefr picture jon-morra-zefr  路  14Comments

xuwei-k picture xuwei-k  路  6Comments