Skip to content

Commit

Permalink
run more expect tests against Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Apr 13, 2024
1 parent f9482c6 commit b332360
Show file tree
Hide file tree
Showing 49 changed files with 47 additions and 42 deletions.
28 changes: 0 additions & 28 deletions scalafix-tests/input/src/main/scala-2/test/AnchorPatches.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package test.escapeHatch

import scala.collection.mutable

// Fails with Scala3 dialect as the second silencer is not attached to the Defn.Val
// https://github.com/scalameta/scalameta/issues/3689
class Issue694 {

// overlapping switches must not interfere with each other. The one with wider range wins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import test.organizeImports.Implicits.b._
import ExecutionContext.Implicits.global
import test.organizeImports.Implicits.a.{nonImplicit, intImplicit, stringImplicit}

// Unsupported on Scala 3
// https://github.com/scala/scala3/issues/12766
// https://github.com/scalacenter/scalafix/blob/f51cb4a/docs/rules/OrganizeImports.md?plain=1#L440-L444
object ExplicitlyImportedImplicits {
def f1()(implicit i: Int) = ???
def f2()(implicit s: String) = ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ rule = RemoveUnused
*/
package test.removeUnused

// Not available as of Scala 3.4.1
// https://github.com/scalacenter/scalafix/issues/1937
object UnusedParams {
val f: String => Unit = unused => println("f")
val ff = (unused: String) => println("f")
Expand Down
24 changes: 24 additions & 0 deletions scalafix-tests/input/src/main/scala/test/AnchorPatches.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
rule = [RemoveUnused]
*/
package test

import scala.collection.AbstractMap
import scala.collection.immutable // scalafix:ok RemoveUnusedImports

import scala.collection.mutable.{ // scalafix:ok RemoveUnusedImports
Map,
Set
}

import scala.collection.mutable.{
Map,
Set
}

import scala.concurrent.duration.Duration

object AnchorPatches {
private def d1s = Duration(1, "s")
private def d2s = Duration(2, "s") // scalafix:ok RemoveUnused
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Disable.symbols = [

package test.escapeHatch

import test.disableSyntax.DisableSyntaxMoreRules.toString

object AnchorExpression {

val aDummy = 0 // assert: NoDummy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Disable.symbols = [

package test.escapeHatch

import test.disableSyntax.DisableSyntaxMoreRules.toString

object AnchorMultipleRules {

// scalafix:off Disable.None, Disable.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ object AnnotationScopes {

class Foo_0[DummyTypeParam] // assert: NoDummy

def dummyMacro_0: Unit = macro ??? // assert: NoDummy

class DummyClass_0( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy
Expand All @@ -35,7 +33,7 @@ object AnnotationScopes {
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
fDummy: String) = { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}

Expand Down Expand Up @@ -70,10 +68,6 @@ object AnnotationScopes {
// Type parameter
class Foo_1[@SuppressWarnings(Array("NoDummy")) DummyTypeParam]

// Macro
@SuppressWarnings(Array("NoDummy"))
def dummyMacro_1: Unit = macro ???

// Object
@SuppressWarnings(Array("NoDummy"))
object DummyObject_1 {
Expand Down Expand Up @@ -110,17 +104,17 @@ object AnnotationScopes {
class DummyClass_5 { // assert: NoDummy

@SuppressWarnings(Array("NoDummy"))
def this(eDummy: String, fDummy: String) {
this
def this(eDummy: String, fDummy: String) = {
this()
}
}

// Secondary constructor parameter
class DummyClass_6 { // assert: NoDummy

def this(@SuppressWarnings(Array("NoDummy")) eDummy: String,
fDummy: String) { // assert: NoDummy
this
fDummy: String) = { // assert: NoDummy
this()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package test.removeUnused

// Not available as of Scala 3.4.1
// https://github.com/scalacenter/scalafix/issues/1937
object UnusedParams {
val f: String => Unit = _ => println("f")
val ff = (_: String) => println("f")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import scala.collection.mutable.{ // scalafix:ok RemoveUnusedImports


import scala.concurrent.duration.Duration
import scala.concurrent.duration.FiniteDuration

object AnchorPatches {
def d1s: FiniteDuration = Duration(1, "s")
def d2s = Duration(2, "s") // scalafix:ok ExplicitResultTypes

private def d2s = Duration(2, "s") // scalafix:ok RemoveUnused
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import ExecutionContext.Implicits.global
import test.organizeImports.Implicits.a.intImplicit
import test.organizeImports.Implicits.a.stringImplicit

// Unsupported on Scala 3
// https://github.com/scala/scala3/issues/12766
// https://github.com/scalacenter/scalafix/blob/f51cb4a/docs/rules/OrganizeImports.md?plain=1#L440-L444
object ExplicitlyImportedImplicits {
def f1()(implicit i: Int) = ???
def f2()(implicit s: String) = ???
Expand Down

0 comments on commit b332360

Please sign in to comment.