Skip to content

Commit

Permalink
Add even 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 ded7248 commit 3dc6783
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.doc(
sources = sources.toArray[VirtualFile],
classpath = classpath,
sources = sources.toIndexedSeq,
classpath = classpath.toIndexedSeq,
converter = converter,
outputDirectory = targetDir,
options = Nil,
Expand All @@ -305,7 +305,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.console(
classpath = classpath,
classpath = classpath.toIndexedSeq,
converter = converter,
options = Nil,
initialCommands = initial,
Expand All @@ -327,7 +327,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit {
val cp = (si.allJars).map(_.toPath) ++ Array(targetDir)
val classpath = cp.map(converter.toVirtualFile)
sc.interactiveConsole(
classpath = classpath,
classpath = classpath.toIndexedSeq,
converter = converter,
options = args.toSeq,
initialCommands = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,29 @@ object ClassToAPI {
cmap: ClassMap
): (api.Structure, api.Structure) = {
lazy val cf = classFileForClass(c)
val methods = mergeMap(c, c.getDeclaredMethods, c.getMethods, methodToDef(enclPkg))
val fields = mergeMap(c, c.getDeclaredFields, c.getFields, fieldToDef(c, cf, enclPkg))
val methods = mergeMap(
c,
c.getDeclaredMethods.toIndexedSeq,
c.getMethods.toIndexedSeq,
methodToDef(enclPkg)
)
val fields = mergeMap(
c,
c.getDeclaredFields.toIndexedSeq,
c.getFields.toIndexedSeq,
fieldToDef(c, cf, enclPkg)
)
val constructors =
mergeMap(c, c.getDeclaredConstructors, c.getConstructors, constructorToDef(enclPkg))
mergeMap(
c,
c.getDeclaredConstructors.toIndexedSeq,
c.getConstructors.toIndexedSeq,
constructorToDef(enclPkg)
)
val classes = merge[Class[?]](
c,
c.getDeclaredClasses,
c.getClasses,
c.getDeclaredClasses.toIndexedSeq,
c.getClasses.toIndexedSeq,
toDefinitions(cmap),
(_: Seq[Class[?]]).partition(isStatic),
_.getEnclosingClass != c
Expand Down Expand Up @@ -240,7 +255,7 @@ object ClassToAPI {
private def allSuperTypes(t: Type): Seq[Type] = {
@tailrec def accumulate(t: Type, accum: Seq[Type] = Seq.empty): Seq[Type] = t match {
case c: Class[?] =>
val (parent, interfaces) = (c.getGenericSuperclass, c.getGenericInterfaces)
val (parent, interfaces) = (c.getGenericSuperclass, c.getGenericInterfaces.toIndexedSeq)
accumulate(parent, (accum :+ parent) ++ flattenAll(interfaces))
case p: ParameterizedType =>
accumulate(p.getRawType, accum)
Expand All @@ -263,7 +278,7 @@ object ClassToAPI {
def types(ts: Seq[Type]): Array[api.Type] =
ts.filter(_ ne null).map(reference).toArray
def upperBounds(ts: Array[Type]): api.Type =
api.Structure.of(lzy(types(ts)), lzyEmptyDefArray, lzyEmptyDefArray)
api.Structure.of(lzy(types(ts.toIndexedSeq)), lzyEmptyDefArray, lzyEmptyDefArray)

@deprecated("No longer used", "0.13.0")
def parents(c: Class[?]): Seq[api.Type] = types(allSuperTypes(c))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object Discovery {
simpleName(a.base).filter(pred)
}.toSet
def defAnnotations(s: Structure, pred: String => Boolean): Set[String] =
defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited, pred)
defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited.toIndexedSeq, pred)
def defAnnotations(defs: Seq[Definition], pred: String => Boolean): Set[String] =
findAnnotations(
defs.flatMap {
Expand Down
4 changes: 2 additions & 2 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ final class HashAPI private (
extend(StructureHash)
hashTypes(structure.parents, includeDefinitions)
if (includeDefinitions) {
hashDefinitions(structure.declared, false, isTrait)
hashDefinitions(structure.inherited, false, isTrait)
hashDefinitions(structure.declared.toIndexedSeq, false, isTrait)
hashDefinitions(structure.inherited.toIndexedSeq, false, isTrait)
}
}
def hashParameters(parameters: Array[TypeParameter], base: Type): Unit = {
Expand Down
38 changes: 22 additions & 16 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
// a.name == b.name &&
debug(sameAccess(a.access, b.access), "Access differed") &&
debug(sameModifiers(a.modifiers, b.modifiers), "Modifiers differed") &&
debug(sameAnnotations(a.annotations, b.annotations), "Annotations differed") &&
debug(
sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq),
"Annotations differed"
) &&
debug(sameDefinitionSpecificAPI(a, b), "Definition-specific differed")
}

Expand Down Expand Up @@ -184,7 +187,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
def sameAnnotation(a: Annotation, b: Annotation): Boolean =
debug(sameType(a.base, b.base), "Annotation base type differed") &&
debug(
sameAnnotationArguments(a.arguments, b.arguments),
sameAnnotationArguments(a.arguments.toIndexedSeq, b.arguments.toIndexedSeq),
"Annotation arguments differed (" + a + ") and (" + b + ")"
)
def sameAnnotationArguments(a: Seq[AnnotationArgument], b: Seq[AnnotationArgument]): Boolean =
Expand All @@ -203,7 +206,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {

def sameParameterizedDefinition(a: ParameterizedDefinition, b: ParameterizedDefinition): Boolean =
debug(
sameTypeParameters(a.typeParameters, b.typeParameters),
sameTypeParameters(a.typeParameters.toIndexedSeq, b.typeParameters.toIndexedSeq),
"Different type parameters for " + a.name
) &&
sameParameterizedSpecificAPI(a, b)
Expand All @@ -222,7 +225,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {

def sameDefSpecificAPI(a: Def, b: Def): Boolean =
debug(
sameValueParameters(a.valueParameters, b.valueParameters),
sameValueParameters(a.valueParameters.toIndexedSeq, b.valueParameters.toIndexedSeq),
"Different def value parameters for " + a.name
) &&
debug(sameType(a.returnType, b.returnType), "Different def return type for " + a.name)
Expand Down Expand Up @@ -253,7 +256,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
debug(sameTopLevel(a, b), "Top level flag differs") &&
sameDefinitionType(a.definitionType, b.definitionType) &&
sameType(a.selfType, b.selfType) &&
sameSeq(a.childrenOfSealedClass, b.childrenOfSealedClass)(sameType) &&
sameSeq(a.childrenOfSealedClass.toIndexedSeq, b.childrenOfSealedClass.toIndexedSeq)(sameType) &&
sameStructure(a.structure, b.structure)
}

Expand All @@ -265,7 +268,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {

def sameParameterList(a: ParameterList, b: ParameterList): Boolean =
(a.isImplicit == b.isImplicit) &&
sameParameters(a.parameters, b.parameters)
sameParameters(a.parameters.toIndexedSeq, b.parameters.toIndexedSeq)
def sameParameters(a: Seq[MethodParameter], b: Seq[MethodParameter]): Boolean =
sameSeq(a, b)(sameMethodParameter)
def sameMethodParameter(a: MethodParameter, b: MethodParameter): Boolean =
Expand All @@ -283,8 +286,11 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
def sameTypeParameters(a: Seq[TypeParameter], b: Seq[TypeParameter]): Boolean =
debug(sameSeq(a, b)(sameTypeParameter), "Different type parameters")
def sameTypeParameter(a: TypeParameter, b: TypeParameter): Boolean = {
sameTypeParameters(a.typeParameters, b.typeParameters) &&
debug(sameAnnotations(a.annotations, b.annotations), "Different type parameter annotations") &&
sameTypeParameters(a.typeParameters.toIndexedSeq, b.typeParameters.toIndexedSeq) &&
debug(
sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq),
"Different type parameter annotations"
) &&
debug(sameVariance(a.variance, b.variance), "Different variance") &&
debug(sameType(a.lowerBound, b.lowerBound), "Different lower bound") &&
debug(sameType(a.upperBound, b.upperBound), "Different upper bound") &&
Expand Down Expand Up @@ -326,24 +332,24 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
sameType(ca.baseType, cb.baseType) &&
ca.value == cb.value
def sameExistentialType(a: Existential, b: Existential): Boolean =
sameTypeParameters(a.clause, b.clause) &&
sameTypeParameters(a.clause.toIndexedSeq, b.clause.toIndexedSeq) &&
sameType(a.baseType, b.baseType)
def samePolymorphicType(a: Polymorphic, b: Polymorphic): Boolean =
sameTypeParameters(a.parameters, b.parameters) &&
sameTypeParameters(a.parameters.toIndexedSeq, b.parameters.toIndexedSeq) &&
sameType(a.baseType, b.baseType)
def sameAnnotatedType(a: Annotated, b: Annotated): Boolean =
sameType(a.baseType, b.baseType) &&
sameAnnotations(a.annotations, b.annotations)
sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq)
def sameStructure(a: Structure, b: Structure): Boolean =
samePending(a, b)(sameStructureDirect)

private[this] def samePending[T](a: T, b: T)(f: (T, T) => Boolean): Boolean =
if (pending add ((a, b))) f(a, b) else true

def sameStructureDirect(a: Structure, b: Structure): Boolean = {
sameSeq(a.parents, b.parents)(sameType) &&
sameMembers(a.declared, b.declared) &&
sameMembers(a.inherited, b.inherited)
sameSeq(a.parents.toIndexedSeq, b.parents.toIndexedSeq)(sameType) &&
sameMembers(a.declared.toIndexedSeq, b.declared.toIndexedSeq) &&
sameMembers(a.inherited.toIndexedSeq, b.inherited.toIndexedSeq)
}

def sameMembers(a: Seq[Definition], b: Seq[Definition]): Boolean =
Expand All @@ -358,7 +364,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {

def sameParameterized(a: Parameterized, b: Parameterized): Boolean =
sameType(a.baseType, b.baseType) &&
sameSeq(a.typeArguments, b.typeArguments)(sameType)
sameSeq(a.typeArguments.toIndexedSeq, b.typeArguments.toIndexedSeq)(sameType)
def sameParameterRef(a: ParameterRef, b: ParameterRef): Boolean = sameTags(a.id, b.id)
def sameSingleton(a: Singleton, b: Singleton): Boolean =
samePath(a.path, b.path)
Expand All @@ -367,7 +373,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
(a.id == b.id)

def samePath(a: Path, b: Path): Boolean =
samePathComponents(a.components, b.components)
samePathComponents(a.components.toIndexedSeq, b.components.toIndexedSeq)
def samePathComponents(a: Seq[PathComponent], b: Seq[PathComponent]): Boolean =
sameSeq(a, b)(samePathComponent)
def samePathComponent(a: PathComponent, b: PathComponent): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private[sbt] object Parser {
in.readUnsignedShort(),
toString(in.readUnsignedShort()),
toString(in.readUnsignedShort()),
array(in.readUnsignedShort())(parseAttribute())
array(in.readUnsignedShort())(parseAttribute()).toIndexedSeq
)
private def parseAttribute() = {
val nameIndex = in.readUnsignedShort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ object ScalaInstance {

/** Return all the required Scala jars from a path `scalaHome`. */
def allJars(scalaHome: File): Seq[File] =
IO.listFiles(scalaLib(scalaHome)).filter(f => !blacklist(f.getName))
IO.listFiles(scalaLib(scalaHome)).toIndexedSeq.filter(f => !blacklist(f.getName))

private[this] def scalaLib(scalaHome: File): File =
new File(scalaHome, "lib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object ClasspathUtil {
classpath: Seq[Path],
instance: ScalaInstance
): Map[String, String] = {
createClasspathResources(classpath, instance.libraryJars.map(_.toPath))
createClasspathResources(classpath, instance.libraryJars.toIndexedSeq.map(_.toPath))
}

def createClasspathResources(appPaths: Seq[Path], bootPaths: Seq[Path]): Map[String, String] = {
Expand Down

0 comments on commit 3dc6783

Please sign in to comment.