From d87b9c270dccf1783c529d555825f754259da698 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 24 Jun 2021 12:55:16 +0200 Subject: [PATCH] Add regression test Closes #12910 --- tests/pos/i12910.scala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/pos/i12910.scala diff --git a/tests/pos/i12910.scala b/tests/pos/i12910.scala new file mode 100644 index 000000000000..e78408aa5e5f --- /dev/null +++ b/tests/pos/i12910.scala @@ -0,0 +1,27 @@ +trait Type[T]: + type Out + +type varchar + +given Type[varchar] with + type Out = String + +class Placeholder[T, U] + +object Placeholder: + def apply[T](using t: Type[T]): Placeholder[T, t.Out] = new Placeholder + +trait Encoder[P, X]: + def encode(x: X): String + +object Encoder: + def apply[P, X](placeholder: P)(using e: Encoder[P, X]): X => String = e.encode + + given [T, X]: Encoder[Placeholder[T, X], X] with + def encode(x: X): String = ??? + +def Test = + // the following compiles just fine + Encoder(new Placeholder[varchar, String])("hello") + // the following fails + Encoder(Placeholder[varchar])("hello")