From 7f9e6145ba7b2ba5c599ac2560805acd0495f184 Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Tue, 5 Dec 2023 17:02:24 +0100 Subject: [PATCH] chore: Add test to close issue 2555 --- .../tests/pc/SyntheticDecorationsSuite.scala | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/cross/src/test/scala/tests/pc/SyntheticDecorationsSuite.scala b/tests/cross/src/test/scala/tests/pc/SyntheticDecorationsSuite.scala index c2c20b64d7b..9ab2c910ab8 100644 --- a/tests/cross/src/test/scala/tests/pc/SyntheticDecorationsSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/SyntheticDecorationsSuite.scala @@ -590,4 +590,82 @@ class SyntheticDecorationsSuite extends BaseSyntheticDecorationsSuite { |} |""".stripMargin ) + + check( + "complex", + """|object ScalatestMock { + | class SRF + | implicit val subjectRegistrationFunction: SRF = new SRF() + | class Position + | implicit val here: Position = new Position() + | implicit class StringTestOps(name: String) { + | def should(right: => Unit)(implicit config: SRF): Unit = () + | def in(f: => Unit)(implicit pos: Position): Unit = () + | } + | implicit def instancesString: Eq[String] with Semigroup[String] = ??? + |} + | + |trait Eq[A] + |trait Semigroup[A] + | + |class DemoSpec { + | import ScalatestMock._ + | + | "foo" should { + | "checkThing1" in { + | checkThing1[String] + | } + | "checkThing2" in { + | checkThing2[String] + | } + | } + | + | "bar" should { + | "checkThing1" in { + | checkThing1[String] + | } + | } + | + | def checkThing1[A](implicit ev: Eq[A]) = ??? + | def checkThing2[A](implicit ev: Eq[A], sem: Semigroup[A]) = ??? + |} + |""".stripMargin, + """|object ScalatestMock { + | class SRF + | implicit val subjectRegistrationFunction: SRF = new SRF() + | class Position + | implicit val here: Position = new Position() + | implicit class StringTestOps(name: String) { + | def should(right: => Unit)(implicit config: SRF): Unit = () + | def in(f: => Unit)(implicit pos: Position): Unit = () + | } + | implicit def instancesString: Eq[String] with Semigroup[String] = ??? + |} + | + |trait Eq[A] + |trait Semigroup[A] + | + |class DemoSpec { + | import ScalatestMock._ + | + | StringTestOps("foo") should { + | StringTestOps("checkThing1") in { + | checkThing1[String](instancesString) + | }(here) + | StringTestOps("checkThing2") in { + | checkThing2[String](instancesString, instancesString) + | }(here) + | }(subjectRegistrationFunction) + | + | StringTestOps("bar") should { + | StringTestOps("checkThing1") in { + | checkThing1[String](instancesString) + | }(here) + | }(subjectRegistrationFunction) + | + | def checkThing1[A](implicit ev: Eq[A]): Nothing = ??? + | def checkThing2[A](implicit ev: Eq[A], sem: Semigroup[A]): Nothing = ??? + |} + |""".stripMargin + ) }