Skip to content

Commit

Permalink
add explicit type (#2825)
Browse files Browse the repository at this point in the history
prepare Scala 2.13.12

- scala/scala#10439
  • Loading branch information
nafg committed Sep 10, 2023
2 parents b2d08a9 + 7409c2c commit dd92938
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 61 deletions.
Expand Up @@ -175,12 +175,12 @@ abstract class AbstractGenerator[Code,TermName,TypeName](model: m.Model)
def doc = "Maps whole row to an option. Useful for outer joins."
override def enabled = optionEnabled
def code = option
def rawName = ???
def rawName: String = ???
}
def StarDef = new AbstractDef {
def doc = ""
def code = star
def rawName = ???
def rawName: String = ???
}

Seq[Seq[AbstractDef]](
Expand Down
Expand Up @@ -22,7 +22,7 @@ object GenerateMainSources extends TestCodeGenerator {
new Config("DB2", StandardTestDBs.DB2, "DB2", Seq("/dbs/db2.sql")),
new Config("DerbyMem", StandardTestDBs.DerbyMem, "DerbyMem", Seq("/dbs/derby.sql")),
new Config("CG7", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2.sql")) {
override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def generator: DBIO[SourceCodeGenerator] = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def entityName = {
case "COFFEES" => "Coff"
case other => super.entityName(other)
Expand All @@ -34,19 +34,19 @@ object GenerateMainSources extends TestCodeGenerator {
}
override def code = "trait AA; trait BB\n" + super.code
override def Table = new Table(_){
override def EntityType = new EntityType{
override def EntityType: EntityType = new EntityType{
override def parents = Seq("AA","BB")
}
override def TableClass = new TableClass{
override def TableClass: TableClass = new TableClass{
override def parents = Seq("AA","BB")
}
}
})
},
new Config("CG8", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2-simple.sql")) {
override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def generator: DBIO[SourceCodeGenerator] = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_){
override def EntityType = new EntityType{
override def EntityType: EntityType = new EntityType{
override def enabled = false
}
override def mappingEnabled = true
Expand All @@ -71,7 +71,7 @@ import CustomTyping.SimpleA
})
},
new Config("CG9", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2.sql")) {
override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def generator: DBIO[SourceCodeGenerator] = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_){
override def autoIncLast = true
override def Column = new Column(_){
Expand All @@ -82,7 +82,7 @@ import CustomTyping.SimpleA
},
new UUIDConfig("CG10", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/uuid-h2.sql")),
new Config("CG11", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2-simple.sql")) {
override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def generator: DBIO[SourceCodeGenerator] = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_){
override def Column = new Column(_){
override def asOption = true
Expand All @@ -98,7 +98,7 @@ import CustomTyping.SimpleA
def blob = column[Blob]("blob")
def * = (id, ba, blob)
}
override def generator =
override def generator: slick.dbio.DBIO[SourceCodeGenerator] =
TableQuery[A].schema.create >>
tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_))
override def testCode =
Expand Down Expand Up @@ -146,7 +146,7 @@ import CustomTyping.SimpleA
def quote = column[String]("x", O.Default("\"\"")) // column name with double quote
def * = quote
}
override def generator =
override def generator: slick.dbio.DBIO[SourceCodeGenerator] =
TableQuery[A].schema.create >>
tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_))
override def testCode =
Expand All @@ -162,7 +162,7 @@ import CustomTyping.SimpleA
new Config("MySQL", StandardTestDBs.MySQL, "MySQL", Seq("/dbs/mysql.sql") ){
override def generator: DBIO[SourceCodeGenerator] =
tdb.profile.createModel(ignoreInvalidDefaults=false).map(new SourceCodeGenerator(_){
override def parentType = Some("com.typesafe.slick.testkit.util.TestCodeRunner.TestCase")
override def parentType: Option[String] = Some("com.typesafe.slick.testkit.util.TestCodeRunner.TestCase")
override def code = {
val testcode =
"""
Expand Down Expand Up @@ -223,7 +223,7 @@ import CustomTyping.SimpleA
//Unified UUID config
class UUIDConfig(objectName: String, tdb: JdbcTestDB, tdbName: String, initScripts: Seq[String])
extends Config(objectName, tdb, tdbName, initScripts) {
override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def generator: DBIO[SourceCodeGenerator] = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_) {
override def Column = new Column(_){
override def defaultCode: Any => String = {
Expand Down
Expand Up @@ -23,7 +23,7 @@ object GenerateRoundtripSources {
import Tables.profile.api.*
val ddl = posts.schema ++ categories.schema ++ typeTest.schema ++ large.schema ++ `null`.schema ++ X.schema ++ SingleNonOptionColumn.schema ++ SelfRef.schema
val a1 = profile.createModel(ignoreInvalidDefaults=false).map(m => new SourceCodeGenerator(m) {
override def parentType = Some("slick.test.codegen.EmptyTestTrait")
override def parentType: Option[String] = Some("slick.test.codegen.EmptyTestTrait")
override def Table = new Table(_)
{
override def hugeClassEnabled = false // HList type instead of case classes (like with Slick before 3.3)
Expand Down
Expand Up @@ -377,8 +377,8 @@ class JdbcMapperTest extends AsyncTest[JdbcTestDB] {

// A Shape that maps Pair to a ProductNode
final class PairShape[Level <: ShapeLevel, M <: Pair[_,_], U <: Pair[_,_] : ClassTag, P <: Pair[_,_]](val shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]) extends MappedScalaProductShape[Level, Pair[_,_], M, U, P] {
def buildValue(elems: IndexedSeq[Any]) = Pair(elems(0), elems(1))
def copy(shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]) = new PairShape(shapes)
def buildValue(elems: IndexedSeq[Any]): Any = Pair(elems(0), elems(1))
def copy(shapes: Seq[Shape[_ <: ShapeLevel, _, _, _]]): Shape[Level, _, _, _] = new PairShape(shapes)
}
implicit def pairShape[Level <: ShapeLevel, M1, M2, U1, U2, P1, P2](implicit s1: Shape[_ <: Level, M1, U1, P1], s2: Shape[_ <: Level, M2, U2, P2]): PairShape[Level, Pair[M1, M2], Pair[U1, U2], Pair[P1, P2]] =
new PairShape[Level, Pair[M1, M2], Pair[U1, U2], Pair[P1, P2]](Seq(s1, s2))
Expand Down
Expand Up @@ -28,7 +28,7 @@ object StandardTestDBs {
lazy val H2Rownum = new H2TestDB("h2rownum", false) {
val url = "jdbc:h2:mem:test_rownum"
override def isPersistent = false
override val profile = new H2Profile {
override val profile: Profile = new H2Profile {
override protected def computeQueryCompiler =
super.computeQueryCompiler.addAfter(Phase.removeTakeDrop, Phase.expandSums)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ object StandardTestDBs {
}

lazy val Postgres = new ExternalJdbcTestDB("postgres") {
val profile = PostgresProfile
val profile: Profile = PostgresProfile
override def localTables(implicit ec: ExecutionContext): DBIO[Vector[String]] =
ResultSetAction[(String,String,String, String)](_.conn.getMetaData.getTables("", "public", null, null))
.map(_.filter(_._4.toUpperCase == "TABLE").map(_._3).sorted)
Expand All @@ -121,7 +121,7 @@ object StandardTestDBs {
}

lazy val MySQL = new ExternalJdbcTestDB("mysql") {
val profile = MySQLProfile
val profile: Profile = MySQLProfile
// Recreating the DB is faster than dropping everything individually
override def dropUserArtifacts(implicit session: profile.backend.Session) = {
session.close()
Expand All @@ -138,13 +138,13 @@ object StandardTestDBs {
val db = session.database
db.getTables.foreach(t => db.dropTable(t.name))
}
def assertTablesExist(tables: String*) = profile.api.SimpleDBIO { ctx =>
def assertTablesExist(tables: String*): DBIO[Unit] = profile.api.SimpleDBIO { ctx =>
val all = ctx.session.database.getTables.map(_.name).toSet
for(t <- tables) {
if(!all.contains(t)) Assert.fail("Table "+t+" should exist")
}
}
def assertNotTablesExist(tables: String*) = profile.api.SimpleDBIO { ctx =>
def assertNotTablesExist(tables: String*): DBIO[Unit] = profile.api.SimpleDBIO { ctx =>
val all = ctx.session.database.getTables.map(_.name).toSet
for(t <- tables) {
if(all.contains(t)) Assert.fail("Table "+t+" should not exist")
Expand All @@ -153,7 +153,7 @@ object StandardTestDBs {
}

lazy val DB2 = new ExternalJdbcTestDB("db2") {
val profile = DB2Profile
val profile: Profile = DB2Profile
import profile.api.actionBasedSQLInterpolation

override def canGetLocalTables = false
Expand Down Expand Up @@ -221,7 +221,7 @@ object StandardTestDBs {
}

lazy val Oracle = new ExternalJdbcTestDB("oracle") {
val profile = OracleProfile
val profile: Profile = OracleProfile
import profile.api.actionBasedSQLInterpolation

override def canGetLocalTables = false
Expand Down
Expand Up @@ -49,7 +49,7 @@ class CodeGeneratorAllTest(val tdb: JdbcTestDB) extends DBTest {
// override table generator
override def Table = new Table(_){
// disable entity class generation and mapping
override def EntityType = new EntityType{
override def EntityType: EntityType = new EntityType{
override def classEnabled = false
}

Expand Down
Expand Up @@ -6,6 +6,7 @@ import slick.jdbc.meta.MTable
import slick.test.codegen.generated._
import com.typesafe.slick.testkit.util.TestCodeRunner
import org.junit.Assert._
import slick.jdbc.JdbcProfile

/** Test files generated by CodeGeneratorTest */
class GeneratedCodeTest extends TestCodeRunner(AllTests)
Expand Down Expand Up @@ -66,7 +67,7 @@ object GeneratedCodeTest {

def testCG2 = {
class Db1 extends CG2 {
val profile = slick.jdbc.HsqldbProfile
val profile: JdbcProfile = slick.jdbc.HsqldbProfile
}
val Db1 = new Db1
import Db1._
Expand Down
2 changes: 1 addition & 1 deletion slick/src/main/scala-2/slick/lifted/TableQuery.scala
Expand Up @@ -10,7 +10,7 @@ import scala.reflect.macros.blackbox.Context
* for operations that can be performed on tables but not on arbitrary
* queries, e.g. getting the table DDL. */
class TableQuery[E <: AbstractTable[_]](cons: Tag => E) extends Query[E, E#TableElementType, Seq] {
lazy val shaped = {
lazy val shaped: ShapedValue[_ <: E, E#TableElementType] = {
val baseTable = cons(new BaseTag { base =>
def taggedAs(path: Node): AbstractTable[_] = cons(new RefTag(path) {
def taggedAs(path: Node) = base.taggedAs(path)
Expand Down
2 changes: 1 addition & 1 deletion slick/src/main/scala/slick/ast/Comprehension.scala
Expand Up @@ -17,7 +17,7 @@ final case class Comprehension[+Fetch <: Option[Node]](sym: TermSymbol,
offset: Option[Node] = None,
forUpdate: Boolean = false) extends DefNode {
type Self = Comprehension[Option[Node]]
override def self = this
override def self: Self = this
lazy val children =
(ConstArray.newBuilder() +
from +
Expand Down
2 changes: 1 addition & 1 deletion slick/src/main/scala/slick/ast/Type.scala
Expand Up @@ -263,7 +263,7 @@ final case class NominalType(sym: TypeSymbol, structuralView: Type) extends Type
trait TypedType[T] extends Type { self =>
def optionType: OptionTypedType[T] = new OptionTypedType[T] {
val elementType = self
def scalaType = new ScalaOptionType[T](self.scalaType)
def scalaType: ScalaType[Option[T]] = new ScalaOptionType[T](self.scalaType)
def mapChildren(f: Type => Type): Type = {
val e2 = f(elementType)
if(e2 eq elementType) this
Expand Down
10 changes: 5 additions & 5 deletions slick/src/main/scala/slick/dbio/DBIOAction.scala
Expand Up @@ -185,17 +185,17 @@ object DBIOAction {
g.foreach(a => b += a.asInstanceOf[SynchronousDatabaseAction[R, NoStream, BasicBackend#BasicActionContext, BasicBackend#BasicStreamingActionContext, E]].run(context))
b.result()
}
override def nonFusedEquivalentAction = SequenceAction[R, M[R], E](g)
override def nonFusedEquivalentAction: DBIOAction[M[R], NoStream, E] = SequenceAction[R, M[R], E](g)
}
} else SequenceAction[R, M[R], E](g)
}
def sequenceGroupAsSeq(g: Vector[DBIOAction[R, NoStream, E]]): DBIOAction[Seq[R], NoStream, E] = {
if(g.length == 1) {
if(g.head.isInstanceOf[SynchronousDatabaseAction[_, _, _, _, _]]) { // fuse synchronous group
new SynchronousDatabaseAction.Fused[Seq[R], NoStream, BasicBackend#BasicActionContext, BasicBackend#BasicStreamingActionContext, E] {
def run(context: BasicBackend#BasicActionContext) =
def run(context: BasicBackend#BasicActionContext): Seq[R] =
g.head.asInstanceOf[SynchronousDatabaseAction[R, NoStream, BasicBackend#BasicActionContext, BasicBackend#BasicStreamingActionContext, E]].run(context) :: Nil
override def nonFusedEquivalentAction = g.head.map(_ :: Nil)
override def nonFusedEquivalentAction: DBIOAction[Seq[R], NoStream, E] = g.head.map(_ :: Nil)
}
} else g.head.map(_ :: Nil)
} else {
Expand All @@ -206,7 +206,7 @@ object DBIOAction {
g.foreach(a => b += a.asInstanceOf[SynchronousDatabaseAction[R, NoStream, BasicBackend#BasicActionContext, BasicBackend#BasicStreamingActionContext, E]].run(context))
b.toIndexedSeq
}
override def nonFusedEquivalentAction = SequenceAction[R, Seq[R], E](g)
override def nonFusedEquivalentAction: DBIOAction[Seq[R], NoStream, E] = SequenceAction[R, Seq[R], E](g)
}
} else SequenceAction[R, Seq[R], E](g)
}
Expand Down Expand Up @@ -237,7 +237,7 @@ object DBIOAction {
def run(context: BasicBackend#BasicActionContext) = {
g.foreach(_.asInstanceOf[SynchronousDatabaseAction[Any, NoStream, BasicBackend#BasicActionContext, BasicBackend#BasicStreamingActionContext, E]].run(context))
}
override def nonFusedEquivalentAction = AndThenAction[Unit, NoStream, E](g)
override def nonFusedEquivalentAction: DBIOAction[Unit, NoStream, E] = AndThenAction[Unit, NoStream, E](g)
}
}
if(actions.isEmpty) DBIO.successful(()) else {
Expand Down
4 changes: 2 additions & 2 deletions slick/src/main/scala/slick/jdbc/JdbcActionComponent.scala
Expand Up @@ -218,9 +218,9 @@ trait JdbcActionComponent extends SqlActionComponent { self: JdbcProfile =>
case (rsm @ ResultSetMapping(_, compiled, CompiledMapping(_, elemType))) :@ (ct: CollectionType) =>
val sql = findSql(compiled)
new StreamingInvokerAction[R, Any, Effect] { streamingAction =>
protected[this] def createInvoker(sql: Iterable[String]) = createQueryInvoker(rsm, param, sql.head)
protected[this] def createInvoker(sql: Iterable[String]): Invoker[Any] = createQueryInvoker(rsm, param, sql.head)
protected[this] def createBuilder = ct.cons.createBuilder(ct.elementType.classTag).asInstanceOf[Builder[Any, R]]
def statements = List(sql)
def statements: Iterable[String] = List(sql)
override def getDumpInfo = super.getDumpInfo.copy(name = "result")
}
case First(rsm @ ResultSetMapping(_, compiled, _)) =>
Expand Down
2 changes: 1 addition & 1 deletion slick/src/main/scala/slick/jdbc/JdbcBackend.scala
Expand Up @@ -28,7 +28,7 @@ trait JdbcBackend extends RelationalBackend {
type Context = JdbcActionContext
type StreamingContext = JdbcStreamingActionContext

val Database = new DatabaseFactoryDef {}
val Database: DatabaseFactory = new DatabaseFactoryDef {}
val backend: JdbcBackend = this

def createDatabase(config: Config, path: String): Database = Database.forConfig(path, config)
Expand Down
Expand Up @@ -116,7 +116,7 @@ trait JdbcStatementBuilderComponent { self: JdbcProfile =>
// Mutable state accessible to subclasses
protected val b = new SQLBuilder
protected var currentPart: StatementPart = OtherPart
val symbolName = new QuotingSymbolNamer(Some(state.symbolNamer))
val symbolName: SymbolNamer = new QuotingSymbolNamer(Some(state.symbolNamer))
protected val joins = new mutable.HashMap[TermSymbol, Join]
protected var currentUniqueFrom: Option[TermSymbol] = None

Expand Down
4 changes: 2 additions & 2 deletions slick/src/main/scala/slick/jdbc/ResultSetInvoker.scala
Expand Up @@ -42,7 +42,7 @@ object ResultSetInvoker {
object ResultSetAction {
def apply[R](f: JdbcBackend#JdbcSessionDef => ResultSet)(implicit conv: PositionedResult => R): BasicStreamingAction[Vector[R], R, Effect.Read] = new StreamingInvokerAction[Vector[R], R, Effect.Read] {
protected[this] def createInvoker(sql: Iterable[String]) = ResultSetInvoker(f)(conv)
protected[this] def createBuilder = Vector.newBuilder[R]
def statements = Nil
protected[this] def createBuilder: collection.mutable.Builder[R, Vector[R]] = Vector.newBuilder[R]
def statements: Iterable[String] = Nil
}
}
2 changes: 1 addition & 1 deletion slick/src/main/scala/slick/jdbc/StatementInvoker.scala
Expand Up @@ -20,7 +20,7 @@ abstract class StatementInvoker[+R] extends Invoker[R] { self =>

protected def getStatement: String
protected def setParam(st: PreparedStatement): Unit
override protected def debuggingId = Some(s"statement $getStatement")
override protected def debuggingId: Option[String] = Some(s"statement $getStatement")

def iteratorTo(maxRows: Int)(implicit session: JdbcBackend#JdbcSessionDef): CloseableIterator[R] =
results(maxRows).fold(r => new CloseableIterator.Single[R](r.asInstanceOf[R]), identity)
Expand Down
6 changes: 3 additions & 3 deletions slick/src/main/scala/slick/jdbc/StaticQuery.scala
Expand Up @@ -61,13 +61,13 @@ object SQLActionBuilder {
case class SQLActionBuilder(sql: String, setParameter: SetParameter[Unit]) {
def as[R](implicit getResult: GetResult[R]): SqlStreamingAction[Vector[R], R, Effect] = {
new StreamingInvokerAction[Vector[R], R, Effect] {
def statements = List(sql)
protected[this] def createInvoker(statements: Iterable[String]) = new StatementInvoker[R] {
def statements: Iterable[String] = List(sql)
protected[this] def createInvoker(statements: Iterable[String]): Invoker[R] = new StatementInvoker[R] {
val getStatement = statements.head
protected def setParam(st: PreparedStatement) = setParameter((), new PositionedParameters(st))
protected def extractValue(rs: PositionedResult): R = getResult(rs)
}
protected[this] def createBuilder = Vector.newBuilder[R]
protected[this] def createBuilder: collection.mutable.Builder[R, Vector[R]] = Vector.newBuilder[R]
}
}
def asUpdate = as[Int](GetResult.GetUpdateValue).head
Expand Down
2 changes: 1 addition & 1 deletion slick/src/main/scala/slick/lifted/Compiled.scala
Expand Up @@ -83,7 +83,7 @@ class AppliedCompiledFunction[PU, R <: Rep[?], RU](val param: PU,
def compiledQuery = function.compiledQuery
def compiledUpdate = function.compiledUpdate
def compiledDelete = function.compiledDelete
def compiledInsert = function.compiledInsert
def compiledInsert: Any = function.compiledInsert
}

abstract class CompiledExecutable[R, RU](val extract: R, val profile: BasicProfile)
Expand Down
4 changes: 2 additions & 2 deletions slick/src/main/scala/slick/lifted/Query.scala
Expand Up @@ -264,7 +264,7 @@ sealed trait QueryBase[T] extends Rep[T]
/** Change the collection type to build when executing the query. */
def to[D[_]](implicit ctc: TypedCollectionTypeConstructor[D]): Query[E, U, D] = new Query[E, U, D] {
val shaped = self.shaped
def toNode = CollectionCast(self.toNode, ctc)
def toNode: Node = CollectionCast(self.toNode, ctc)
}

/** Force a subquery to be created when using this Query as part of a larger Query. This method
Expand All @@ -285,7 +285,7 @@ object Query {
/** The empty Query. */
def empty: Query[Unit, Unit, Seq] = new Query[Unit, Unit, Seq] {
val toNode = shaped.toNode
def shaped = ShapedValue((), Shape.unitShape[FlatShapeLevel])
def shaped: ShapedValue[? <: Unit, Unit] = ShapedValue((), Shape.unitShape[FlatShapeLevel])
}

@inline implicit def queryShape[
Expand Down

0 comments on commit dd92938

Please sign in to comment.