Skip to content

Commit

Permalink
Make sure Scala 3 dialect is used when printing instrumented code
Browse files Browse the repository at this point in the history
Previously, we would use the default dialect, which would print `import something._` instead of `import something.*` and this would break with the -source future flag that drops the former syntax.

Fixes #513
  • Loading branch information
tgodzik committed Jun 10, 2021
1 parent 38a7121 commit ace23cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.io.PrintStream
import scala.meta._

final class FailInstrumenter(sections: List[SectionInput], i: Int) {
implicit val dialect: Dialect = dialects.Scala3
private val out = new ByteArrayOutputStream()
private val gensym = new Gensym()
def instrument(): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Instrumenter(
settings: Settings,
reporter: Reporter
) {
implicit val dialect: Dialect = dialects.Scala3
def instrument(): Instrumented = {
printAsScript()
Instrumented.fromSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ class WorksheetSuite extends BaseSuite {
|""".stripMargin
)

checkDecorations(
"import-future".tag(OnlyScala3),
"""|import $scalac.`-source future`
|import scala.collection._
|val x = 1.to(4).toVector
|""".stripMargin,
"""|import $scalac.`-source future`
|import scala.collection._
|<val x = 1.to(4).toVector> // : Vector[Int] = Vect...
|x: Vector[Int] = Vector(1, 2, 3, 4)
|""".stripMargin
)

checkDiagnostics(
"value-class",
"""|object Foo {
Expand Down

0 comments on commit ace23cd

Please sign in to comment.