Skip to content

Add Ycheck to stdlib-bootstrapped #18002

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 1 commit into from
Jun 23, 2023
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
11 changes: 8 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,9 @@ class Definitions {
denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted
patch2(denot, patchCls)

if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then
if ctx.settings.Yscala2Stdlib.value then
()
else if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then
patchWith(ScalaPredefModuleClassPatch)
else if denot.name == tpnme.language.moduleClassName && denot.symbol == LanguageModuleClass then
patchWith(LanguageModuleClassPatch)
Expand Down Expand Up @@ -1724,8 +1726,9 @@ class Definitions {
isFunctionType(tp) || isRefinedFunctionType(tp)

private def withSpecMethods(cls: ClassSymbol, bases: List[Name], paramTypes: Set[TypeRef]) =
for base <- bases; tp <- paramTypes do
cls.enter(newSymbol(cls, base.specializedName(List(tp)), Method, ExprType(tp)))
if !ctx.settings.Yscala2Stdlib.value then
for base <- bases; tp <- paramTypes do
cls.enter(newSymbol(cls, base.specializedName(List(tp)), Method, ExprType(tp)))
cls

@tu lazy val Tuple1: ClassSymbol = withSpecMethods(requiredClass("scala.Tuple1"), List(nme._1), Tuple1SpecializedParamTypes)
Expand Down Expand Up @@ -1766,6 +1769,7 @@ class Definitions {
case List(x, y) => Tuple2SpecializedParamClasses().contains(x.classSymbol) && Tuple2SpecializedParamClasses().contains(y.classSymbol)
case _ => false
&& base.owner.denot.info.member(base.name.specializedName(args)).exists // when dotc compiles the stdlib there are no specialised classes
&& !ctx.settings.Yscala2Stdlib.value // We do not add the specilized TupleN methods/classes when compiling the stdlib

def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(using Context): Boolean =
paramTypes.length <= 2
Expand All @@ -1787,6 +1791,7 @@ class Definitions {
case _ =>
false
})
&& !ctx.settings.Yscala2Stdlib.value // We do not add the specilized FunctionN methods/classes when compiling the stdlib

@tu lazy val Function0SpecializedApplyNames: collection.Set[TermName] =
for r <- Function0SpecializedReturnTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
override def description: String = SpecializeApplyMethods.description

override def isEnabled(using Context): Boolean =
!ctx.settings.scalajs.value
!ctx.settings.scalajs.value && !ctx.settings.Yscala2Stdlib.value

private def specApplySymbol(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = {
val name = nme.apply.specializedFunction(ret, args)
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
&& !cls.isAllOf(PrivateLocal)
&& effectiveOwner.is(Trait)
&& !effectiveOwner.derivesFrom(defn.ObjectClass)
&& !ctx.settings.Yscala2Stdlib.value // FIXME?: class PermutationsItr cannot be defined in universal trait SeqOps
then
report.error(em"$cls cannot be defined in universal $effectiveOwner", cdef.srcPos)

Expand Down
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ object Build {
},
Compile / doc / scalacOptions += "-Ydocument-synthetic-types",
scalacOptions += "-Yscala2-stdlib",
scalacOptions += "-Ycheck:all",
scalacOptions -= "-Xfatal-warnings",
ivyConfigurations += SourceDeps.hide,
transitiveClassifiers := Seq("sources"),
Expand Down