diff --git a/build.sbt b/build.sbt index e304defbe..f60a5dd13 100644 --- a/build.sbt +++ b/build.sbt @@ -8,8 +8,8 @@ lazy val commonSettings = Seq( "org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full ), addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), - scalaVersion := "2.13.11", - crossScalaVersions := Seq("2.13.11"), + scalaVersion := "2.13.12", + crossScalaVersions := Seq("2.13.12"), // from: https://tpolecat.github.io/2017/04/25/scalac-flags.html scalacOptions ++= Seq( "-deprecation", // Emit warning and location for usages of deprecated APIs. @@ -176,12 +176,12 @@ lazy val core = scalaTest.value % Test, scalaTestPlusScalacheck.value % Test, // needed for acyclic which we run periodically, not all the time - "com.lihaoyi" % "acyclic_2.13.11" % "0.3.9" % "provided" + "com.lihaoyi" % "acyclic_2.13.12" % "0.3.9" % "provided" ) // periodically we use acyclic to ban cyclic dependencies and make compilation faster , autoCompilerPlugins := true, - addCompilerPlugin("com.lihaoyi" % "acyclic_2.13.11" % "0.3.9"), + addCompilerPlugin("com.lihaoyi" % "acyclic_2.13.12" % "0.3.9"), scalacOptions += "-P:acyclic:force" ).dependsOn(base) .jsSettings(commonJsSettings) diff --git a/core/src/main/scala/org/bykn/bosatsu/DirectEC.scala b/core/src/main/scala/org/bykn/bosatsu/DirectEC.scala index 026da6e0a..4e2f42103 100644 --- a/core/src/main/scala/org/bykn/bosatsu/DirectEC.scala +++ b/core/src/main/scala/org/bykn/bosatsu/DirectEC.scala @@ -6,6 +6,6 @@ object DirectEC { implicit val directEC: ExecutionContext = new ExecutionContext { def execute(r: Runnable) = r.run() - def reportFailure(t: Throwable) = throw t + def reportFailure(t: Throwable): Unit = throw t } } diff --git a/core/src/main/scala/org/bykn/bosatsu/KindFormula.scala b/core/src/main/scala/org/bykn/bosatsu/KindFormula.scala index ad8cd4991..74de5513d 100644 --- a/core/src/main/scala/org/bykn/bosatsu/KindFormula.scala +++ b/core/src/main/scala/org/bykn/bosatsu/KindFormula.scala @@ -63,7 +63,7 @@ object KindFormula { idx: Int, kindArg: Kind.Arg ) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = if (value == kindArg.variance) Sat.Yes else Sat.No @@ -76,7 +76,7 @@ object KindFormula { bound: rankn.Type.Var.Bound, kindArg: Kind.Arg ) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = Sat(value == kindArg.variance) } @@ -88,20 +88,20 @@ object KindFormula { kind: Kind, kindArg: Kind.Arg ) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = Sat(value == kindArg.variance) } // arg idx of a given constructor function case class Accessor(cfn: ConstructorFn, idx: Int) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = Sat(value == Variance.co || value == Variance.in) } case class RecursiveView(cfn: ConstructorFn, idx: Int) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = Sat(value == Variance.co) } @@ -127,7 +127,7 @@ object KindFormula { inType: rankn.Type, variance: Variance ) extends Constraint { - def depends = Nil + def depends = List.empty[Var] def satisfied(known: LongMap[Variance], value: Variance) = Sat(value == variance) } @@ -233,7 +233,8 @@ object KindFormula { implicit val emptyTypeEnv: IsTypeEnv[Unit] = new IsTypeEnv[Unit] { - def getDefinedType(env: Unit, tc: rankn.Type.Const) = None + def getDefinedType(env: Unit, tc: rankn.Type.Const) = + Option.empty[DefinedType[Kind.Arg]] } } diff --git a/core/src/main/scala/org/bykn/bosatsu/ParallelViaProduct.scala b/core/src/main/scala/org/bykn/bosatsu/ParallelViaProduct.scala index 0d9e65f11..4021b0702 100644 --- a/core/src/main/scala/org/bykn/bosatsu/ParallelViaProduct.scala +++ b/core/src/main/scala/org/bykn/bosatsu/ParallelViaProduct.scala @@ -7,13 +7,15 @@ import cats.{Parallel, Applicative} abstract class ParallelViaProduct[G[_]] extends Parallel[G] { self => type F[A] = G[A] - val parallel = new FunctionK[G, F] { - def apply[A](ga: G[A]) = ga - } + val parallel: FunctionK[G, F] = + new FunctionK[G, F] { + def apply[A](ga: G[A]) = ga + } - val sequential = new FunctionK[F, G] { - def apply[A](fa: F[A]) = fa - } + val sequential: FunctionK[F, G] = + new FunctionK[F, G] { + def apply[A](fa: F[A]) = fa + } def parallelProduct[A, B](fa: F[A], fb: F[B]): F[(A, B)] diff --git a/core/src/main/scala/org/bykn/bosatsu/Shape.scala b/core/src/main/scala/org/bykn/bosatsu/Shape.scala index 52ac9d393..295c6ecb0 100644 --- a/core/src/main/scala/org/bykn/bosatsu/Shape.scala +++ b/core/src/main/scala/org/bykn/bosatsu/Shape.scala @@ -184,7 +184,7 @@ object Shape { implicit val emptyShapeEnv: IsShapeEnv[Unit] = new IsShapeEnv[Unit] { - def getShape(env: Unit, tc: rankn.Type.Const) = None + def getShape(env: Unit, tc: rankn.Type.Const) = Option.empty[KnownShape] } } diff --git a/core/src/main/scala/org/bykn/bosatsu/TotalityCheck.scala b/core/src/main/scala/org/bykn/bosatsu/TotalityCheck.scala index a5a1bb3c4..ca8876747 100644 --- a/core/src/main/scala/org/bykn/bosatsu/TotalityCheck.scala +++ b/core/src/main/scala/org/bykn/bosatsu/TotalityCheck.scala @@ -228,7 +228,7 @@ case class TotalityCheck(inEnv: TypeEnv[Any]) { lazy val patternSetOps: SetOps[Pattern[Cons, Type]] = new SetOps[Pattern[Cons, Type]] { self => - val top = Some(WildCard) + val top: Option[Pattern[Cons, Type]] = Some(WildCard) def intersection( left: Pattern[Cons, Type], diff --git a/core/src/main/scala/org/bykn/bosatsu/TypeRef.scala b/core/src/main/scala/org/bykn/bosatsu/TypeRef.scala index 63798ddf2..309ee7b52 100644 --- a/core/src/main/scala/org/bykn/bosatsu/TypeRef.scala +++ b/core/src/main/scala/org/bykn/bosatsu/TypeRef.scala @@ -109,19 +109,19 @@ object TypeRef { } private object TypeRefParser extends TypeParser[TypeRef] { - lazy val parseRoot = { + lazy val parseRoot: P[TypeRef] = { val tvar = Parser.lowerIdent.map(TypeVar(_)) val tname = Identifier.consParser.map { cn => TypeName(Name(cn)) } tvar.orElse(tname) } - def makeFn(in: NonEmptyList[TypeRef], out: TypeRef) = TypeArrow(in, out) + def makeFn(in: NonEmptyList[TypeRef], out: TypeRef): TypeRef = TypeArrow(in, out) - def applyTypes(cons: TypeRef, args: NonEmptyList[TypeRef]) = TypeApply(cons, args) - def universal(vars: NonEmptyList[(String, Option[Kind])], in: TypeRef) = + def applyTypes(cons: TypeRef, args: NonEmptyList[TypeRef]): TypeRef = TypeApply(cons, args) + def universal(vars: NonEmptyList[(String, Option[Kind])], in: TypeRef): TypeRef = TypeForAll(vars.map { case (s, k) => (TypeVar(s), k) }, in) - def makeTuple(items: List[TypeRef]) = TypeTuple(items) + def makeTuple(items: List[TypeRef]): TypeRef = TypeTuple(items) def unapplyRoot(a: TypeRef): Option[Doc] = a match { diff --git a/core/src/main/scala/org/bykn/bosatsu/TypedExprNormalization.scala b/core/src/main/scala/org/bykn/bosatsu/TypedExprNormalization.scala index 36f1d7bb5..aa1f04497 100644 --- a/core/src/main/scala/org/bykn/bosatsu/TypedExprNormalization.scala +++ b/core/src/main/scala/org/bykn/bosatsu/TypedExprNormalization.scala @@ -703,7 +703,7 @@ object TypedExprNormalization { case Pattern.Union(h, t) => (h :: t).toList.iterator.map(makeLet).reduce(_.orElse(_)) // $COVERAGE-OFF$ this is ill-typed so should be unreachable - case Pattern.PositionalStruct(_, _) | Pattern.ListPat(_) | Pattern.StrPat(_) | Pattern.Literal(Lit.Str(_)) => None + case Pattern.PositionalStruct(_, _) | Pattern.ListPat(_) | Pattern.StrPat(_) | Pattern.Literal(Lit.Str(_) | Lit.Chr(_)) => None // $COVERAGE-ON$ } diff --git a/core/src/main/scala/org/bykn/bosatsu/Variance.scala b/core/src/main/scala/org/bykn/bosatsu/Variance.scala index 73fcd2af6..eb5ab4925 100644 --- a/core/src/main/scala/org/bykn/bosatsu/Variance.scala +++ b/core/src/main/scala/org/bykn/bosatsu/Variance.scala @@ -55,7 +55,7 @@ object Variance { implicit val varianceBoundedSemilattice: BoundedSemilattice[Variance] = new BoundedSemilattice[Variance] { - override def empty = Phantom + override def empty = phantom override def combine(a: Variance, b: Variance): Variance = a + b } diff --git a/core/src/main/scala/org/bykn/bosatsu/codegen/python/Code.scala b/core/src/main/scala/org/bykn/bosatsu/codegen/python/Code.scala index 91765f49b..57a48e1e8 100644 --- a/core/src/main/scala/org/bykn/bosatsu/codegen/python/Code.scala +++ b/core/src/main/scala/org/bykn/bosatsu/codegen/python/Code.scala @@ -227,16 +227,16 @@ object Code { ///////////////////////// case class PyInt(toBigInteger: BigInteger) extends Expression { - def simplify = this + def simplify: Expression = this } case class PyString(content: String) extends Expression { - def simplify = this + def simplify: Expression = this } case class PyBool(toBoolean: Boolean) extends Expression { - def simplify = this + def simplify: Expression = this } case class Ident(name: String) extends Expression { - def simplify = this + def simplify: Expression = this } // Binary operator used for +, -, and, == etc... case class Op(left: Expression, op: Operator, right: Expression) extends Expression { @@ -445,7 +445,7 @@ object Code { } // foo[a:b] case class SelectRange(arg: Expression, start: Option[Expression], end: Option[Expression]) extends Expression { - def simplify = SelectRange(arg, start.map(_.simplify), end.map(_.simplify)) + def simplify: Expression = SelectRange(arg, start.map(_.simplify), end.map(_.simplify)) } case class Ternary(ifTrue: Expression, cond: Expression, ifFalse: Expression) extends Expression { def simplify: Expression = @@ -459,19 +459,19 @@ object Code { } } case class MakeTuple(args: List[Expression]) extends Expression { - def simplify = MakeTuple(args.map(_.simplify)) + def simplify: Expression = MakeTuple(args.map(_.simplify)) } case class MakeList(args: List[Expression]) extends Expression { - def simplify = MakeList(args.map(_.simplify)) + def simplify: Expression = MakeList(args.map(_.simplify)) } case class Lambda(args: List[Ident], result: Expression) extends Expression { - def simplify = Lambda(args, result.simplify) + def simplify: Expression = Lambda(args, result.simplify) } case class Apply(fn: Expression, args: List[Expression]) extends Expression { - def simplify = Apply(fn.simplify, args.map(_.simplify)) + def simplify: Expression = Apply(fn.simplify, args.map(_.simplify)) } case class DotSelect(ex: Expression, ident: Ident) extends Expression { - def simplify = DotSelect(ex.simplify, ident) + def simplify: Expression = DotSelect(ex.simplify, ident) } ///////////////////////// diff --git a/core/src/main/scala/org/bykn/bosatsu/codegen/python/PythonGen.scala b/core/src/main/scala/org/bykn/bosatsu/codegen/python/PythonGen.scala index 4ba25427d..874571827 100644 --- a/core/src/main/scala/org/bykn/bosatsu/codegen/python/PythonGen.scala +++ b/core/src/main/scala/org/bykn/bosatsu/codegen/python/PythonGen.scala @@ -26,7 +26,7 @@ object PythonGen { import Impl._ val m = Monad[State[EnvState, *]] - def pure[A](a: A) = EnvImpl(m.pure(a)) + def pure[A](a: A): Env[A] = EnvImpl(m.pure(a)) override def map[A, B](ea: Env[A])(fn: A => B): Env[B] = EnvImpl(m.map(ea.state)(fn)) def flatMap[A, B](ea: Env[A])(fn: A => Env[B]): Env[B] = diff --git a/core/src/main/scala/org/bykn/bosatsu/graph/Toposort.scala b/core/src/main/scala/org/bykn/bosatsu/graph/Toposort.scala index ce091d008..6f32343e6 100644 --- a/core/src/main/scala/org/bykn/bosatsu/graph/Toposort.scala +++ b/core/src/main/scala/org/bykn/bosatsu/graph/Toposort.scala @@ -34,7 +34,7 @@ object Toposort { def isFailure: Boolean = !isSuccess } final case class Success[A](layers: Vector[NonEmptyList[A]], nfn: A => List[A]) extends Result[A] { - def loopNodes = Nil + def loopNodes = List.empty[A] } final case class Failure[A](loopNodes: List[A], layers: Vector[NonEmptyList[A]]) extends Result[A] diff --git a/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPart.scala b/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPart.scala index 85a0eea70..e42d9bd78 100644 --- a/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPart.scala +++ b/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPart.scala @@ -44,7 +44,7 @@ object SeqPart { case Some(topA) => setOpsA.difference(topA, a).map(toPart1) } - val top = Some(AnyElem) + val top: Option[SeqPart1[A]] = Some(AnyElem) def isTop(c: SeqPart1[A]) = c match { case AnyElem => true diff --git a/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPattern.scala b/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPattern.scala index f67f20219..05eebdf97 100644 --- a/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPattern.scala +++ b/core/src/main/scala/org/bykn/bosatsu/pattern/SeqPattern.scala @@ -131,7 +131,7 @@ object SeqPattern { new SetOps[SeqPattern[A]] { import SeqPart.{SeqPart1, AnyElem, Wildcard} - lazy val top = Some(Wild) + val top: Option[SeqPattern[A]] = Some(Wild) def isTop(p: SeqPattern[A]) = p.matchesAny // Try to unify lists according to the rules: diff --git a/core/src/main/scala/org/bykn/bosatsu/pattern/Splitter.scala b/core/src/main/scala/org/bykn/bosatsu/pattern/Splitter.scala index 14c957cba..a988b7cff 100644 --- a/core/src/main/scala/org/bykn/bosatsu/pattern/Splitter.scala +++ b/core/src/main/scala/org/bykn/bosatsu/pattern/Splitter.scala @@ -105,7 +105,7 @@ object Splitter { final def cons(c: V, s: List[V]) = c :: s - final def emptySeq = Nil + final def emptySeq = List.empty[V] final def catSeqs(s: List[List[V]]) = s.flatten final override def toList(s: List[V]) = s final override def fromList(cs: List[V]) = cs diff --git a/core/src/main/scala/org/bykn/bosatsu/rankn/Infer.scala b/core/src/main/scala/org/bykn/bosatsu/rankn/Infer.scala index 81d16ae88..bd447323d 100644 --- a/core/src/main/scala/org/bykn/bosatsu/rankn/Infer.scala +++ b/core/src/main/scala/org/bykn/bosatsu/rankn/Infer.scala @@ -303,7 +303,7 @@ object Infer { // $COVERAGE-ON$ case object GetEnv extends Infer[Env] { - def run(env: Env) = RefSpace.pure(Right(env)) + def run(env: Env): RefSpace[Either[Error, Env]] = RefSpace.pure(Right(env)) } def GetDataCons(fqn: (PackageName, Constructor), reg: Region): Infer[Cons] = diff --git a/core/src/main/scala/org/bykn/bosatsu/rankn/Ref.scala b/core/src/main/scala/org/bykn/bosatsu/rankn/Ref.scala index 81912c563..fb22f9cbd 100644 --- a/core/src/main/scala/org/bykn/bosatsu/rankn/Ref.scala +++ b/core/src/main/scala/org/bykn/bosatsu/rankn/Ref.scala @@ -42,9 +42,9 @@ object RefSpace { value } private case class AllocRef[A](handle: Long, init: A) extends RefSpace[A] with Ref[A] { - def get = this - def set(a: A) = SetRef(handle, a) - val reset = Reset(handle) + def get: RefSpace[A] = this + def set(a: A): RefSpace[Unit] = SetRef(handle, a) + val reset: RefSpace[Unit] = Reset(handle) protected def runState(al: AtomicLong, state: State): Eval[A] = Eval.now { @@ -65,7 +65,7 @@ object RefSpace { { state.remove(handle); Eval.Unit } } private case class Alloc[A](init: A) extends RefSpace[Ref[A]] { - protected def runState(al: AtomicLong, state: State) = + protected def runState(al: AtomicLong, state: State): Eval[Ref[A]] = Eval.now(AllocRef(al.getAndIncrement, init)) } diff --git a/core/src/main/scala/org/bykn/bosatsu/rankn/Type.scala b/core/src/main/scala/org/bykn/bosatsu/rankn/Type.scala index 85c7a4da3..eb651747f 100644 --- a/core/src/main/scala/org/bykn/bosatsu/rankn/Type.scala +++ b/core/src/main/scala/org/bykn/bosatsu/rankn/Type.scala @@ -629,7 +629,7 @@ object Type { } private object FullResolved extends TypeParser[Type] { - lazy val parseRoot = { + lazy val parseRoot: P[Type] = { val tvar = Parser.lowerIdent.map { s => Type.TyVar(Type.Var.Bound(s)) } val name = ((PackageName.parser <* P.string("::")) ~ Identifier.consParser) .map { case (p, n) => Type.TyConst(Type.Const.Defined(p, TypeName(n))) } @@ -654,13 +654,13 @@ object Type { tvar.orElse(name).orElse(skolem).orElse(meta) } - def makeFn(in: NonEmptyList[Type], out: Type) = + def makeFn(in: NonEmptyList[Type], out: Type): Type = // this may be an invalid function, but typechecking verifies that. Type.Fun(in, out) def applyTypes(left: Type, args: NonEmptyList[Type]) = applyAll(left, args.toList) - def universal(vs: NonEmptyList[(String, Option[Kind])], on: Type) = + def universal(vs: NonEmptyList[(String, Option[Kind])], on: Type): Type = Type.forAll(vs.map { case (s, None) => (Type.Var.Bound(s), Kind.Type) case (s, Some(k)) => (Type.Var.Bound(s), k) diff --git a/core/src/test/scala/org/bykn/bosatsu/pattern/SeqPatternTest.scala b/core/src/test/scala/org/bykn/bosatsu/pattern/SeqPatternTest.scala index bb67c8df4..7b0e7a239 100644 --- a/core/src/test/scala/org/bykn/bosatsu/pattern/SeqPatternTest.scala +++ b/core/src/test/scala/org/bykn/bosatsu/pattern/SeqPatternTest.scala @@ -448,7 +448,7 @@ class BoolSeqPatternTest extends SeqPatternLaws[Set[Boolean], Boolean, List[Bool Some(loop(sp)) } - override def diffUBRegressions = + override def diffUBRegressions: List[(Pattern, Pattern, List[Boolean])] = List({ val p1 = Cat(Wildcard,Empty) val p2 = Cat(Lit(Set(true)),Cat(Wildcard,Cat(Lit(Set(true, false)),Cat(Lit(Set(true)),Cat(Wildcard, Empty))))) @@ -613,7 +613,8 @@ class SeqPatternTest extends SeqPatternLaws[Char, Char, String, Unit] { Pattern.Cat(Lit(c), r) } - override def diffUBRegressions = + + override def diffUBRegressions: List[(SeqPattern[Char], SeqPattern[Char], String)] = List({ val p1 = Cat(AnyElem,Cat(Wildcard,Empty)) val p2 = Cat(Wildcard,Cat(AnyElem,Cat(Lit('0'),Cat(Lit('1'),Cat(Wildcard, Empty)))))