10000 Scala 3 stripMargin type error · sim642/adventofcode@b3bff03 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3bff03

Browse files
committed
Scala 3 stripMargin type error
1 parent e18e9de commit b3bff03

File tree

14 files changed

+54
-30
lines changed

14 files changed

+54
-30
lines changed

.idea/sbt.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/scala_compiler.xml

Lines changed: 5 additions & 1 deletion
10000
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.sbt

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@ name := "adventofcode"
22

33
version := "0.1"
44

5-
scalaVersion := "2.13.5"
6-
scalacOptions ++= Seq("-deprecation")
5+
scalaVersion := "3.0.0-RC2"
6+
crossScalaVersions ++= Seq("2.13.5", "3.0.0-RC2")
7+
scalacOptions ++= {
8+
Seq(
9+
//"-deprecation",
10+
) ++
11+
(CrossVersion.partialVersion(scalaVersion.value) match {
12+
case Some((3, _)) => Seq(
13+
"-source:3.0-migration",
14+
"-explain",
15+
"-explain-types",
16+
)
17+
case _ => Seq(
18+
"-deprecation",
19+
)
20+
})
21+
}
722

823
// TODO: unnecessary for scalameter because it exists on maven central?
924
//resolvers += "Sonatype OSS Snapshots" at
1025
// "https://oss.sonatype.org/content/repositories/snapshots"
1126

12-
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.0"
13-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0" % "test"
14-
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
15-
libraryDependencies += "org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % "test"
16-
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
17-
libraryDependencies += "com.lihaoyi" %% "ujson" % "0.7.5"
18-
libraryDependencies += "com.storm-enroute" %% "scalameter" % "0.19" % "test"
27+
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.7"
28+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.7" % "test"
29+
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.15.3" % "test"
30+
libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.7.0" % "test"
31+
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.2.0-RC1"
32+
libraryDependencies += "com.lihaoyi" %% "ujson" % "1.3.11"
33+
libraryDependencies += ("com.storm-enroute" %% "scalameter" % "0.19" % "test").cross(CrossVersion.for3Use2_13) // 0.21 has transitive io.github.... dependency which breaks io.Source in tests
34+
.exclude("org.scala-lang.modules", "scala-parser-combinators_2.13") // scalameter 2.13 dependency workaround
35+
.exclude("org.scala-lang.modules", "scala-xml_2.13") // scalameter 2.13 dependency workaround
36+
// libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.0.0-RC1" // scalameter 2.13 dependency workaround
1937

2038
// TODO: scalameter tests don't work in SBT
2139
//testFrameworks += new TestFramework("org.scalameter.ScalaMeterFramework")

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.3.13
1+
sbt.version = 1.5.0

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.21")
2+
addDependencyTreePlugin

src/main/scala/eu/sim642/adventofcode2017/Day8.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ object Day8 {
2727
def parseInstruction(instructionStr: String): Instruction = instructionStr match {
2828
case instructionRegex(register, op, amount, conditionRegister, comp, conditionAmount) =>
2929
val operation = (op match {
30-
case "inc" => Inc
31-
case "dec" => Dec
30+
case "inc" => Inc.apply _
31+
case "dec" => Dec.apply _
3232
})(amount.toInt)
3333

3434
val comparison = comp match {

src/main/scala/eu/sim642/adventofcode2018/Day10.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object Day10 {
5353
override def minimizePointsArea(points: Seq[Point]): (Seq[Point], Int) = {
5454
def slope(t: Int): Long = stepBoundingArea(points, t + 1) - stepBoundingArea(points, t)
5555

56-
val minSecond = OrderedSearch.exponentialBinaryLower(slope, 0)(0)
56+
val minSecond = OrderedSearch.exponentialBinaryLower(slope, 0)(0L)
5757
(points.map(_.step(minSecond)), minSecond)
5858
}
5959
}

src/main/scala/eu/sim642/adventofcode2019/Day22.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object Day22 {
3838
}
3939

4040
def shuffleFactoryOrder(techniques: Techniques, size: Long): Deck = {
41-
techniques.foldLeft(Vector.range(0, size))((deck, technique) => applyDeck(technique, deck))
41+
techniques.foldLeft(Vector.range(0L, size))((deck, technique) => applyDeck(technique, deck))
4242
}
4343

4444
override def shuffleFactoryOrderPosition(techniques: Techniques, size: Long, card: Long): Long = {
@@ -118,7 +118,8 @@ object Day22 {
118118
}
119119

120120
def toLinear(techniques: Techniques, modular: Modular): modular.Linear = {
121-
techniques.map(toLinear(_, modular)).reduce((a, b) => b.compose(a))
121+
val linears: Seq[modular.Linear] = techniques.map(toLinear(_, modular)) // TODO: why is this type annotation necessary in Scala 3?
122+
linears.reduce((a, b) => b.compose(a))
122123
}
123124

124125
override def shuffleFactoryOrderPosition(techniques: Techniques, size: Long, card: Long): Long = {

src/main/scala/eu/sim642/adventofcode2020/Day10.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import eu.sim642.adventofcodelib.LazyMap
55
import eu.sim642.adventofcodelib.LazyMapImplicits._
66

77
import scala.annotation.tailrec
8-
import scala.collection.compat.immutable.ArraySeq
8+
import scala.collection.immutable.ArraySeq
99

1010
object Day10 {
1111

src/main/scala/eu/sim642/adventofcode2020/Day18.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ object Day18 extends RegexParsers {
4040
object Part1 extends Part {
4141

4242
def op: Parser[(Expr, Expr) => Expr] = (
43-
"+" ^^^ Add
44-
| "*" ^^^ Mul
43+
"+" ^^^ Add.apply _
44+
| "*" ^^^ Mul.apply _
4545
)
4646

4747
def expr: Parser[Expr] = chainl1(simple, op)

0 commit comments

Comments
 (0)
0