From 56c26744de54dcf8e0aa8cffabce9bf261ae40ad Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Wed, 7 Feb 2024 15:29:07 +0900 Subject: [PATCH] fix ImplicitValueClass if type param has context-bound --- input/src/main/scala/fix/ImplicitValueClassTest.scala | 2 ++ output/src/main/scala/fix/ImplicitValueClassTest.scala | 2 ++ rules/src/main/scala/fix/ImplicitValueClass.scala | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/input/src/main/scala/fix/ImplicitValueClassTest.scala b/input/src/main/scala/fix/ImplicitValueClassTest.scala index e778811..cb91296 100644 --- a/input/src/main/scala/fix/ImplicitValueClassTest.scala +++ b/input/src/main/scala/fix/ImplicitValueClassTest.scala @@ -52,4 +52,6 @@ object ImplicitValueClassTest { } } } + + implicit class HasContextBound[A: Option](val x: Int) } diff --git a/output/src/main/scala/fix/ImplicitValueClassTest.scala b/output/src/main/scala/fix/ImplicitValueClassTest.scala index ea33a56..e4a5f1c 100644 --- a/output/src/main/scala/fix/ImplicitValueClassTest.scala +++ b/output/src/main/scala/fix/ImplicitValueClassTest.scala @@ -49,4 +49,6 @@ object ImplicitValueClassTest { } } } + + implicit class HasContextBound[A: Option](val x: Int) } diff --git a/rules/src/main/scala/fix/ImplicitValueClass.scala b/rules/src/main/scala/fix/ImplicitValueClass.scala index 9c9812c..9bec8bb 100644 --- a/rules/src/main/scala/fix/ImplicitValueClass.scala +++ b/rules/src/main/scala/fix/ImplicitValueClass.scala @@ -44,7 +44,7 @@ class ImplicitValueClass extends SyntacticRule("ImplicitValueClass") { Template.Initial(Nil, Nil, _, stats) ) if c.mods.exists(_.is[Mod.Implicit]) && stats.forall(_.is[Defn.Def]) && allParentIsObject(c) && !p1.decltpe - .forall(_.is[Type.ByName]) => + .forall(_.is[Type.ByName]) && c.tparamClause.values.forall(_.cbounds.isEmpty) => Seq( { if (p1.mods.exists(_.is[ValParam])) {