Skip to content

Commit 67d0fb9

Browse files
committed
Remove multiple implicitly calls. Still getting: Pojo does not take parameters
1 parent 994a4c8 commit 67d0fb9

File tree

11 files changed

+148
-288
lines changed

11 files changed

+148
-288
lines changed

build.sbt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ inThisBuild(
55
Seq(
66
version := "0.1",
77
scalaVersion := "2.13.5",
8-
scalacOptions ++= "-Ymacro-annotations" :: "-language:experimental.macros" :: Nil
8+
scalacOptions ++= Seq(
9+
"-Ymacro-annotations",
10+
"-language:experimental.macros",
11+
//"-Xlog-implicits",
12+
"-Ymacro-debug-lite"
13+
),
14+
// for nicer error messages
15+
addCompilerPlugin("io.tryp" % "splain" % "0.5.8" cross CrossVersion.patch)
916
)
1017
)
1118

@@ -28,6 +35,7 @@ lazy val `scala-macros-usage` = (project in file("scala-macros-usage"))
2835
libraryDependencies ++= Seq(
2936
scalaPbRuntime,
3037
beamSdksJavaCore,
31-
beamRunnersDirectJava
38+
beamRunnersDirectJava,
39+
scalaTest
3240
)
3341
)

project/Dependencies.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ object Dependencies {
77
val beamVersion = "2.28.0"
88
val beamSdksJavaCore = "org.apache.beam" % "beam-sdks-java-core" % beamVersion
99
val beamRunnersDirectJava = "org.apache.beam" % "beam-runners-direct-java" % beamVersion % Runtime
10+
11+
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.7" % Test
1012
}

scala-macros-usage/src/main/scala/com/github/fpopic/scalamacros/AnnotationMacroUsage.scala

Lines changed: 0 additions & 23 deletions
This file was deleted.

scala-macros-usage/src/main/scala/com/github/fpopic/scalamacros/DefMacroCoderUsage.scala

Lines changed: 0 additions & 30 deletions
This file was deleted.

scala-macros-usage/src/main/scala/com/github/fpopic/scalamacros/DefMacroUsageCombinedWithIdentityAnnotation.scala

Lines changed: 0 additions & 31 deletions
This file was deleted.

scala-macros-usage/src/main/scala/com/github/fpopic/scalamacros/Person.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.github.fpopic.scalamacros.beam
2+
3+
import org.apache.beam.sdk.coders.Coder
4+
import org.scalatest.flatspec.AnyFlatSpec
5+
import org.scalatest.matchers.should.Matchers
6+
7+
import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
8+
9+
class DefMacroCoderSpec extends AnyFlatSpec with Matchers {
10+
11+
behavior of "DefMacroCoder"
12+
13+
private case class Pojo(s: String, i: Int, l: List[Int])
14+
// TODO try with nested class (check magnolia)
15+
// e.g case class Nojo(a: String, p: Pojo)
16+
17+
it should "generate a coder and serialize/deserialize properly the value." in {
18+
19+
val coder: Coder[Pojo] = DefMacroCoder.productCoder[Pojo]
20+
21+
val pojo = Pojo(s = "4", i = 1, l = List(2, 3))
22+
23+
val encoded: Array[Byte] = {
24+
val os = new ByteArrayOutputStream()
25+
coder.encode(pojo, os)
26+
os.toByteArray
27+
}
28+
val decoded: Pojo = coder.decode(new ByteArrayInputStream(encoded))
29+
30+
pojo shouldBe decoded
31+
}
32+
33+
}

scala-macros/src/main/scala/com/github/fpopic/scalamacros/AnnotationMacroIdentityExample.scala

Lines changed: 0 additions & 53 deletions
This file was deleted.

scala-macros/src/main/scala/com/github/fpopic/scalamacros/DefMacroToMapExample.scala

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)