-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
input/src/main/scala-3/fix/KindProjectorScala3TypeLambdaTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
rule = KindProjectorScala3TypeLambda | ||
*/ | ||
package fix | ||
|
||
trait KindProjectorScala3TypeLambdaTest { | ||
type X1[b] = λ[a => Either[a, b]] | ||
|
||
def f: X1[Int][String] = Right(2).withLeft[String] | ||
} |
7 changes: 7 additions & 0 deletions
7
output/src/main/scala-3/fix/KindProjectorScala3TypeLambdaTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fix | ||
|
||
trait KindProjectorScala3TypeLambdaTest { | ||
type X1[b] = [a] =>> Either[a, b] | ||
|
||
def f: X1[Int][String] = Right(2).withLeft[String] | ||
} |
25 changes: 25 additions & 0 deletions
25
rules/src/main/scala/fix/KindProjectorScala3TypeLambda.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package fix | ||
|
||
import scala.meta.Type | ||
import scala.meta.XtensionCollectionLikeUI | ||
import scalafix.Patch | ||
import scalafix.v1.SyntacticDocument | ||
import scalafix.v1.SyntacticRule | ||
import scalafix.v1.XtensionSeqPatch | ||
|
||
class KindProjectorScala3TypeLambda extends SyntacticRule("KindProjectorScala3TypeLambda") { | ||
override def fix(implicit doc: SyntacticDocument): Patch = { | ||
doc.tree.collect { | ||
case t @ Type.Apply.After_4_6_0( | ||
Type.Name("λ"), | ||
Type.ArgClause( | ||
Type.Function.After_4_6_0( | ||
Type.FuncParamClause(args), | ||
body | ||
) :: Nil | ||
) | ||
) => | ||
Patch.replaceTree(t, args.mkString("[", ", ", s"] =>> ${body}")) | ||
}.asPatch | ||
} | ||
} |