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

[bugfix] capturing package names crashes at runtime #55

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.2
sbt.version=1.5.5
7 changes: 6 additions & 1 deletion src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RecorderMacro(using qctx0: Quotes) {
listener: Expr[RecorderListener[A, R]])(using qctx0: Quotes): Expr[R] = {
val termArgs: Seq[Term] = recordings.map(_.asTerm.underlyingArgument)


'{
val recorderRuntime: RecorderRuntime[A, R] = new RecorderRuntime($listener)
recorderRuntime.recordMessage($message)
Expand Down Expand Up @@ -162,7 +163,10 @@ class RecorderMacro(using qctx0: Quotes) {
}
// case TypeApply(x, ys) => recordValue(TypeApply.copy(expr)(recordSubValues(x), ys), expr)
case TypeApply(x, ys) => TypeApply.copy(expr)(recordSubValues(runtime, x), ys)
case Select(x, y) => Select.copy(expr)(recordAllValues(runtime, x), y)
case Select(x, y) =>
if(!x.symbol.flags.is(Flags.Package))
Select.copy(expr)(recordAllValues(runtime, x), y)
else expr
case Typed(x, tpe) => Typed.copy(expr)(recordSubValues(runtime, x), tpe)
case Repeated(xs, y) => Repeated.copy(expr)(xs.map(recordAllValues(runtime, _)), y)
case _ => expr
Expand Down Expand Up @@ -198,6 +202,7 @@ class RecorderMacro(using qctx0: Quotes) {
case sym if sym.isValDef => skipIdent(sym)
case _ => true
})

expr match {
case Select(_, _) if skipSelect(expr.symbol) => expr
case TypeApply(_, _) => expr
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala-3/ExpectyScala3Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@ object ExpectyScala3Test extends verify.BasicTestSuite {
assert1(z.hello(50)(using ti2) == 50 -> 50)
assert1(z.hello(128) == 25 -> 128)
}

test("Capturing package names correctly") {
assert1(cats.data.Chain(1, 2, 3).size == 3)
}
}

7 changes: 7 additions & 0 deletions src/test/scala-3/Fixtures.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cats {
package data {
object Chain {
def apply[A](a: A*) : List[A] = List(a*)
}
}
}