Skip to content

Commit 47de500

Browse files
committed
scala 3.3.3: upgrade and adapt
1 parent 5b4b695 commit 47de500

File tree

8 files changed

+50
-49
lines changed

8 files changed

+50
-49
lines changed

codegen/src/main/scala/overflowdb/codegen/CodeGen.scala

+14-13
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ class CodeGen(schema: Schema) {
184184
|class DiffGraphBuilder extends overflowdb.BatchedUpdate.DiffGraphBuilder {
185185
| override def absorb(other: overflowdb.BatchedUpdate.DiffGraphBuilder): this.type = {super.absorb(other); this}
186186
| override def addNode(node: overflowdb.DetachedNodeData): this.type = {super.addNode(node); this}
187-
| override def addNode(label: String, keyvalues:Any*): this.type = {super.addNode(label, keyvalues:_*); this}
187+
| override def addNode(label: String, keyvalues:Any*): this.type = {super.addNode(label, keyvalues: _*); this}
188188
| override def addEdge(src: overflowdb.NodeOrDetachedNode, dst: overflowdb.NodeOrDetachedNode, label: String): this.type = {super.addEdge(src, dst, label); this}
189-
| override def addEdge(src: overflowdb.NodeOrDetachedNode, dst: overflowdb.NodeOrDetachedNode, label: String, properties: Any*): this.type = {super.addEdge(src, dst, label, properties:_*); this}
189+
| override def addEdge(src: overflowdb.NodeOrDetachedNode, dst: overflowdb.NodeOrDetachedNode, label: String, properties: Any*): this.type = {super.addEdge(src, dst, label, properties: _*); this}
190190
| override def setNodeProperty(node: overflowdb.Node, label: String, property: Any): this.type = {super.setNodeProperty(node, label, property); this}
191191
| override def removeNode(node: overflowdb.Node): this.type = {super.removeNode(node); this}
192192
| override def removeEdge(edge: overflowdb.Edge): this.type = {super.removeEdge(edge); this}
@@ -284,8 +284,8 @@ class CodeGen(schema: Schema) {
284284
val factories = {
285285
val edgeFactories = schema.edgeTypes.map(edgeType => edgeType.className + ".factory").mkString(", ")
286286
s"""object Factories {
287-
| lazy val all: Seq[EdgeFactory[_]] = Seq($edgeFactories)
288-
| lazy val allAsJava: java.util.List[EdgeFactory[_]] = all.asJava
287+
| lazy val all: Seq[EdgeFactory[?]] = Seq($edgeFactories)
288+
| lazy val allAsJava: java.util.List[EdgeFactory[?]] = all.asJava
289289
|}
290290
|""".stripMargin
291291
}
@@ -296,7 +296,7 @@ class CodeGen(schema: Schema) {
296296
|""".stripMargin
297297
}
298298

299-
def generateEdgeSource(edgeType: EdgeType, properties: Seq[Property[_]]) = {
299+
def generateEdgeSource(edgeType: EdgeType, properties: Seq[Property[?]]) = {
300300
val edgeClassName = edgeType.className
301301

302302
val propertyNames = properties.map(_.className)
@@ -338,7 +338,7 @@ class CodeGen(schema: Schema) {
338338
|}
339339
|""".stripMargin
340340

341-
def propertyBasedFieldAccessors(properties: Seq[Property[_]]): String = {
341+
def propertyBasedFieldAccessors(properties: Seq[Property[?]]): String = {
342342
import Property.Cardinality
343343
properties.map { property =>
344344
val name = property.name
@@ -418,8 +418,8 @@ class CodeGen(schema: Schema) {
418418
val nodeFactories =
419419
schema.nodeTypes.map(nodeType => nodeType.className + ".factory").mkString(", ")
420420
s"""object Factories {
421-
| lazy val all: Seq[NodeFactory[_]] = Seq($nodeFactories)
422-
| lazy val allAsJava: java.util.List[NodeFactory[_]] = all.asJava
421+
| lazy val all: Seq[NodeFactory[?]] = Seq($nodeFactories)
422+
| lazy val allAsJava: java.util.List[NodeFactory[?]] = all.asJava
423423
|}
424424
|""".stripMargin
425425
}
@@ -525,7 +525,7 @@ class CodeGen(schema: Schema) {
525525
// val relevantNeighbors = (neighbors ++ subtypesWithSameEdgeAndDirection).map(_.neighbor).toSet
526526
// deriveCommonRootType(relevantNeighbors)
527527
// }
528-
val neighborNodesType = "_ <: StoredNode"
528+
val neighborNodesType = "StoredNode"
529529
val genericEdgeAccessor = s"def $edgeAccessorName: Iterator[$neighborNodesType]"
530530

531531
val specificNodeAccessors = neighbors.flatMap { adjacentNode =>
@@ -1011,7 +1011,8 @@ class CodeGen(schema: Schema) {
10111011
}.mkString(lineSeparator)
10121012

10131013
val neighborNodeClass = neighborInfo.deriveNeighborNodeType.getOrElse(schema.anyNode).className
1014-
s"""def $edgeAccessorName: Iterator[$neighborNodeClass] = get().$edgeAccessorName
1014+
s"""/** Actually this Iterator includes only `$neighborNodeClass` nodes, but we need to stick to the inherited type from BaseNode */
1015+
|def $edgeAccessorName: Iterator[StoredNode] = get().$edgeAccessorName
10151016
|override def _$edgeAccessorName = get()._$edgeAccessorName
10161017
|
10171018
|$nodeDelegators
@@ -1154,7 +1155,7 @@ class CodeGen(schema: Schema) {
11541155
|}""".stripMargin
11551156
}
11561157

1157-
def propertyBasedFields(properties: Seq[Property[_]]): String = {
1158+
def propertyBasedFields(properties: Seq[Property[?]]): String = {
11581159
import Property.Cardinality
11591160
properties.map { property =>
11601161
val publicName = camelCase(property.name)
@@ -1315,7 +1316,7 @@ class CodeGen(schema: Schema) {
13151316
}
13161317
}
13171318

1318-
def generatePropertyTraversals(properties: Seq[Property[_]]): Seq[String] = {
1319+
def generatePropertyTraversals(properties: Seq[Property[?]]): Seq[String] = {
13191320
import Property.Cardinality
13201321
properties.map { property =>
13211322
val nameCamelCase = camelCase(property.name)
@@ -1730,7 +1731,7 @@ class CodeGen(schema: Schema) {
17301731
|}
17311732
|""".stripMargin
17321733

1733-
def generateNewNodeSource(nodeType: NodeType, properties: Seq[Property[_]], inEdges: Map[String, Set[String]], outEdges: Map[String, Set[String]]) = {
1734+
def generateNewNodeSource(nodeType: NodeType, properties: Seq[Property[?]], inEdges: Map[String, Set[String]], outEdges: Map[String, Set[String]]) = {
17341735
import Property.Cardinality
17351736
case class FieldDescription(name: String, valueType: String, fullType: String, cardinality: Cardinality)
17361737
val fieldDescriptions = mutable.ArrayBuffer.empty[FieldDescription]

codegen/src/main/scala/overflowdb/codegen/Formatter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import org.scalafmt.interfaces.Scalafmt
66

77
object Formatter {
88
val defaultScalafmtConfig = """
9-
|version=3.4.3
10-
|runner.dialect=scala213
9+
|version=3.8.1
10+
|runner.dialect=scala3
1111
|align.preset=some
1212
|maxColumn=120
1313
|""".stripMargin

codegen/src/main/scala/overflowdb/codegen/Helpers.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ object Helpers {
120120
}
121121
}
122122

123-
def getCompleteType[A](property: Property[_]): String =
123+
def getCompleteType[A](property: Property[?]): String =
124124
getCompleteType(property.cardinality, typeFor(property))
125125

126126
def typeFor(containedNode: ContainedNode): String = {
@@ -178,7 +178,7 @@ object Helpers {
178178
}
179179
}
180180

181-
def propertyDefaultValueImpl(propertyDefaultsPath: String, properties: Seq[Property[_]]): String = {
181+
def propertyDefaultValueImpl(propertyDefaultsPath: String, properties: Seq[Property[?]]): String = {
182182
val propertyDefaultValueCases = properties.collect {
183183
case property if property.hasDefault =>
184184
s"""case "${property.name}" => $propertyDefaultsPath.${property.className}"""
@@ -192,14 +192,14 @@ object Helpers {
192192
|""".stripMargin
193193
}
194194

195-
def propertyDefaultCases(properties: Seq[Property[_]]): String = {
195+
def propertyDefaultCases(properties: Seq[Property[?]]): String = {
196196
properties.collect {
197197
case p if p.hasDefault =>
198198
s"""val ${p.className} = ${defaultValueImpl(p.default.get)}"""
199199
}.mkString(s"$lineSeparator| ")
200200
}
201201

202-
def propertyAccessors(properties: Seq[Property[_]]): String = {
202+
def propertyAccessors(properties: Seq[Property[?]]): String = {
203203
properties.map { property =>
204204
val camelCaseName = camelCase(property.name)
205205
val tpe = getCompleteType(property)
@@ -209,10 +209,10 @@ object Helpers {
209209

210210
val propertyErrorRegisterImpl =
211211
s"""object PropertyErrorRegister {
212-
| private var errorMap = Set[(Class[_], String)]()
212+
| private var errorMap = Set[(Class[?], String)]()
213213
| private val logger = org.slf4j.LoggerFactory.getLogger(getClass)
214214
|
215-
| def logPropertyErrorIfFirst(clazz: Class[_], propertyName: String): Unit = {
215+
| def logPropertyErrorIfFirst(clazz: Class[?], propertyName: String): Unit = {
216216
| if (!errorMap.contains((clazz, propertyName))) {
217217
| logger.warn("Property " + propertyName + " is deprecated for " + clazz.getName + ".")
218218
| errorMap += ((clazz, propertyName))

codegen/src/main/scala/overflowdb/codegen/ProtoGen.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ class ProtoGen(schema: Schema) {
226226
}.mkString("\n")
227227
}
228228

229-
private def enumEntryMaybe(constant: Constant[_]): EnumEntryMaybe =
229+
private def enumEntryMaybe(constant: Constant[?]): EnumEntryMaybe =
230230
EnumEntryMaybe(constant.protoId, constant.name, constant.comment)
231231

232-
private def enumEntryMaybe(property: Property[_]): EnumEntryMaybe =
232+
private def enumEntryMaybe(property: Property[?]): EnumEntryMaybe =
233233
EnumEntryMaybe(property.protoId, property.name, property.comment)
234234

235235
private def enumEntryMaybe(nodeType: NodeType): EnumEntryMaybe =

codegen/src/main/scala/overflowdb/schema/Schema.scala

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ import scala.collection.mutable
1313
class Schema(val domainShortName: String,
1414
val basePackage: String,
1515
val additionalTraversalsPackages: Seq[String],
16-
val properties: Seq[Property[_]],
16+
val properties: Seq[Property[?]],
1717
val anyNode: AnyNodeType,
1818
val nodeBaseTypes: Seq[NodeBaseType],
1919
val nodeTypes: Seq[NodeType],
2020
val edgeTypes: Seq[EdgeType],
21-
val constantsByCategory: Map[String, Seq[Constant[_]]],
21+
val constantsByCategory: Map[String, Seq[Constant[?]]],
2222
val protoOptions: Option[ProtoOptions],
23-
val noWarnList: Set[(AbstractNodeType, Property[_])]) {
23+
val noWarnList: Set[(AbstractNodeType, Property[?])]) {
2424

2525
/** nodeTypes and nodeBaseTypes combined */
2626
lazy val allNodeTypes: Seq[AbstractNodeType] =
2727
nodeTypes ++ nodeBaseTypes
2828

2929
/** properties that are used in node types */
30-
def nodeProperties: Seq[Property[_]] =
30+
def nodeProperties: Seq[Property[?]] =
3131
properties.filter(property =>
3232
(nodeTypes ++ nodeBaseTypes).exists(_.properties.contains(property))
3333
)
3434

3535
/** properties that are used in edge types */
36-
def edgeProperties: Seq[Property[_]] =
36+
def edgeProperties: Seq[Property[?]] =
3737
properties.filter(property =>
3838
edgeTypes.exists(_.properties.contains(property))
3939
)
@@ -58,12 +58,12 @@ abstract class AbstractNodeType(val name: String, val comment: Option[String], v
5858
def starterName(name:String): this.type = {this._starterName = Option(name); this}
5959
def withoutStarter(): this.type = starterName(null)
6060
/** properties (including potentially inherited properties) */
61-
override def properties: Seq[Property[_]] = {
61+
override def properties: Seq[Property[?]] = {
6262
val entireClassHierarchy = this +: extendzRecursively
6363
entireClassHierarchy.flatMap(_.propertiesWithoutInheritance).distinct.sortBy(_.name.toLowerCase)
6464
}
6565

66-
def propertiesWithoutInheritance: Seq[Property[_]] =
66+
def propertiesWithoutInheritance: Seq[Property[?]] =
6767
_properties.toSeq.sortBy(_.name.toLowerCase)
6868

6969
def extendz(additional: NodeBaseType*): this.type = {
@@ -139,14 +139,14 @@ class NodeType(name: String, comment: Option[String], schemaInfo: SchemaInfo)
139139
extends AbstractNodeType(name, comment, schemaInfo) with HasOptionalProtoId {
140140
protected val _containedNodes: mutable.Set[ContainedNode] = mutable.Set.empty
141141

142-
private var _primaryKey: Option[Property[_]] = None
142+
private var _primaryKey: Option[Property[?]] = None
143143

144-
def primaryKey(p: Property[_]): this.type = {
144+
def primaryKey(p: Property[?]): this.type = {
145145
this._primaryKey = Option(p)
146146
this
147147
}
148148

149-
def primaryKey: Option[Property[_]] = this._primaryKey
149+
def primaryKey: Option[Property[?]] = this._primaryKey
150150

151151
lazy val classNameDb = s"${className}Db"
152152

@@ -212,7 +212,7 @@ class EdgeType(val name: String, val comment: Option[String], val schemaInfo: Sc
212212
override def toString = s"EdgeType($name)"
213213

214214
/** properties (including potentially inherited properties) */
215-
def properties: Seq[Property[_]] =
215+
def properties: Seq[Property[?]] =
216216
_properties.toSeq.sortBy(_.name.toLowerCase)
217217
}
218218

@@ -240,7 +240,7 @@ class Property[A](val name: String,
240240
}
241241

242242
def isMandatory: Boolean =
243-
cardinality.isInstanceOf[Cardinality.One[_]]
243+
cardinality.isInstanceOf[Cardinality.One[?]]
244244

245245
def hasDefault: Boolean =
246246
default.isDefined
@@ -273,7 +273,7 @@ object Property {
273273
object Long extends ValueType[Long]
274274
object Float extends ValueType[Float]
275275
object Double extends ValueType[Double]
276-
object List extends ValueType[Seq[_]]
276+
object List extends ValueType[Seq[?]]
277277
object Char extends ValueType[Char]
278278
object NodeRef extends ValueType[Any]
279279
object Unknown extends ValueType[Any]
@@ -357,20 +357,20 @@ trait HasClassName {
357357
}
358358

359359
trait HasProperties {
360-
protected val _properties: mutable.Set[Property[_]] = mutable.Set.empty
360+
protected val _properties: mutable.Set[Property[?]] = mutable.Set.empty
361361

362-
def addProperty(additional: Property[_]): this.type = {
362+
def addProperty(additional: Property[?]): this.type = {
363363
_properties.add(additional)
364364
this
365365
}
366366

367-
def addProperties(additional: Property[_]*): this.type = {
367+
def addProperties(additional: Property[?]*): this.type = {
368368
additional.foreach(addProperty)
369369
this
370370
}
371371

372372
/** properties (including potentially inherited properties) */
373-
def properties: Seq[Property[_]]
373+
def properties: Seq[Property[?]]
374374
}
375375

376376
trait HasOptionalProtoId {
@@ -390,10 +390,10 @@ trait HasSchemaInfo {
390390

391391
/** carry extra information on where a schema element is being defined, e.g. when we want to be able to
392392
* refer back that `node XYZ` was defined in `BaseSchema`, e.g. for documentation */
393-
case class SchemaInfo(definedIn: Option[Class[_]])
393+
case class SchemaInfo(definedIn: Option[Class[?]])
394394
object SchemaInfo {
395395
val Unknown = SchemaInfo(None)
396396

397-
def forClass(schemaClass: Class[_]): SchemaInfo =
397+
def forClass(schemaClass: Class[?]): SchemaInfo =
398398
SchemaInfo(Option(schemaClass))
399399
}

codegen/src/main/scala/overflowdb/schema/SchemaBuilder.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import scala.collection.mutable
88
class SchemaBuilder(domainShortName: String,
99
basePackage: String,
1010
additionalTraversalsPackages: Seq[String] = Seq.empty) {
11-
val properties = mutable.ListBuffer.empty[Property[_]]
11+
val properties = mutable.ListBuffer.empty[Property[?]]
1212
val nodeBaseTypes = mutable.ListBuffer.empty[NodeBaseType]
1313
val nodeTypes = mutable.ListBuffer.empty[NodeType]
1414
val edgeTypes = mutable.ListBuffer.empty[EdgeType]
15-
val constantsByCategory = mutable.Map.empty[String, Seq[Constant[_]]]
15+
val constantsByCategory = mutable.Map.empty[String, Seq[Constant[?]]]
1616
var protoOptions: Option[ProtoOptions] = None
17-
val noWarnList: mutable.Set[(AbstractNodeType, Property[_])] = mutable.Set.empty
17+
val noWarnList: mutable.Set[(AbstractNodeType, Property[?])] = mutable.Set.empty
1818

1919
/** root node trait for all nodes - use if you want to be explicitly unspecific */
2020
lazy val anyNode: AnyNodeType = new AnyNodeType
@@ -38,7 +38,7 @@ class SchemaBuilder(domainShortName: String,
3838
implicit schemaInfo: SchemaInfo = SchemaInfo.Unknown): NodeType =
3939
addAndReturn(nodeTypes, new NodeType(name, stringToOption(comment), schemaInfo))
4040

41-
def addConstants(category: String, constants: Constant[_]*): Seq[Constant[_]] = {
41+
def addConstants(category: String, constants: Constant[?]*): Seq[Constant[?]] = {
4242
val previousEntries = constantsByCategory.getOrElse(category, Seq.empty)
4343
constantsByCategory.put(category, previousEntries ++ constants)
4444
constants
@@ -49,7 +49,7 @@ class SchemaBuilder(domainShortName: String,
4949
this
5050
}
5151

52-
def dontWarnForDuplicateProperty(nodeType: AbstractNodeType, property: Property[_]): SchemaBuilder = {
52+
def dontWarnForDuplicateProperty(nodeType: AbstractNodeType, property: Property[?]): SchemaBuilder = {
5353
noWarnList.add((nodeType, property))
5454
this
5555
}

project/Build.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Versions {
55
val overflowdb = "1.185"
66
val scala_2_12 = "2.12.17"
77
val scala_2_13 = "2.13.10"
8-
val scala_3 = "3.3.1"
8+
val scala_3 = "3.3.3"
99
}
1010

1111
object Projects {

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.9.3
1+
sbt.version=1.9.9

0 commit comments

Comments
 (0)