Skip to content

Commit

Permalink
Update Scala to 3.5 (#2857)
Browse files Browse the repository at this point in the history
  • Loading branch information
achinaou authored Sep 29, 2024
1 parent 5018a00 commit 7fe4a23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ plugins {
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}

ext.ammoniteScalaVersion = '2.13'
ext.ammoniteVersion = '2.5.11'
ext.ammoniteScalaVersion = '3.5'
ext.ammoniteVersion = '3.0.0'
ext.ammoniteVersionQualifier = '2-6342755f'
ext.assertjVersion = '3.26.3'
ext.junitVersion = '5.11.1'

Expand Down Expand Up @@ -87,7 +88,10 @@ tasks.register('generateSources') {
}
def ammoniteJar = new File(ammoniteDir, "amm-${ammoniteScalaVersion}-${ammoniteVersion}.jar")
if (!ammoniteJar.exists()) {
def ammoniteReleaseUrl = "https://github.com/lihaoyi/Ammonite/releases/download/${ammoniteVersion}/${ammoniteScalaVersion}-${ammoniteVersion}"
def ammoniteAssetName = [ammoniteScalaVersion, ammoniteVersion, ammoniteVersionQualifier]
.findAll { it != null && !it.isEmpty() }
.join('-')
def ammoniteReleaseUrl = "https://github.com/lihaoyi/Ammonite/releases/download/${ammoniteVersion}/${ammoniteAssetName}"
ant.get(src: ammoniteReleaseUrl, dest: ammoniteJar)
}
javaexec {
Expand Down
19 changes: 9 additions & 10 deletions generator/Generator.sc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import JavaGenerator._

import collection.immutable.ListMap
import scala.language.implicitConversions
import scala.reflect.macros.whitebox

val N = 8
val VARARGS = 10
Expand Down Expand Up @@ -776,7 +775,7 @@ def generateMainClasses(): Unit = {
val forClassName = if (mtype.endsWith("Iterable")) { s"For$i" } else { s"For$i$mtype" }
val generics = (1 to i).gen(j => s"T$j")(", ")
val params = (1 to i).gen(j => s"${if(mtype == "Either") mtype + s"<L, T$j>" else mtype + s"<T$j>"} ts$j")(", ")
xs"""
xs"""
/$javadoc
* Creates a {@code For}-comprehension of ${i.numerus(mtype)}.
${(0 to i).gen(j => if (j == 0) "*" else s"* @param ts$j the ${j.ordinal} $mtype")("\n")}
Expand Down Expand Up @@ -2131,7 +2130,7 @@ def generateMainClasses(): Unit = {
}
""")}

${(i > 1) gen (1 to i).gen(j => xs"""
${(i > 1) `gen` (1 to i).gen(j => xs"""
/$javadoc
* Maps the ${j.ordinal} component of this tuple to a new value.
*
Expand Down Expand Up @@ -2201,7 +2200,7 @@ def generateMainClasses(): Unit = {
}
""")}

${(i < N) gen (1 to N-i).gen(j => xs"""
${(i < N) `gen` (1 to N-i).gen(j => xs"""
/$javadoc
* Concat a tuple's values to this tuple.
*
Expand Down Expand Up @@ -3644,7 +3643,7 @@ def generateTestClasses(): Unit = {
}
""")}

${(i > 1) gen (1 to i).gen(j => {
${(i > 1) `gen` (1 to i).gen(j => {
val substitutedResultTypes = if (i == 0) "" else s"<${(1 to i).gen(k => s"${if (k == j) "String" else "Integer"}")(", ")}>"
val ones = (1 to i).gen(_ => "1")(", ")
val result = (1 to i).gen(k => s"${if (k == j) "\"X\"" else "1"}")(", ")
Expand Down Expand Up @@ -3683,7 +3682,7 @@ def generateTestClasses(): Unit = {
}
""")}

${(i < N) gen (1 to N-i).gen(j => xs"""
${(i < N) `gen` (1 to N-i).gen(j => xs"""
@$test
public void shouldConcatTuple$j() {
final Tuple${i+j}<${(1 to i+j).gen(j => s"Integer")(", ")}> actual = ${ if (i == 0) "Tuple0.instance()" else s"Tuple.of(${(1 to i).gen(j => xs"$j")(", ")})"}.concat(Tuple.of(${(i+1 to i+j).gen(k => s"$k")(", ")}));
Expand Down Expand Up @@ -3943,10 +3942,10 @@ object Generator {
def first: String = s.substring(0, 1)

// converts first char of s to upper case. throws if string is empty
def firstUpper: String = s(0).toUpper + s.substring(1)
def firstUpper: String = s"${s(0).toUpper}${s.substring(1)}"

// converts first char of s to lower case. throws if string is empty
def firstLower: String = s(0).toLower + s.substring(1)
def firstLower: String = s"${s(0).toLower}${s.substring(1)}"
}

implicit class BooleanExtensions(condition: Boolean) {
Expand Down Expand Up @@ -4121,15 +4120,15 @@ object Generator {
* @param args StringContext parts
* @return An aligned String
*/
def xs(args: Any*): String = align(sc.s(indentedArgs(args:_*):_*))
def xs(args: Any*): String = align(sc.s(indentedArgs(args*)*))

/**
* Formats raw/unescaped strings.
*
* @param args StringContext parts
* @return An aligned String
*/
def xraw(args: Any*): String = align(sc.raw(indentedArgs(args:_*):_*))
def xraw(args: Any*): String = align(sc.raw(indentedArgs(args*)*))

// indent embedded strings, invariant: parts.length = args.length + 1
private def indentedArgs(args: Any*): Seq[String] =
Expand Down

0 comments on commit 7fe4a23

Please sign in to comment.