-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1801 from mrdziuban/print-lambda-and-match-types
Support `LambdaType` and `MatchType`
- Loading branch information
Showing
17 changed files
with
308 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
scalafix-tests/input/src/main/scala-3/test/TypeSignatures.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,14 @@ | ||
/* | ||
rules = [ | ||
DecorateTypeSignatures | ||
] | ||
*/ | ||
package test | ||
|
||
object TypeSignatures: | ||
|
||
type MapKV[K] = [V] =>> Map[K, V] | ||
|
||
type Convert[X] = X match | ||
case String => Char | ||
case Int => Float |
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
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
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
scalafix-tests/integration/src/main/scala-3/test/LegacySyntheticsTest.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 test | ||
|
||
class LegacySyntheticsTest { | ||
import scala.language.implicitConversions | ||
implicit def conv[F[A], A](a: A): Throwable = ??? | ||
1: Throwable | ||
} |
154 changes: 154 additions & 0 deletions
154
scalafix-tests/integration/src/main/scala-3/test/PrettyTest.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,154 @@ | ||
// scalafix:off | ||
package test | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
class PrettyTest { | ||
List(1).map(_ + 2) | ||
for { | ||
i <- 1.to(10) | ||
j <- 2.to(20) | ||
if i > i | ||
} yield j | ||
for { | ||
i <- Future(1.to(10)) | ||
j <- Future(2.to(i.length)) | ||
} { | ||
println(j) | ||
} | ||
|
||
class Inner | ||
val a = new PrettyTest | ||
val b = new a.Inner | ||
|
||
Option(null.asInstanceOf[{ | ||
def bar(a: Int): Int | ||
def foo(a: Int): Int | ||
} | ||
]) | ||
Option(b) | ||
Option(null.asInstanceOf[Int with String]) | ||
Option(null.asInstanceOf[this.type]) | ||
|
||
} | ||
|
||
import scala.language.existentials | ||
import scala.language.higherKinds | ||
|
||
class ann[T](x: T) extends scala.annotation.StaticAnnotation | ||
class ann1 extends scala.annotation.StaticAnnotation | ||
class ann2 extends scala.annotation.StaticAnnotation | ||
|
||
class B | ||
|
||
class C | ||
|
||
class P { | ||
class C | ||
class X | ||
val x = new X | ||
} | ||
|
||
class T { | ||
class C | ||
class X | ||
val x = new X | ||
} | ||
|
||
object Test { | ||
class M { | ||
def m: Int = ??? | ||
} | ||
|
||
trait N { | ||
def n: Int = ??? | ||
} | ||
|
||
class C extends M { | ||
val p = new P | ||
val x = p.x | ||
|
||
val typeRef1: C = ??? | ||
val typeRef2: p.C = ??? | ||
val typeRef3: T#C = ??? | ||
val typeRef4: List[Int] = ??? | ||
|
||
val singleType1: x.type = ??? | ||
val singleType2: p.x.type = ??? | ||
val Either = scala.util.Either | ||
|
||
val thisType1: this.type = ??? | ||
val thisType2: C.this.type = ??? | ||
|
||
val superType1 = super.m | ||
val superType2 = super[M].m | ||
val superType3 = C.super[M].m | ||
|
||
val compoundType1: { def k: Int } = ??? | ||
val compoundType2: M with N = ??? | ||
val compoundType3: M with N { def k: Int } = ??? | ||
val compoundType4 = new { def k: Int = ??? } | ||
val compoundType5 = new M with N | ||
val compoundType6 = new M with N { def k: Int = ??? } | ||
|
||
val annType1: T @ann(42) = ??? | ||
val annType2: T @ann1 @ann2 = ??? | ||
|
||
val existentialType2: List[_] = ??? | ||
val existentialType3 = Class.forName("foo.Bar") | ||
val existentialType4 = Class.forName("foo.Bar") | ||
|
||
def typeLambda1[M[_]] = ??? | ||
typeLambda1[({ type L[T] = List[T] })#L] | ||
|
||
object ClassInfoType1 | ||
class ClassInfoType2 extends B { def x = 42 } | ||
trait ClassInfoType3[T] | ||
|
||
object MethodType { | ||
def x1: Int = ??? | ||
def x2: Int = ??? | ||
def m3: Int = ??? | ||
def m4(): Int = ??? | ||
def m5(x: Int): Int = ??? | ||
def m6[T](x: T): T = ??? | ||
} | ||
|
||
object ByNameType { | ||
def m1(x: => Int): Int = ??? | ||
} | ||
|
||
case class RepeatedType(s: String*) { | ||
def m1(x: Int*): Int = s.length | ||
} | ||
|
||
object TypeType { | ||
type T1 | ||
def m2[T2 >: C <: C] = ??? | ||
def m3[M3[_]] = ??? | ||
type T4 = C | ||
type T5[U] = U | ||
} | ||
} | ||
|
||
object Literal { | ||
final val int = 1 | ||
final val long = 1L | ||
final val float = 1f | ||
final val double = 2d | ||
final val nil = null | ||
final val char = 'a' | ||
final val string = "a" | ||
final val bool = true | ||
final val unit = () | ||
final val javaEnum = java.nio.file.LinkOption.NOFOLLOW_LINKS | ||
final val clazzOf = classOf[Option[Int]] | ||
} | ||
|
||
type MapKV = [K] =>> [V] =>> Map[K, V] | ||
|
||
type Convert[X] = X match | ||
case String => Char | ||
case Int => Float | ||
} |
22 changes: 22 additions & 0 deletions
22
scalafix-tests/integration/src/main/scala/scalafix/test/DecorateTypeSignatures.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,22 @@ | ||
package scalafix.test | ||
|
||
import scala.meta._ | ||
|
||
import scalafix.v1._ | ||
|
||
class DecorateTypeSignatures extends SemanticRule("DecorateTypeSignatures") { | ||
|
||
override def fix(implicit doc: SemanticDocument): Patch = | ||
doc.tree.collect { case t: Defn.Type => | ||
t.symbol.info | ||
.map(_.signature) | ||
.map { | ||
case sig: TypeSignature => | ||
Patch.addLeft(t, "/*" + sig.upperBound.toString + "*/ ") | ||
case _ => | ||
Patch.empty | ||
} | ||
.getOrElse(Patch.empty) | ||
}.asPatch | ||
|
||
} |
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
29 changes: 29 additions & 0 deletions
29
scalafix-tests/integration/src/test/scala-3/scalafix/tests/v0/LegacySyntheticsSuite.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,29 @@ | ||
package scalafix.tests.v0 | ||
|
||
import scala.meta.* | ||
|
||
import scalafix.tests.core.BaseSemanticSuite | ||
|
||
class LegacySyntheticsSuite extends BaseSemanticSuite("LegacySyntheticsTest") { | ||
|
||
test("text") { | ||
val synthetics = index.synthetics(input) | ||
val obtained = synthetics.sortBy(_.position.start).mkString("\n") | ||
val expected = | ||
""" | ||
|[141..142): conv[[A] =>> Any, Int](*) | ||
| [0..4): conv => test/LegacySyntheticsTest#conv(). | ||
| [6..7): A => test/LegacySyntheticsTest#conv().[F][A] | ||
| [13..16): Any => scala/Any# | ||
| [18..21): Int => scala/Int# | ||
| [23..24): * => _star_. | ||
""".stripMargin | ||
|
||
assertNoDiff(obtained, expected) | ||
} | ||
|
||
test("parsable") { | ||
val synthetics = index.synthetics(input) | ||
synthetics.foreach(n => n.text.parse[Term]) | ||
} | ||
} |
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
Oops, something went wrong.