Skip to content

Commit

Permalink
Add more missing .toIndexedSeq calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Oct 18, 2024
1 parent 5a41ce6 commit 60f90e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ object ClassToAPI {
* We need this logic to trigger recompilation due to changes to pattern exhaustivity checking results.
*/
private def childrenOfSealedClass(c: Class[?]): Seq[api.Type] =
if (!c.isEnum) emptyTypeArray
if (!c.isEnum) emptyTypeArray.toIndexedSeq
else {
// Calling getCanonicalName() on classes from enum constants yields same string as enumClazz.getCanonicalName
// Moreover old behaviour create new instance of enum - what may fail (e.g. in static block )
Array(reference(c))
Seq(reference(c))
}

// full information not available from reflection
Expand Down Expand Up @@ -556,7 +556,7 @@ object ClassToAPI {
}

def pathFromString(s: String): api.Path =
pathFromStrings(s.split("\\."))
pathFromStrings(s.split("\\.").toIndexedSeq)
def pathFromStrings(ss: Seq[String]): api.Path =
api.Path.of((ss.map(api.Id.of(_)) :+ ThisRef).toArray)
def packageName(c: Class[?]) = packageAndName(c)._1
Expand Down
12 changes: 6 additions & 6 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class Discovery(baseClasses: Set[String], annotations: Set[String]) {
case _ => Discovered.empty
}
def discover(c: ClassLike): Discovered = {
val onClass = Discovery.findAnnotations(c.annotations, annotations)
val onClass = Discovery.findAnnotations(c.annotations.toIndexedSeq, annotations)
val onDefs = Discovery.defAnnotations(c.structure, annotations) ++ c.savedAnnotations.filter(
annotations
)
val module = isModule(c)
new Discovered(
bases(c.name, c.structure.parents),
bases(c.name, c.structure.parents.toIndexedSeq),
onClass ++ onDefs,
module && hasMainMethod(c),
module
Expand All @@ -66,7 +66,7 @@ object Discovery {
simpleName(a.base).filter(pred)
}.toSet
def defAnnotations(s: Structure, pred: String => Boolean): Set[String] =
defAnnotations(s.declared, pred) ++ defAnnotations(s.inherited, pred)
defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited, pred)
def defAnnotations(defs: Seq[Definition], pred: String => Boolean): Set[String] =
findAnnotations(
defs.flatMap {
Expand All @@ -82,19 +82,19 @@ object Discovery {
def isModule(c: ClassLike) = c.definitionType == DefinitionType.Module

def hasMainMethod(c: ClassLike): Boolean =
hasMainMethod(c.structure.declared) || hasMainMethod(c.structure.inherited)
hasMainMethod(c.structure.declared.toIndexedSeq) || hasMainMethod(c.structure.inherited.toIndexedSeq)
def hasMainMethod(defs: Seq[Definition]): Boolean =
defs.exists(isMainMethod)
def isMainMethod(d: Definition): Boolean =
d match {
case d: Def =>
d.name == "main" && isPublic(d) && isConcrete(d) && isUnit(d.returnType) && isStringArray(
d.valueParameters
d.valueParameters.toIndexedSeq
)
case _ => false
}
def isStringArray(vp: IndexedSeq[ParameterList]): Boolean =
vp.length == 1 && isStringArray(vp(0).parameters)
vp.length == 1 && isStringArray(vp(0).parameters.toIndexedSeq)
def isStringArray(params: Seq[MethodParameter]): Boolean =
params.length == 1 && isStringArray(params(0))
def isStringArray(p: MethodParameter): Boolean =
Expand Down
20 changes: 10 additions & 10 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/ShowAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ object ShowAPI {
case v: Val => showMonoDef(v, "val") + ": " + showType(v.tpe)
case v: Var => showMonoDef(v, "var") + ": " + showType(v.tpe)
case d: Def =>
showPolyDef(d, "def") + showValueParams(d.valueParameters) + ": " + showType(d.returnType)
showPolyDef(d, "def") + showValueParams(d.valueParameters.toIndexedSeq) + ": " + showType(d.returnType)
case ta: TypeAlias => showPolyDef(ta, "type") + " = " + showType(ta.tpe)
case td: TypeDeclaration => showPolyDef(td, "type") + showBounds(td.lowerBound, td.upperBound)
case cl: ClassLike =>
showMonoDef(d, showDefinitionType(cl.definitionType)) +
showTypeParameters(cl.typeParameters) + " extends " + showTemplate(cl)
showTypeParameters(cl.typeParameters.toIndexedSeq) + " extends " + showTemplate(cl)
case cl: ClassLikeDef => showPolyDef(cl, showDefinitionType(cl.definitionType))
}

Expand All @@ -59,9 +59,9 @@ object ShowAPI {

cl.structure.parents.map(showNestedType).mkString("", " with ", " {") + showSelf +
lines(
truncateDecls(cl.structure.inherited).map(d => "^inherited^ " + showNestedDefinition(d))
truncateDecls(cl.structure.inherited).toIndexedSeq.map(d => "^inherited^ " + showNestedDefinition(d))
) +
lines(truncateDecls(cl.structure.declared).map(showNestedDefinition)) +
lines(truncateDecls(cl.structure.declared).toIndexedSeq.map(showNestedDefinition)) +
"}"
}

Expand All @@ -73,7 +73,7 @@ object ShowAPI {
case p: Parameterized =>
showType(p.baseType) + p.typeArguments.map(showType).mkString("[", ", ", "]")
case c: Constant => showType(c.baseType) + "(" + c.value + ")"
case a: Annotated => showAnnotations(a.annotations) + " " + showType(a.baseType)
case a: Annotated => showAnnotations(a.annotations.toIndexedSeq) + " " + showType(a.baseType)
case s: Structure =>
s.parents.map(showType).mkString(" with ") + (
if (nesting <= 0) "{ <nesting level reached> }"
Expand All @@ -90,7 +90,7 @@ object ShowAPI {
case p: Polymorphic =>
showType(p.baseType) + (
if (nesting <= 0) " [ <nesting level reached> ]"
else showNestedTypeParameters(p.parameters)
else showNestedTypeParameters(p.parameters.toIndexedSeq)
)
}

Expand All @@ -103,22 +103,22 @@ object ShowAPI {

private def space(s: String) = if (s.isEmpty) s else s + " "
private def showMonoDef(d: Definition, label: String)(implicit nesting: Int): String =
space(showAnnotations(d.annotations)) + space(showAccess(d.access)) + space(
space(showAnnotations(d.annotations.toIndexedSeq)) + space(showAccess(d.access)) + space(
showModifiers(d.modifiers)
) + space(label) + d.name

private def showPolyDef(d: ParameterizedDefinition, label: String)(
implicit nesting: Int
): String =
showMonoDef(d, label) + showTypeParameters(d.typeParameters)
showMonoDef(d, label) + showTypeParameters(d.typeParameters.toIndexedSeq)

private def showTypeParameters(tps: Seq[TypeParameter])(implicit nesting: Int): String =
if (tps.isEmpty) ""
else tps.map(showTypeParameter).mkString("[", ", ", "]")

private def showTypeParameter(tp: TypeParameter)(implicit nesting: Int): String =
showAnnotations(tp.annotations) + " " + showVariance(tp.variance) + tp.id + showTypeParameters(
tp.typeParameters
showAnnotations(tp.annotations.toIndexedSeq) + " " + showVariance(tp.variance) + tp.id + showTypeParameters(
tp.typeParameters.toIndexedSeq
) + " " + showBounds(tp.lowerBound, tp.upperBound)

private def showAnnotations(as: Seq[Annotation])(implicit nesting: Int) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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.toIndexedSeq.map(_.toPath): _*)
val otherJars = scalaInstance.otherJars.toList.map(_.toPath)
val extraClasspath = include(cpOptions.extra, otherJars: _*)
filteredClasspath ++ extraCompiler ++ extraClasspath
Expand Down

0 comments on commit 60f90e4

Please sign in to comment.