Skip to content

Commit

Permalink
Merge pull request #11385 from dotty-staging/safe-object-init3
Browse files Browse the repository at this point in the history
Enable -Ycheck-init on community projects and CI
  • Loading branch information
liufengyun committed Feb 25, 2021
2 parents 0b697d5 + db19f60 commit 79ba06c
Show file tree
Hide file tree
Showing 28 changed files with 600 additions and 423 deletions.
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

0 comments on commit 79ba06c

Please sign in to comment.