Skip to content

Commit

Permalink
scala 3.4.1 including automatic rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
mpollmeier committed Apr 9, 2024
1 parent 4d05d91 commit d1b1faa
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ThisBuild / organization := "io.joern"
ThisBuild / scalaVersion := scala3

val slf4jVersion = "2.0.7"
val scala3 = "3.3.1"
val scala3 = "3.4.1"
val scala2_12 = "2.12.18"

/** Only the below listed projects are included in things like `sbt compile`.
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/flatgraph/DiffGraphApplier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ private[flatgraph] class DiffGraphApplier(graph: Graph, diff: DiffGraphBuilder)
// ^ change this once we switch away from full copy-on-write, see e.g.
// https://github.com/joernio/flatgraph/pull/163#discussion_r1537246314
}
val propview = mutable.ArraySeq.make(edgeProp.asInstanceOf[Array[_]]).asInstanceOf[mutable.ArraySeq[Any]]
val propview = mutable.ArraySeq.make(edgeProp.asInstanceOf[Array[?]]).asInstanceOf[mutable.ArraySeq[Any]]
// this will fail if the edge doesn't support properties. todo: better error message
val default = graph.schema.allocateEdgeProperty(nodeKind, direction, edgeKind = edgeKind, size = 1)(0)
for (edgeRepr <- setEdgeProperties(pos)) {
Expand Down Expand Up @@ -584,7 +584,7 @@ private[flatgraph] class DiffGraphApplier(graph: Graph, diff: DiffGraphBuilder)
val oldQty = Option(graph.properties(pos).asInstanceOf[Array[Int]]).getOrElse(new Array[Int](1))
val oldProperty = Option(graph.properties(pos + 1))
.getOrElse(graph.schema.getNodePropertyFormalType(nodeKind, propertyKind).allocate(0))
.asInstanceOf[Array[_]]
.asInstanceOf[Array[?]]
if oldProperty == null then throw new SchemaViolationException("Unsupported property on node")

val newQty = new Array[Int](nodeCount + 1)
Expand Down
42 changes: 21 additions & 21 deletions core/src/main/scala/flatgraph/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,75 +22,75 @@ object FormalQtyType {
object QtyMulti extends FormalQuantity

sealed trait FormalType {
def allocate(n: Int): Array[_]
def allocate(n: Int): Array[?]
}

object NothingType extends FormalType {
def allocate(n: Int): Array[_] = null
def allocate(n: Int): Array[?] = null
}

object BoolType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Boolean](n)
override def allocate(n: Int): Array[?] = new Array[Boolean](n)
}
case class BoolTypeWithDefault(b: Boolean) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}

object ByteType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Byte](n)
override def allocate(n: Int): Array[?] = new Array[Byte](n)
}

case class ByteTypeWithDefault(b: Byte) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}

object ShortType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Short](n)
override def allocate(n: Int): Array[?] = new Array[Short](n)
}

case class ShortTypeWithDefault(b: Short) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}

object IntType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Int](n)
override def allocate(n: Int): Array[?] = new Array[Int](n)
}

case class IntTypeWithDefault(b: Int) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}
object LongType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Long](n)
override def allocate(n: Int): Array[?] = new Array[Long](n)
}

case class LongTypeWithDefault(b: Long) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}

object FloatType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Float](n)
override def allocate(n: Int): Array[?] = new Array[Float](n)
}

case class FloatTypeWithDefault(b: Float) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}
object DoubleType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[Double](n)
override def allocate(n: Int): Array[?] = new Array[Double](n)
}

case class DoubleTypeWithDefault(b: Double) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}

object StringType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[String](n)
override def allocate(n: Int): Array[?] = new Array[String](n)
}

case class StringTypeWithDefault(b: String) extends FormalType {
override def allocate(n: Int): Array[_] = Array.fill(n)(b)
override def allocate(n: Int): Array[?] = Array.fill(n)(b)
}
object RefType extends FormalType {
override def allocate(n: Int): Array[_] = new Array[GNode](n)
override def allocate(n: Int): Array[?] = new Array[GNode](n)
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ abstract class Schema {
// fixme: API will need to change when we add generated edge classes (relevant for edge properties)
def makeEdge(src: GNode, dst: GNode, edgeKind: Short, subSeq: Int, property: Any): Edge

def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[_]
def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[?]
def getNodePropertyFormalType(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalType
def getNodePropertyFormalQuantity(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalQuantity

Expand Down Expand Up @@ -184,7 +184,7 @@ class FreeSchema(
new Edge(src, dst, edgeKind, subSeq, property)

override def getNodePropertyFormalType(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalType = nodePropertyTypes(propertyKind)
override def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[_] =
override def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[?] =
edgePropertyTypes(edgeKind).allocate(size)

override def getNodePropertyFormalQuantity(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalQuantity =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/flatgraph/help/DocFinder.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flatgraph.help

object DocFinder {
def findDocumentedMethodsOf(clazz: Class[_]): Iterable[StepDoc] = {
def findDocumentedMethodsOf(clazz: Class[?]): Iterable[StepDoc] = {
clazz.getMethods.flatMap { method =>
method.getAnnotations.find(_.isInstanceOf[Doc]).map { case docAnnotation: Doc =>
StepDoc(
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/flatgraph/help/TraversalHelp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import scala.jdk.CollectionConverters.*
class TraversalHelp(packageNamesToSearch: DocSearchPackages) {
import TraversalHelp._

def forElementSpecificSteps(elementClass: Class[_], verbose: Boolean)(implicit availableWidthProvider: AvailableWidthProvider): String = {
def forElementSpecificSteps(elementClass: Class[?], verbose: Boolean)(implicit availableWidthProvider: AvailableWidthProvider): String = {
val isNode = classOf[GNode].isAssignableFrom(elementClass)

val stepDocs = {
def parentTraitsRecursively(clazz: Class[_]): List[Class[_]] = {
def parentTraitsRecursively(clazz: Class[?]): List[Class[?]] = {
val parents = clazz.getInterfaces.to(List)
parents ++ parents.flatMap(parentTraitsRecursively)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ class TraversalHelp(packageNamesToSearch: DocSearchPackages) {
/** Scans the entire classpath for classes annotated with @TraversalExt (using java reflection), to then extract the \@Doc annotations for
* all steps, and group them by the elementType (e.g. node.Method).
*/
lazy val stepDocsByElementType: Map[Class[_], List[StepDoc]] = {
lazy val stepDocsByElementType: Map[Class[?], List[StepDoc]] = {
for {
packageName <- packageNamesToSearch()
traversal <- findClassesAnnotatedWith(packageName, classOf[help.Traversal])
Expand All @@ -88,16 +88,16 @@ class TraversalHelp(packageNamesToSearch: DocSearchPackages) {
private def findClassesAnnotatedWith[Annotation <: JAnnotation](
packageName: String,
annotationClass: Class[Annotation]
): Iterator[Class[_]] =
): Iterator[Class[?]] =
new Reflections(packageName).getTypesAnnotatedWith(annotationClass).asScala.iterator

lazy val genericStepDocs: Iterable[StepDoc] =
findStepDocs(classOf[flatgraph.traversal.GenericSteps[_]])
findStepDocs(classOf[flatgraph.traversal.GenericSteps[?]])

lazy val nodeStepDocs: Iterable[StepDoc] =
findStepDocs(classOf[flatgraph.traversal.NodeSteps[_]])
findStepDocs(classOf[flatgraph.traversal.NodeSteps[?]])

protected def findStepDocs(traversal: Class[_]): Iterable[StepDoc] = {
protected def findStepDocs(traversal: Class[?]): Iterable[StepDoc] = {
DocFinder
.findDocumentedMethodsOf(traversal)
// scala generates additional `fooBar$extension` methods, but those don't matter in the context of .help/@Doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ object Deserialization {
a
}

private def readArray(channel: FileChannel, ptr: OutlineStorage, nodes: Array[Array[GNode]], stringPool: Array[String]): Array[_] = {
private def readArray(channel: FileChannel, ptr: OutlineStorage, nodes: Array[Array[GNode]], stringPool: Array[String]): Array[?] = {
if (ptr == null) return null
val dec = Zstd
.decompress(channel.map(FileChannel.MapMode.READ_ONLY, ptr.startOffset, ptr.compressedLength), ptr.decompressedLength)
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/flatgraph/storage/Manifest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ object Manifest {
def write(item: GraphItem): ujson.Value = {
val res = ujson.Obj()
res(Keys.Version) = 0
res(Keys.Nodes) = ujson.Arr(item.nodes.map(NodeItem.write): _*)
res(Keys.Edges) = ujson.Arr(item.edges.map(EdgeItem.write): _*)
res(Keys.Properties) = ujson.Arr(item.properties.map(PropertyItem.write): _*)
res(Keys.Nodes) = ujson.Arr(item.nodes.map(NodeItem.write)*)
res(Keys.Edges) = ujson.Arr(item.edges.map(EdgeItem.write)*)
res(Keys.Properties) = ujson.Arr(item.properties.map(PropertyItem.write)*)
res(Keys.StringPoolLength) = OutlineStorage.write(item.stringPoolLength)
res(Keys.StringPoolBytes) = OutlineStorage.write(item.stringPoolBytes)
res
Expand All @@ -48,7 +48,7 @@ object Manifest {
res(Keys.NodeLabel) = item.nodeLabel
res(Keys.NNodes) = item.nnodes
res(Keys.Deletions) =
if (item.deletions == null || item.deletions.isEmpty) ujson.Null else ujson.Arr(item.deletions.map { seq => ujson.Num(seq) }: _*)
if (item.deletions == null || item.deletions.isEmpty) ujson.Null else ujson.Arr(item.deletions.map { seq => ujson.Num(seq) }*)
res
}

Expand Down
26 changes: 13 additions & 13 deletions core/src/main/scala/flatgraph/traversal/Language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {

/** perform side effect without changing the contents of the traversal */
@Doc(info = "perform side effect without changing the contents of the traversal")
def sideEffect(fun: A => _): Iterator[A] =
def sideEffect(fun: A => ?): Iterator[A] =
iterator match {
case pathAwareTraversal: PathAwareTraversal[A] =>
pathAwareTraversal._sideEffect(fun)
Expand All @@ -179,26 +179,26 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
* input - analogous to `collect`
*/
@Doc(info = "perform side effect without changing the contents of the traversal")
def sideEffectPF(pf: PartialFunction[A, _]): Iterator[A] =
def sideEffectPF(pf: PartialFunction[A, ?]): Iterator[A] =
sideEffect(pf.lift)

/** only preserves elements if the provided traversal has at least one result */
@Doc(info = "only preserves elements if the provided traversal has at least one result")
def where(trav: Iterator[A] => Iterator[_]): Iterator[A] =
def where(trav: Iterator[A] => Iterator[?]): Iterator[A] =
iterator.filter { (a: A) =>
trav(Iterator.single(a)).hasNext
}

/** only preserves elements if the provided traversal does _not_ have any results */
@Doc(info = "only preserves elements if the provided traversal does _not_ have any results")
def whereNot(trav: Iterator[A] => Iterator[_]): Iterator[A] =
def whereNot(trav: Iterator[A] => Iterator[?]): Iterator[A] =
iterator.filter { (a: A) =>
!trav(Iterator.single(a)).hasNext
}

/** only preserves elements if the provided traversal does _not_ have any results - alias for whereNot */
@Doc(info = "only preserves elements if the provided traversal does _not_ have any results - alias for whereNot")
def not(trav: Iterator[A] => Iterator[_]): Iterator[A] =
def not(trav: Iterator[A] => Iterator[?]): Iterator[A] =
whereNot(trav)

/** only preserves elements for which _at least one of_ the given traversals has at least one result Works for arbitrary amount of 'OR'
Expand All @@ -208,7 +208,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
* {{{.or(_.label("someLabel"), _.has("someProperty"))}}}
*/
@Doc(info = "only preserves elements for which _at least one of_ the given traversals has at least one result")
def or(traversals: (Iterator[A] => Iterator[_])*): Iterator[A] = {
def or(traversals: (Iterator[A] => Iterator[?])*): Iterator[A] = {
iterator.filter { (a: A) =>
traversals.exists { trav =>
trav(Iterator.single(a)).hasNext
Expand All @@ -223,7 +223,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
* {{{.and(_.label("someLabel"), _.has("someProperty"))}}}
*/
@Doc(info = "only preserves elements for which _all of_ the given traversals have at least one result")
def and(traversals: (Iterator[A] => Iterator[_])*): Iterator[A] = {
def and(traversals: (Iterator[A] => Iterator[?])*): Iterator[A] = {
iterator.filter { (a: A) =>
traversals.forall { trav =>
trav(Iterator.single(a)).hasNext
Expand All @@ -241,7 +241,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
@Doc(info = "union/sum/aggregate/join given traversals from the current point")
def union[B](traversals: (Iterator[A] => Iterator[B])*): Iterator[B] = iterator match {
case pathAwareTraversal: PathAwareTraversal[A] =>
pathAwareTraversal._union(traversals: _*)
pathAwareTraversal._union(traversals*)
case _ =>
iterator.flatMap { (a: A) =>
traversals.flatMap(_.apply(Iterator.single(a)))
Expand Down Expand Up @@ -289,7 +289,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
@Doc(info = "evaluates the provided traversals in order and returns the first traversal that emits at least one element")
def coalesce[NewEnd](options: (Iterator[A] => Iterator[NewEnd])*): Iterator[NewEnd] = iterator match {
case pathAwareTraversal: PathAwareTraversal[A] =>
pathAwareTraversal._coalesce(options: _*)
pathAwareTraversal._coalesce(options*)
case _ =>
iterator.flatMap { (a: A) =>
options.iterator
Expand All @@ -316,7 +316,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
}

def isPathTracking: Boolean =
iterator.isInstanceOf[PathAwareTraversal[_]]
iterator.isInstanceOf[PathAwareTraversal[?]]

/** retrieve entire path that has been traversed thus far prerequisite: enablePathTracking has been called previously
*
Expand Down Expand Up @@ -379,7 +379,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal {
@Doc(info = "repeat the given traversal")
def repeat[B >: A](
repeatTraversal: Iterator[A] => Iterator[B]
)(implicit behaviourBuilder: RepeatBehaviour.Builder[B] => RepeatBehaviour.Builder[B] = RepeatBehaviour.noop[B] _): Iterator[B] = {
)(implicit behaviourBuilder: RepeatBehaviour.Builder[B] => RepeatBehaviour.Builder[B] = RepeatBehaviour.noop[B]): Iterator[B] = {
val behaviour = behaviourBuilder(new RepeatBehaviour.Builder[B]).build
val _repeatTraversal =
repeatTraversal
Expand Down Expand Up @@ -510,7 +510,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal {

/** alias for {{{label}}} */
def hasLabel(values: String*): Iterator[A] =
label(values: _*)
label(values*)

/** filter by the node label (inverse) */
def labelNot(value: String): Iterator[A] =
Expand Down Expand Up @@ -560,7 +560,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal {
def property[@specialized T](name: String): Iterator[T] =
traversal.flatMap(_.propertyOption[T](name))

def property[@specialized ValueType](propertyKey: PropertyKey[ValueType, _]): Iterator[ValueType] =
def property[@specialized ValueType](propertyKey: PropertyKey[ValueType, ?]): Iterator[ValueType] =
propertyKey match {
case propertyKey: SinglePropertyKey[_] => property(propertyKey)
case propertyKey: OptionalPropertyKey[_] => property(propertyKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PathAwareTraversal[A](val wrapped: Iterator[(A, Vector[Any])]) extends Ite
.getOrElse(Iterator.empty)
})

private[traversal] def _sideEffect(f: A => _): PathAwareTraversal[A] = new PathAwareTraversal(wrapped.map { case (a, p) =>
private[traversal] def _sideEffect(f: A => ?): PathAwareTraversal[A] = new PathAwareTraversal(wrapped.map { case (a, p) =>
f(a); (a, p)
})

Expand Down
Loading

0 comments on commit d1b1faa

Please sign in to comment.