From 19d0ecb8a1e42858859f45586e46e51d0e0a08fb Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 16 Mar 2024 16:46:46 +0000 Subject: [PATCH] Add second test case from comment 1 --- tests/pos/i19942.1.scala | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/pos/i19942.1.scala diff --git a/tests/pos/i19942.1.scala b/tests/pos/i19942.1.scala new file mode 100644 index 000000000000..20f923886089 --- /dev/null +++ b/tests/pos/i19942.1.scala @@ -0,0 +1,29 @@ +trait Alternative[F[_]] + +opaque type Derived[A] = A +object Derived: + extension [A](derived: Derived[A]) def instance: A = derived + infix type <<<[F[_], G[_]] = [x] =>> F[G[x]] + +import Derived.* +import scala.compiletime.summonInline + +type DerivedAlternative[F[_]] = Derived[Alternative[F]] +object DerivedAlternative: + inline def apply[F[_]]: Alternative[F] = + import DerivedAlternative.given + summonInline[DerivedAlternative[F]].instance + given nested[F[_], G[_]]: DerivedAlternative[F <<< G] = ??? + +object auto: + object alternative: + transparent inline given [F[_]]: Alternative[F] = DerivedAlternative[F] + +trait Test: + import Test.* + import auto.alternative.given + val fails = summon[Alternative[OptList]] + +// Fails if companion object defined AFTER trait +object Test: + type OptList[A] = Option[List[A]]