- Ólafur Páll Geirsson, Scala Center
@olafurpg
"For open source. For education."
"define a migration path
from Scala 2.x to Dotty"
-- May 9th, 2016 - Scala Center Advisory Board
$ git clone https://github.com/arktekk/linx
// project/plugins.sbt
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.1.0-RC4")
// build.sbt
scalaVersion := dottyLatestNightlyBuild
$ sbt compile
-- Error: linx/shared/src/main/scala/linx/Linx.scala:42:15 ----
42 | implicit def VarOps[A, X]() = new VarOps[A, X](l)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| implicit definition needs explicit type
// project/plugins.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.3.2")
$ sbt "scalafix Dotty"
$ git diff
- VarOps[A, X]() = new VarOps[A, X](l)
+ VarOps[A, X](): Linx.VarOps[A, X] = new VarOps[A, X](l)
> scalafix org/repo/v1.0
Syntax | Semantic | |
---|---|---|
perl/bash | n/a | n/a |
scala-refactoring | scalac | scalac |
scalameta | custom | scalac |
intellij-scala | custom | custom |
val lst = List[Int](1, x, 3).filter(y => y > 2).headOption
[32..36): List => _root_.scala.collection.immutable.List.apply(Lscala/collection/Seq;)Lscala/collection/immutable/List;.
[37..40): Int => _root_.scala.Int#
[48..54): filter => _root_.scala.collection.TraversableLike#filter(Lscala/Function1;)Ljava/lang/Object;.
[57..58): > => _root_.scala.Int#`>`(I)Z.
[62..72): headOption => _root_.scala.collection.TraversableLike#headOption()Lscala/Option;.
Rewrite.apply("object code")
Rewrite.diff("object code")
RenameSymbol
AddImport
RemoveToken
- List(1, 2).filter(_ > 2).headOption
+ List(1, 2).find(_ > 2)
- Visit documentation: scalacenter.github.io/scalafix
- Contribute with ideas, reporting issues and PRs.
- Follow @olafurpg on Twitter.
- Chat on Gitter.