Skip to content

Commit 60fac10

Browse files
committed
Narrow the node on which the patch is performed
1 parent ee1bdba commit 60fac10

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

2.13/input/src/main/scala/fix/Collectionstrawman_v0_Stream.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ rule = "scala:fix.Collectionstrawman_v0"
44
package fix
55

66
object Collectionstrawman_v0_Stream {
7-
Stream(1, 2, 3)
7+
val s = Stream(1, 2, 3)
8+
s.append(List(4, 5, 6))
89
1 #:: 2 #:: 3 #:: Stream.Empty
910
val isEmpty: Stream[_] => Boolean = {
1011
case Stream.Empty => true

2.13/output/src/main/scala/fix/Collectionstrawman_v0_Stream.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package fix
22

33
object Collectionstrawman_v0_Stream {
4-
LazyList(1, 2, 3)
4+
val s = LazyList(1, 2, 3)
5+
s.lazyAppendAll(List(4, 5, 6))
56
1 #:: 2 #:: 3 #:: LazyList.Empty
67
val isEmpty: LazyList[_] => Boolean = {
78
case LazyList.Empty => true

2.13/rules/src/main/scala/fix/Collectionstrawman_v0.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,21 @@ case class Collectionstrawman_v0(index: SemanticdbIndex)
9696
ctx.replaceTree(t, q"$buffer ++= $collection".syntax)
9797
}.asPatch
9898

99+
val streamAppend = SymbolMatcher.normalized(
100+
Symbol("_root_.scala.collection.immutable.Stream.append.")
101+
)
102+
103+
def replaceStreamAppend(ctx: RuleCtx): Patch =
104+
ctx.tree.collect {
105+
case streamAppend(t: Name) =>
106+
ctx.replaceTree(t, "lazyAppendAll")
107+
}.asPatch
108+
99109
override def fix(ctx: RuleCtx): Patch = {
100110
replaceToList(ctx) +
101111
replaceSymbols(ctx) +
102112
replaceTupleZipped(ctx) +
103-
replaceCopyToBuffer(ctx)
113+
replaceCopyToBuffer(ctx) +
114+
replaceStreamAppend(ctx)
104115
}
105116
}

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ lazy val `input-2_13` = project.in(file("2.13") / "input")
5858

5959
lazy val `output-2_13` = project.in(file("2.13") / "output")
6060
.settings(
61-
resolvers += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/",
62-
scalaVersion := "2.13.0-pre-47ffa9c-SNAPSHOT"
61+
resolvers += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-integration/",
62+
scalaVersion := "2.13.0-pre-c577876"
6363
)
6464

6565
lazy val `tests-2_13` = project.in(file("2.13") / "tests")

0 commit comments

Comments
 (0)