Skip to content
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

Scalabuff removes _ chars in vaiable names and error occur when scala is compiled #130

Open
lewissk opened this issue Sep 23, 2016 · 0 comments

Comments

@lewissk
Copy link

lewissk commented Sep 23, 2016

If your protobuf looks like this (test project is located here https://github.com/lewissk/test_protobuf/tree/master):

syntax = "proto2";
package test;

option java_package = "test";
option cc_enable_arenas = true;

enum ContentCategory {
  IAB1_1 = 2;
  IAB11 = 191;
}

Then you run:

sbt compile

You will get the following error:

[error] /Users/xxx/test/protobuf_scala_test/target/src_managed/main/compiled_protobuf/test/ContentCategory.scala:11: method isIab11 is defined twice
[error]   conflicting symbols both originated in file '/Users/xxx/protobuf_scala_test/target/src_managed/main/compiled_protobuf/test/ContentCategory.scala'
[error]   def isIab11: Boolean = false
[error]       ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed

Because the scala it generates is like so:

// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!

package test


import com.trueaccord.scalapb.Descriptors

sealed trait ContentCategory extends com.trueaccord.scalapb.GeneratedEnum {
  def isIab11: Boolean = false
  def isIab11: Boolean = false
}

object ContentCategory extends com.trueaccord.scalapb.GeneratedEnumCompanion[ContentCategory] {
  @SerialVersionUID(0L)
  case object IAB1_1 extends ContentCategory {
    val id = 2
    val name = "IAB1_1"
    override def isIab11: Boolean = true
  }

  @SerialVersionUID(0L)
  case object IAB11 extends ContentCategory {
    val id = 191
    val name = "IAB11"
    override def isIab11: Boolean = true
  }

  lazy val values = Seq(IAB1_1, IAB11)
  def fromValue(value: Int): ContentCategory = value match {
    case 2 => IAB1_1
    case 191 => IAB11
  }
  lazy val descriptor = new Descriptors.EnumDescriptor(0, "ContentCategory", this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant