Skip to content

Commit fb98d33

Browse files
fix dropped AvroType @doc annotations (#5879)
1 parent 9915816 commit fb98d33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scio-avro/src/main/scala/com/spotify/scio/avro/types/SchemaProvider.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,13 @@ private[types] object SchemaProvider {
110110
}
111111

112112
private def fieldDoc(t: Type): Iterable[Option[String]] = {
113-
val tpe = "com.spotify.scio.avro.types.doc"
113+
// Scala 2.13.17+ resolves annotation type using `com.spotify.scio.avro.doc` alias; previous Scala
114+
// versions (and all 2.12 versions) resolve to `com.spotify.scio.avro.types.doc`
115+
// See: https://github.com/spotify/scio/issues/5874
116+
val tpes = Set("com.spotify.scio.avro.types.doc", "com.spotify.scio.avro.doc")
114117
t.typeSymbol.asClass.primaryConstructor.typeSignature.paramLists.head.map {
115118
_.annotations
116-
.find(_.tree.tpe.toString == tpe)
119+
.find(a => tpes.contains(a.tree.tpe.toString))
117120
.map { a =>
118121
val q"new $_($v)" = a.tree: @nowarn
119122
val Literal(Constant(s)) = v: @nowarn

0 commit comments

Comments
 (0)