Skip to content

Commit

Permalink
enforce new varargs syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Oct 6, 2024
1 parent 2bdc237 commit fadc1d8
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 21 deletions.
5 changes: 3 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = 3.8.3
runner.dialect = scala213
runner.dialect = scala3

project.git = true
project.excludeFilters = [ /sbt-test/, /input_sources/, /contraband-scala/ ]
Expand Down Expand Up @@ -27,12 +27,13 @@ danglingParentheses.defnSite = true
rewrite.trailingCommas.style = keep

rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.newSyntax.control = false
fileOverride {
"glob:**/internal/compiler-bridge/**" {
rewrite.scala3.convertToNewSyntax = false
runner.dialect = scala213
}
}
runner.dialectOverride.allowSignificantIndentation = false
runner.dialectOverride.allowAsForImportRename = false
runner.dialectOverride.allowStarWildcardImport = false
runner.dialectOverride.allowPostfixStarVarargSplices = false
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ object ClassLikeHelpers {
Structure.of(lzy(Array.empty[Type]), lzy(defs.toArray), emptyMembers)

def simpleTrait(name: String, defs: List[ClassDefinition]): ClassLike = {
val structure = simpleStructure(defs: _*)
val structure = simpleStructure(defs*)
simpleClassLike(name, structure, dt = DefinitionType.Trait)
}

def simpleClass(name: String, defs: ClassDefinition*): ClassLike = {
val structure = simpleStructure(defs: _*)
val structure = simpleStructure(defs*)
simpleClassLike(name, structure)
}

def simpleObject(name: String, defs: ClassDefinition*): ClassLike = {
val structure = simpleStructure(defs: _*)
val structure = simpleStructure(defs*)
simpleClassLike(name, structure, dt = DefinitionType.Module)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private[sbt] object JavaAnalyze {
classFile

val sourceToClassFiles = mutable.HashMap[VirtualFile, Buffer[ClassFile]](
sources.map(vf => vf -> new ArrayBuffer[ClassFile]): _*
sources.map(vf => vf -> new ArrayBuffer[ClassFile])*
)

val binaryClassNameToLoadedClass = new mutable.HashMap[String, Class[?]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object JavaCompilerForUnitTesting {
}

def extractDependenciesFromSrcs(srcs: (String, String)*): ExtractedClassDependencies = {
val (_, testCallback) = compileJavaSrcs(srcs: _*)((_, _, classes) => extractParents(classes))
val (_, testCallback) = compileJavaSrcs(srcs*)((_, _, classes) => extractParents(classes))

val memberRefDeps = testCallback.classDependencies
.collect({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object ReflectUtilities {
else clazz :: ancestry(clazz.getSuperclass);

def fields(clazz: Class[?]) =
mutable.OpenHashMap(ancestry(clazz).flatMap(_.getDeclaredFields).map(f => (f.getName, f)): _*)
mutable.OpenHashMap(ancestry(clazz).flatMap(_.getDeclaredFields).map(f => (f.getName, f))*)

/**
* Collects all `val`s of type `T` defined on value `self`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ final class AnalyzingCompiler(
private def invoke(bridge: AnyRef, bridgeClass: Class[?], methodName: String, log: Logger)(
argTypes: Class[?]*
)(args: AnyRef*): AnyRef = {
val method = bridgeClass.getMethod(methodName, argTypes: _*)
try method.invoke(bridge, args: _*)
val method = bridgeClass.getMethod(methodName, argTypes*)
try method.invoke(bridge, args*)
catch {
case e: InvocationTargetException =>
e.getCause match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ final class CompilerArguments(
*/
def finishClasspath(classpath: Seq[Path]): Seq[Path] = {
val filteredClasspath = filterLibrary(classpath)
val extraCompiler = include(cpOptions.compiler, scalaInstance.compilerJars.map(_.toPath): _*)
val extraCompiler = include(cpOptions.compiler, scalaInstance.compilerJars.map(_.toPath)*)
val otherJars = scalaInstance.otherJars.toList.map(_.toPath)
val extraClasspath = include(cpOptions.extra, otherJars: _*)
val extraClasspath = include(cpOptions.extra, otherJars*)
filteredClasspath ++ extraCompiler ++ extraClasspath
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ object LocalJava {
): Int =
javadocTool match {
case Some(m) =>
m.run(in, out, err, args: _*)
m.run(in, out, err, args*)
case _ =>
System.err.println(JavadocFailure)
-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private class MStamps(
val rs = removeSources.toSet
Map(sources.toSeq.filter {
case (file, stamp) => !rs(file)
}: _*)
}*)
},
libraries.view.filterKeys(lib).toMap
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ class TextAnalysisFormat(val mappers: ReadWriteMappers)
keyMapper: Mapper[File],
valueMapper: ContextAwareMapper[File, Stamp]
): TreeMap[File, Stamp] = {
TreeMap(readMappedPairs(in)(expectedHeader, keyMapper.read, valueMapper.read).toSeq: _*)
TreeMap(readMappedPairs(in)(expectedHeader, keyMapper.read, valueMapper.read).toSeq*)
}
def doReadMapV(
expectedHeader: String,
keyMapper: Mapper[VirtualFileRef],
valueMapper: ContextAwareMapper[VirtualFileRef, Stamp]
): TreeMap[VirtualFileRef, Stamp] = {
import VirtualFileUtil._
TreeMap(readMappedPairs(in)(expectedHeader, keyMapper.read, valueMapper.read).toSeq: _*)
TreeMap(readMappedPairs(in)(expectedHeader, keyMapper.read, valueMapper.read).toSeq*)
}

val products = doReadMapV(Headers.products, productsMapper, productsStampsMapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object AnalysisGenerators {
import VirtualFileUtil._

def stamp(xs: Iterable[VirtualFileRef]) =
for (stamps <- listOfN(xs.size, genStamp)) yield TreeMap(xs.toList.zip(stamps): _*)
for (stamps <- listOfN(xs.size, genStamp)) yield TreeMap(xs.toList.zip(stamps)*)

for {
prods <- stamp(rel.allProducts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ final class AnalyzingJavaCompiler private[sbt] (
} {
val classes = classFinder.classes
try {
val newClasses = Set(classes.paths: _*) -- oldClasses
val newClasses = Set(classes.paths*) -- oldClasses
JavaAnalyze(newClasses.toSeq, srcs, log, output, finalJarOutput)(
callback,
loader,
Expand Down
2 changes: 1 addition & 1 deletion zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class IncrementalCompilerSpec extends BaseCompilerSpec {
)
)
}
comp.doCompileWithStore(newInputs = incrementalJavaInputs(sources: _*))
comp.doCompileWithStore(newInputs = incrementalJavaInputs(sources*))
}

val res1 = compileJava(f1, f2, f3)
Expand Down
4 changes: 2 additions & 2 deletions zinc/src/test/scala/sbt/inc/TestProjectSetup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ case class CompilerSetup(
}

def compileBoth(sources: VirtualFile*) = {
val res = compile(sources: _*)
if (res.hasModified) compileAllJava(sources: _*) else res
val res = compile(sources*)
if (res.hasModified) compileAllJava(sources*) else res
}

def withSrcs(vs: Array[VirtualFile]) = (in: Inputs) => in.withOptions(in.options.withSources(vs))
Expand Down

0 comments on commit fadc1d8

Please sign in to comment.