Skip to content

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

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

Closed
wants to merge 12 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ final case class SbtCommunityProject(
private val baseCommand =
"clean; set logLevel in Global := Level.Error; set updateOptions in Global ~= (_.withLatestSnapshots(false)); "
++ s"""set dependencyOverrides in ThisBuild ++= ${dependencyOverrides.mkString("Seq(", ", ", ")")}; """
++ """set scalacOptions in Global += "-Ycheck-init";"""
++ s"++$compilerVersion!; "

override val testCommand = s"$baseCommand$sbtTestCommand"
Expand Down
5 changes: 3 additions & 2 deletions 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,9 +46,9 @@ 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,
checked = Set.empty,
path = Vector.empty,
thisClass = cls,
fieldsInited = mutable.Set.empty,
Expand Down
Loading