From b41e7c683ced67ebe7f4e3fa65cfb08daa3526b9 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Fri, 26 Feb 2021 17:16:17 -0800 Subject: [PATCH 1/2] Replace Dotty with Scala 3 in project README.md --- README.md | 57 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 6d6e544..7b07281 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,29 @@ -# Example sbt project that compiles using Dotty +# Example sbt project that compiles using Scala 3 [![Build Status](https://travis-ci.com/scala/scala3-example-project.svg?branch=master)](https://travis-ci.com/scala/scala3-example-project) ## Usage This is a normal sbt project, you can compile code with `sbt compile` and run it -with `sbt run`, `sbt console` will start a Dotty REPL. +with `sbt run`, `sbt console` will start a Scala 3 REPL. If compiling this example project fails, you probably have a global sbt plugin -that does not work with dotty, try to disable all plugins in +that does not work with Scala 3, try to disable all plugins in `~/.sbt/1.0/plugins` and `~/.sbt/1.0`. ### IDE support -Dotty comes built-in with IDE support, to try it out see -http://dotty.epfl.ch/docs/usage/ide-support.html +Scala 3 comes built-in with IDE support, to try it out see +[IDE support for Scala 3](http://dotty.epfl.ch/docs/usage/ide-support.html) -## Making a new Dotty project +## Making a new Scala 3 project -The fastest way to start a new Dotty project is to use one of the following templates: +The fastest way to start a new Scala 3 project is to use one of the following templates: -* [Simple Dotty project](https://github.com/scala/scala3.g8) -* [Dotty project that cross-compiles with Scala 2](https://github.com/scala/scala3-cross.g8) +* [Minimal Scala 3 project](https://github.com/scala/scala3.g8) +* [Scala 3 project that cross-compiles with Scala 2](https://github.com/scala/scala3-cross.g8) -## Using Dotty in an existing project +## Using Scala 3 in an existing project You will need to make the following adjustments to your build: @@ -33,6 +33,10 @@ You will need to make the following adjustments to your build: addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.3") ``` +Here, _dotty_ is the project name for technologies that are considered for inclusion in Scala 3. +Since the development of Scala 3 is not done, the word _dotty_ and _Dotty_ are still can be seen +in some names of Scala 3 related tools, sbt plugins, etc. + ### project/build.properties ```scala @@ -43,8 +47,7 @@ You must use sbt 1.4 or newer; older versions of sbt are not supported. ### build.sbt -Any version number that starts with `0.` is automatically recognized as Dotty by -the `sbt-dotty` plugin, you don't need to set up anything: +Set up the Scala 3 version: ```scala scalaVersion := "3.0.0-RC1" @@ -52,30 +55,30 @@ scalaVersion := "3.0.0-RC1" #### Nightly builds -If the latest release of Dotty is missing a bugfix or feature you need, you may -wish to use a nightly build. Look at the bottom of -https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3.0.0-RC1/ to find the version -number for the latest nightly build. Alternatively, you can set `scalaVersion := -dottyLatestNightlyBuild.get` to always use the latest nightly build of dotty. +If the latest release of Scala 3 is missing a bugfix or feature you need, you may +wish to use a nightly build. Look at the bottom of the list of +[releases](https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3.0.0-RC1/) +to find the version number for the latest nightly build. Alternatively, you can set +`scalaVersion := dottyLatestNightlyBuild.get` to always use the latest nightly build of Scala 3. -## Getting your project to compile with Dotty +## Getting your project to compile with Scala 3 When porting an existing project, it's a good idea to start out with the Scala 2 compatibility mode (note that this mode affects typechecking and thus may -prevent some valid Dotty code from compiling) by adding to your `build.sbt`: +prevent some valid Scala 3 code from compiling) by adding to your `build.sbt`: ```scala scalacOptions ++= { if (isDotty.value) Seq("-source:3.0-migration") else Nil } ``` Using the `isDotty` setting ensures that this option will only be set when -compiling with Dotty. For more information on the `-source` flag, see -http://dotty.epfl.ch/docs/usage/language-versions.html, for more information on -migrating to Scala 3 see [the migration -guide](https://github.com/scalacenter/scala-3-migration-guide). +compiling with Scala 3. For more information on the `-source` flag, see +[language versions](http://dotty.epfl.ch/docs/usage/language-versions.html); +for more information on migrating to Scala 3, see +[the migration guide](https://github.com/scalacenter/scala-3-migration-guide). If your build contains dependencies that have only been published for Scala 2.x, -you may be able to get them to work on Dotty by replacing: +you may be able to get them to work on Scala 3 by replacing: ```scala libraryDependencies += "a" %% "b" % "c" @@ -88,8 +91,8 @@ by: ``` This will have no effect when compiling with Scala 2.x, but when compiling -with Dotty this will change the cross-version to a Scala 2.x one. This -works because Dotty is currently retro-compatible with Scala 2.x. +with Scala 3 this will change the cross-version to a Scala 2.x one. This +works because Scala 3 is currently retro-compatible with Scala 2.x. Alternatively, to set this setting on all your dependencies, you can use: @@ -100,4 +103,4 @@ Alternatively, to set this setting on all your dependencies, you can use: ## Discuss Feel free to come chat with us on the -[Dotty gitter](http://gitter.im/lampepfl/dotty)! +[Scala 3 gitter](http://gitter.im/lampepfl/dotty)! From 720e18cbcebc9bf71a5583483927fd0268223e18 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Fri, 26 Feb 2021 17:33:00 -0800 Subject: [PATCH 2/2] Replace Dotty with Scala 3 in the comments of two source files --- src/main/scala/Conversion.scala | 2 +- src/main/scala/TraitParams.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/Conversion.scala b/src/main/scala/Conversion.scala index 574d1d2..cd4b374 100644 --- a/src/main/scala/Conversion.scala +++ b/src/main/scala/Conversion.scala @@ -26,7 +26,7 @@ object Conversion { /* Not working anymore. def useConversion(implicit f: A => B) = { val y: A = ... - val x: B = a // error under Dotty + val x: B = a // error under Scala 3 } */ diff --git a/src/main/scala/TraitParams.scala b/src/main/scala/TraitParams.scala index 9a802d7..48f4827 100644 --- a/src/main/scala/TraitParams.scala +++ b/src/main/scala/TraitParams.scala @@ -7,13 +7,13 @@ object TraitParams { class A extends Base("Hello") class B extends Base("Dotty!") - // Union types only exist in Dotty, so there's no chance that this will accidentally be compiled with Scala 2 + // Union types only exist in Scala 3, so there's no chance that this will accidentally be compiled with Scala 2 private def printMessages(msgs: (A | B)*) = println(msgs.map(_.msg).mkString(" ")) def test(): Unit = { printMessages(new A, new B) - // Sanity check the classpath: this won't run if the dotty jar is not present. + // Sanity check the classpath: this won't run if the Scala 3 jar is not present. val x: Int => Int = z => z x(1) }