Skip to content

Enable -Ycheck-init on community projects and CI #11385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions community-build/src/scala/dotty/communitybuild/projects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ final case class SbtCommunityProject(
extraSbtArgs: List[String] = Nil,
dependencies: List[CommunityProject] = Nil,
sbtPublishCommand: String = null,
sbtDocCommand: String = null
sbtDocCommand: String = null,
scalacOptions: List[String] = List("-Ycheck-init")
) extends CommunityProject:
override val binaryName: String = "sbt"

private def scalacOptionsString: String =
scalacOptions.map("\"" + _ + "\"").mkString("List(", ",", ")")

private val baseCommand =
"clean; set logLevel in Global := Level.Error; set updateOptions in Global ~= (_.withLatestSnapshots(false)); "
++ (if scalacOptions.isEmpty then "" else s"""set scalacOptions in Global ++= $scalacOptionsString;""")
++ s"++$compilerVersion!; "

override val testCommand =
Expand Down Expand Up @@ -307,7 +312,8 @@ object projects:
lazy val shapeless = SbtCommunityProject(
project = "shapeless",
sbtTestCommand = "test",
sbtDocCommand = forceDoc("typeable", "deriving", "data")
sbtDocCommand = forceDoc("typeable", "deriving", "data"),
scalacOptions = Nil // disable -Ycheck-init, due to -Xfatal-warnings
)

lazy val xmlInterpolator = SbtCommunityProject(
Expand Down Expand Up @@ -466,7 +472,8 @@ object projects:
project = "discipline-specs2",
sbtTestCommand = "test",
sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal",
dependencies = List(discipline)
dependencies = List(discipline),
scalacOptions = Nil // disable -Ycheck-init
)

lazy val simulacrumScalafixAnnotations = SbtCommunityProject(
Expand All @@ -479,7 +486,8 @@ object projects:
project = "cats",
sbtTestCommand = "set scalaJSStage in Global := FastOptStage;buildJVM;validateAllJS",
sbtPublishCommand = "catsJVM/publishLocal;catsJS/publishLocal",
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations)
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
scalacOptions = Nil // disable -Ycheck-init, due to -Xfatal-warning
)

lazy val catsMtl = SbtCommunityProject(
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/init/Checker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ast.tpd
import dotty.tools.dotc.core._
import Contexts._
import Types._
import Symbols._

import dotty.tools.dotc.transform._
import MegaPhase._
Expand Down Expand Up @@ -45,7 +46,7 @@ class Checker extends MiniPhase {
}

// A concrete class may not be instantiated if the self type is not satisfied
if (instantiable) {
if (instantiable && cls.enclosingPackageClass != defn.StdLibPatchesPackage.moduleClass) {
implicit val state: Checking.State = Checking.State(
visited = Set.empty,
path = Vector.empty,
Expand Down
Loading