Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created September 30, 2025 23:16
Show Gist options
  • Save xuwei-k/581f382309227966164b1d3641caf349 to your computer and use it in GitHub Desktop.
Save xuwei-k/581f382309227966164b1d3641caf349 to your computer and use it in GitHub Desktop.

build.sbt

scalaVersion := "2.13.17"

scalacOptions ++= Seq("-Xsource:3")

Compile / PB.targets += (
  scalapb.gen(scala3Sources = true) -> (Compile / sourceManaged).value / "scalapb"
)

libraryDependencies ++= Seq(
  "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion
)

project/build.properties

sbt.version=1.11.6

project/plugins.sbt

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.8")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.20"

src/main/protobuf/a.proto

syntax = "proto3";

message A {
  enum B {
    B1 = 0;
    B2 = 1;
  }

  repeated B c = 1;
}

sbt compile result

[error] scalapb-2-13-17-example/target/scala-2.13/src_managed/main/scalapb/a/A.scala:46:30: missing argument list for method writeEnumNoTag in class CodedOutputStream of type (value: Int): Unit
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] Use -Xsource-features:eta-expand-always to convert even if the expected type is not a function type.
[error] You can make this conversion explicit by writing `writeEnumNoTag _` or `writeEnumNoTag(_)` instead of `writeEnumNoTag`.
[error]         c.foreach((_output__.writeEnumNoTag).compose((_: a.A.B).value))
[error]                              ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment