Skip to content

Commit

Permalink
Close #2120, Close #2184 - Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Jun 4, 2024
1 parent 0824f10 commit f858ea5
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 95 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ lazy val shaded = project
publishTo := None
)

val scala213Version = "2.13.12"
val scala213Version = "2.13.14"

val fullCrossScalaVersions = Def.setting {
Seq(
"2.11.12",
scalaVersion.value,
scala213Version,
"3.2.2"
"3.4.1"
)
}

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala-2/core/ScalaParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1319,9 +1319,7 @@ final class ScalaParser[Uni <: Universe](
}
}

@com.github.ghik.silencer.silent(".*Unused\\ import.*")
private[scalats] object ScalaParser {
import scala.language.higherKinds

case class Result[M[_], Tpe](
examined: ListSet[Tpe],
Expand Down
15 changes: 1 addition & 14 deletions core/src/main/scala-3/core/ScalaParser.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.github.scalats.core

import scala.util.control.NonFatal

import scala.collection.Factory

import scala.collection.immutable.ListSet

import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.{ Constants, Names, Denotations, Definitions }
import dotty.tools.dotc.core.{ Constants, Names, Denotations }
import dotty.tools.dotc.core.Symbols, Symbols.Symbol
import dotty.tools.dotc.core.Types, Types.{ Type, MethodType }
import dotty.tools.dotc.core.Flags
Expand All @@ -16,8 +14,6 @@ import dotty.tools.dotc.util.NoSourcePosition

import dotty.tools.dotc.ast.{ Trees, tpd }

import dotty.tools.dotc.ast.untpd.ImportSelector

import io.github.scalats.{ scala => ScalaModel }

final class ScalaParser(
Expand Down Expand Up @@ -282,9 +278,6 @@ final class ScalaParser(

private val skipCompanion = true // TODO: (low priority) Configurable

@inline private def isLiteralType(tpe: Type): Boolean =
isAnyValChild(tpe) || tpe <:< defn.StringClass.info

@annotation.tailrec
private def appliedOp(
op: Names.SimpleName,
Expand Down Expand Up @@ -324,9 +317,6 @@ final class ScalaParser(

}

private lazy val plainPrinter =
new dotty.tools.dotc.printing.PlainPrinter(ctx)

private lazy val printerCtx: Context = {
import dotty.tools.dotc.config._

Expand Down Expand Up @@ -455,9 +445,6 @@ final class ScalaParser(
private lazy val MapType: Type =
Symbols.requiredClass("scala.collection.immutable.Map").typeRef

private lazy val ProductType: Type =
Symbols.requiredClass("scala.Product").typeRef

private object WithTypeArgs {

def unapply(tree: Tree): Option[(Tree, List[Type])] = tree.tpe match {
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/scala-3/plugins/CompilerPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.scalats.plugins

import java.io.File

import dotty.tools.dotc.{ CompilationUnit, report }
import dotty.tools.dotc.report
import dotty.tools.dotc.core.Flags
import dotty.tools.dotc.core.Symbols.Symbol
import dotty.tools.dotc.core.Types.Type
Expand Down Expand Up @@ -40,7 +40,7 @@ end CompilerPlugin
private[plugins] object ScalaTSPhase:
val name = "scalats"

type Initer = Context => (Configuration, File, Boolean)
type Initer = Context => (Configuration, Boolean)

def initer(opts: List[String]): Initer = {
val cfgPrefix = "configuration="
Expand All @@ -54,7 +54,7 @@ private[plugins] object ScalaTSPhase:
outDir: File,
cfgPath: Option[String],
debug: Boolean
): (Configuration, File, Boolean) = options.headOption match {
): (Configuration, Boolean) = options.headOption match {
case Some(opt) => {
if (opt startsWith cfgPrefix) {
parse(options.tail, outDir, Some(opt stripPrefix cfgPrefix), debug)
Expand Down Expand Up @@ -110,7 +110,7 @@ private[plugins] object ScalaTSPhase:
}
}

(config, outDir, debug)
config -> debug
}
}

Expand Down Expand Up @@ -152,7 +152,7 @@ private class ScalaTSPhase(initer: ScalaTSPhase.Initer) extends PluginPhase {
ctx: Context
): Unit = {
val compiledFile: File = ctx.source.file.file
val (config, outDir, debug) = initer(ctx)
val (config, debug) = initer(ctx)

import config.compilationRuleSet

Expand All @@ -178,7 +178,7 @@ private class ScalaTSPhase(initer: ScalaTSPhase.Initer) extends PluginPhase {
)
}

handle(config, outDir, debug)
handle(config, debug)
} else if (debug) {
report.inform(
s"${phaseName}.debug: Skip excluded ${compiledFile.getAbsolutePath}"
Expand Down Expand Up @@ -206,7 +206,6 @@ private class ScalaTSPhase(initer: ScalaTSPhase.Initer) extends PluginPhase {

private def handle(
config: Configuration,
outDir: File,
debug: Boolean
)(using
ctx: Context
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala-3/silent.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.github.ghik.silencer

@ _root_.scala.annotation.nowarn
class silent(s: String = "") extends scala.annotation.StaticAnnotation
3 changes: 0 additions & 3 deletions core/src/test/scala-3/core/ScalaExtraParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ private[core] trait ScalaExtraParserSpec { self: ScalaParserSpec =>
val colorTpe = ColorType -> ColorTree

"declaration" in {
import scala.collection.immutable.ListSet
import io.github.scalats.{ scala => ScalaModel }

parseTypes(List(colorTpe)) must_=== List(color)
}

Expand Down
12 changes: 5 additions & 7 deletions core/src/test/scala-3/core/ScalaRuntimeFixtures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package io.github.scalats.core

import scala.collection.immutable.ListSet

import scala.util.control.NonFatal

import dotty.tools.dotc.core.{ Contexts, Symbols, Types, Flags }
import dotty.tools.dotc.core.{ Contexts, Symbols, Types }

import dotty.tools.dotc.ast.Trees
import dotty.tools.dotc.ast.tpd.Tree
Expand Down Expand Up @@ -181,8 +179,8 @@ object ScalaRuntimeFixtures {

val typecheck = { (input: String) =>
replCompiler.typeCheck(input)(using state) match {
case Right(valDef) =>
valDef.unforced match {
case Right((_, valDef)) =>
valDef.unforcedRhs match {
case Trees.Block(d :: _, _) =>
d.asInstanceOf[Tree]

Expand Down Expand Up @@ -369,8 +367,8 @@ case class Style(name: String, color: Color)
type RefinementFoo = Product with Serializable with Family
""")(using state) match {
case Right(valDef) =>
valDef.unforced match {
case Right((_, valDef)) =>
valDef.unforcedRhs match {
case Trees.Block(
testClass1Tree :: _ :: testClass1CompanionTree :: testClass1BTree :: _ :: _ :: testClass2Tree :: _ :: _ :: testClass3Tree :: _ :: _ :: testClass4Tree :: _ :: _ :: testClass5Tree :: _ :: _ :: testClass6Tree :: _ :: _ :: testClass7Tree :: _ :: _ :: anyValChildTree :: _ :: _ :: testClass8Tree :: _ :: _ :: testEnumerationTree :: _ :: testClass9Tree :: _ :: _ :: testClass10Tree :: _ :: _ :: _ :: testObject1Tree :: _ :: testObject2Tree :: _ /*Foo*/ :: familyTree :: familyMember1Tree :: _ :: _ :: _ :: familyMember2Tree :: _ :: familyMember3Tree :: _ :: Trees
.TypeDef(
Expand Down
41 changes: 28 additions & 13 deletions project/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,25 @@ object Compiler extends AutoPlugin {
if (scalaBinaryVersion.value == "3") {
Seq.empty
} else {
Seq("-target:jvm-1.8", "-Xlint", "-g:vars")
Seq("-Xlint", "-g:vars", "-language:higherKinds")
}
},
scalacOptions ++= {
val sv = scalaBinaryVersion.value

if (sv == "2.12") {
if (sv == "2.11") {
Seq(
"-target:jvm-1.8",
"-Xmax-classfile-name",
"128",
"-Yopt:_",
"-Ydead-code",
"-Yclosure-elim",
"-Yconst-opt"
)
} else if (sv == "2.12") {
Seq(
"-target:jvm-1.8",
"-Xmax-classfile-name",
"128",
"-Ywarn-numeric-widen",
Expand All @@ -45,28 +56,32 @@ object Compiler extends AutoPlugin {
"-Ywarn-unused-import",
"-Ywarn-macros:after"
)
} else if (sv == "2.11") {
Seq(
"-Xmax-classfile-name",
"128",
"-Yopt:_",
"-Ydead-code",
"-Yclosure-elim",
"-Yconst-opt"
)
} else if (sv == "2.13") {
Seq(
"-release",
"8",
"-explaintypes",
"-Werror",
"-Wnumeric-widen",
"-Wdead-code",
"-Wvalue-discard",
"-Wextra-implicit",
"-Wmacros:after",
"-Wunused"
"-Wunused",
"-Wconf:msg=.*JavaConverters.*:s",
)
} else {
Seq("-Wunused:all", "-language:implicitConversions")
Seq(
"-release",
"8",
"-Wunused:all",
"-language:implicitConversions",
"-Wconf:msg=.*is\\ not\\ declared\\ infix.*:s",
"-Wconf:msg=.*is\\ deprecated\\ for\\ wildcard\\ arguments\\ of\\ types.*:s",
"-Wconf:msg=.*with\\ as\\ a\\ type\\ operator.*:s",
"-Wconf:msg=.*is\\ no\\ longer\\ supported\\ for\\ vararg\\ splices.*:s",
"-Wconf:msg=.*JavaConverters.*:s"
)
}
},
Compile / console / scalacOptions ~= { _.filterNot(excludeScalacOpts) },
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1")

addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1")

Expand Down
39 changes: 0 additions & 39 deletions python/src/main/scala/PythonTypeMapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,43 +80,4 @@ final class PythonTypeMapper extends TypeMapper {

Some(tsType)
}

private def valueType(
vtpe: TypeRef,
typeNaming: TypeRef => String
): String = {
val tr = valueType(_: TypeRef, typeNaming)

vtpe match {
case TupleRef(args) =>
args.map(tr).mkString("[", ", ", "]")

case NullableType(inner) =>
s"Optional[${valueType(inner, typeNaming)}]"

case UnionType(possibilities) =>
possibilities.map(tr).mkString("typing.Union[", ", ", "]")

case custom @ (TaggedRef(_, _) | SingletonTypeRef(_, _)) =>
typeNaming(custom)

case custom @ CustomTypeRef(_, Nil) =>
typeNaming(custom)

case custom @ CustomTypeRef(_, args) => {
val n = typeNaming(custom)

s"""${n}${args.map(tr).mkString("[", ", ", "]")}"""
}

case ArrayRef(tpe) =>
s"list[${tr(tpe)}]"

case MapType(kt, vt) =>
s"dict[${tr(kt)}, ${tr(vt)}]"

case _ =>
typeNaming(vtpe)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version := "1.0-SNAPSHOT"

enablePlugins(ScalatsIdtltPlugin) // Required as disabled by default

scalaVersion := "2.13.12"
scalaVersion := "2.13.14"

crossScalaVersions := Seq("2.12.19", scalaVersion.value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version := "1.0-SNAPSHOT"

enablePlugins(ScalatsPythonPlugin) // Required as disabled by default

scalaVersion := "2.13.12"
scalaVersion := "2.13.14"

crossScalaVersions := Seq("2.12.19", scalaVersion.value)

Expand Down
2 changes: 1 addition & 1 deletion sbt-plugin/src/sbt-test/sbt-scala-ts/enumeratum/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name := "sbt-plugin-test-enumeratum"

version := "1.0-SNAPSHOT"

crossScalaVersions := Seq("2.12.19", "2.13.12")
crossScalaVersions := Seq("2.12.19", "2.13.14")

enablePlugins(ScalatsGeneratorPlugin) // Required as disabled by default

Expand Down
2 changes: 1 addition & 1 deletion sbt-plugin/src/sbt-test/sbt-scala-ts/multi/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inThisBuild(
Seq(
organization := "io.github.scala-ts",
version := "1.0-SNAPSHOT",
scalaVersion := "2.13.12"
scalaVersion := "2.13.14"
)
)

Expand Down
2 changes: 1 addition & 1 deletion sbt-plugin/src/sbt-test/sbt-scala-ts/simple/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name := "sbt-plugin-test-simple"

version := "1.0-SNAPSHOT"

crossScalaVersions := Seq("2.12.19", "2.13.12", "3.2.2")
crossScalaVersions := Seq("2.12.19", "2.13.14", "3.4.1")

enablePlugins(ScalatsGeneratorPlugin) // Required as disabled by default

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ version := "1.0-SNAPSHOT"

resolvers ++= Resolver.sonatypeOssRepos("snapshots")

scalaVersion := "2.13.12"
scalaVersion := "2.13.14"

crossScalaVersions := Seq(scalaVersion.value, "3.2.2")
crossScalaVersions := Seq(scalaVersion.value, "3.4.1")

enablePlugins(ScalatsGeneratorPlugin) // Required as disabled by default

Expand Down

0 comments on commit f858ea5

Please sign in to comment.