Skip to content

Commit fed95b5

Browse files
halotukozakclaude
andcommitted
fix: missing Fallback import in AsRaw/AsReal, unused-given warnings in tests
AsRawReal.scala fully-qualified mrpc.Fallback but AsRaw.scala/AsReal.scala didn't import it at all - never caught locally because the CI test hang (fixed in #16) meant this branch was never actually compiled end to end until now. Also marks the intentionally-shadowed Fallback givens in FallbackSuite/ MetadataFallbackSuite's "normal given wins" tests as @unused - their presence-but-non-resolution is exactly what's being asserted, which -Wunused:all -Werror otherwise flags as dead code. Verified: full `scala-cli test .` passes (0 failed except the pre-existing, already-documented AnnotationCaptureSuite issue from #16). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent fdffa5d commit fed95b5

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/mrpc/conv/AsRaw.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package mrpc.conv
1+
package mrpc
2+
package conv
23

34
import scala.concurrent.{ExecutionContext, Future}
45
import scala.util.Try

src/mrpc/conv/AsReal.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package mrpc.conv
22

3+
import mrpc.Fallback
4+
35
import scala.concurrent.{ExecutionContext, Future}
46
import scala.util.Try
57

test/mrpc/conv/FallbackSuite.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package mrpc.conv
22

33
import mrpc.Fallback
44

5+
import scala.annotation.unused
6+
57
/**
68
* DIVERGENCES.md D17: `Fallback[T]` lowers an implicit's priority below normal givens. Proves both
79
* halves — a `Fallback`-wrapped instance is picked up when nothing else resolves, AND a normal given
@@ -17,7 +19,8 @@ class FallbackSuite extends munit.FunSuite:
1719
assertEquals(summon[AsRaw[String, Wrapped]].asRaw(Wrapped("x")), "x")
1820

1921
test("AsRaw: a normal given wins over a Fallback-wrapped competitor, no ambiguity"):
20-
given Fallback[AsRaw[String, Wrapped]] = Fallback((_: Wrapped) => "from-fallback")
22+
// Present but never actually resolved — that's exactly the point being asserted below.
23+
@unused given Fallback[AsRaw[String, Wrapped]] = Fallback((_: Wrapped) => "from-fallback")
2124
given AsRaw[String, Wrapped] = (w: Wrapped) => "from-normal:" + w.s
2225
assertEquals(summon[AsRaw[String, Wrapped]].asRaw(Wrapped("x")), "from-normal:x")
2326

@@ -26,7 +29,8 @@ class FallbackSuite extends munit.FunSuite:
2629
assertEquals(summon[AsReal[String, Wrapped]].asReal("x"), Wrapped("x"))
2730

2831
test("AsReal: a normal given wins over a Fallback-wrapped competitor, no ambiguity"):
29-
given Fallback[AsReal[String, Wrapped]] = Fallback((_: String) => Wrapped("from-fallback"))
32+
// Present but never actually resolved — that's exactly the point being asserted below.
33+
@unused given Fallback[AsReal[String, Wrapped]] = Fallback((_: String) => Wrapped("from-fallback"))
3034
given AsReal[String, Wrapped] = (s: String) => Wrapped("from-normal:" + s)
3135
assertEquals(summon[AsReal[String, Wrapped]].asReal("x"), Wrapped("from-normal:x"))
3236

@@ -37,7 +41,8 @@ class FallbackSuite extends munit.FunSuite:
3741
assertEquals(instance.asReal("x"), Wrapped("x"))
3842

3943
test("AsRawReal: fromSeparate (built from AsRaw+AsReal givens) wins over a Fallback competitor"):
40-
given Fallback[AsRawReal[String, Wrapped]] =
44+
// Present but never actually resolved — that's exactly the point being asserted below.
45+
@unused given Fallback[AsRawReal[String, Wrapped]] =
4146
Fallback(AsRawReal.create[String, Wrapped](_ => "from-fallback", _ => Wrapped("from-fallback")))
4247
given AsRaw[String, Wrapped] = (w: Wrapped) => "from-separate:" + w.s
4348
given AsReal[String, Wrapped] = (s: String) => Wrapped("from-separate:" + s)

test/mrpc/meta/MetadataFallbackSuite.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package mrpc.meta
33
import mrpc.Fallback
44
import mrpc.derive.SampleApi.SampleApi
55

6+
import scala.annotation.unused
7+
68
/**
79
* DIVERGENCES.md D17: `RpcMetadataCompanion.fromFallback` mirrors commons `MetadataCompanion.fromFallback` —
810
* a `Fallback[M[Real]]` resolves via implicit search when no normal `given M[Real]` is in scope, but a
@@ -19,6 +21,7 @@ class MetadataFallbackSuite extends munit.FunSuite:
1921
assertEquals(summon[SimpleMeta[SampleApi]].tag, "from-fallback")
2022

2123
test("a normal given wins over a Fallback-wrapped competitor, no ambiguity"):
22-
given Fallback[SimpleMeta[SampleApi]] = Fallback(SimpleMeta("from-fallback"))
24+
// Present but never actually resolved — that's exactly the point being asserted below.
25+
@unused given Fallback[SimpleMeta[SampleApi]] = Fallback(SimpleMeta("from-fallback"))
2326
given SimpleMeta[SampleApi] = SimpleMeta("from-normal")
2427
assertEquals(summon[SimpleMeta[SampleApi]].tag, "from-normal")

0 commit comments

Comments
 (0)