Skip to content

Commit c5a2f86

Browse files
authored
Merge branch 'master' into scaladoc/scala3-docs-in-jar
2 parents cd6705c + e08fd59 commit c5a2f86

File tree

252 files changed

+4091
-1203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+4091
-1203
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@
187187
[submodule "community-build/community-projects/protoquill"]
188188
path = community-build/community-projects/protoquill
189189
url = https://github.com/dotty-staging/protoquill.git
190+
[submodule "community-build/community-projects/onnx-scala"]
191+
path = community-build/community-projects/onnx-scala
192+
url = https://github.com/dotty-staging/onnx-scala.git
193+
[submodule "community-build/community-projects/cask"]
194+
path = community-build/community-projects/cask
195+
url = https://github.com/dotty-staging/cask.git
Submodule cask added at 93c27ab
Submodule onnx-scala added at 64cb918
Submodule upickle updated 101 files

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ final case class SbtCommunityProject(
129129

130130
object SbtCommunityProject:
131131
def scalacOptions = List(
132-
"-Ycheck:macros",
133-
"-Ycheck-init",
132+
"-Xcheck-macros",
133+
"-Ysafe-init",
134134
)
135135

136136
object projects:
@@ -188,6 +188,18 @@ object projects:
188188
dependencies = List(geny, utest)
189189
)
190190

191+
lazy val upickleImplicits = MillCommunityProject(
192+
project = "upickle",
193+
baseCommand = s"implicits.jvm[$compilerVersion]",
194+
dependencies = List(upickleCore, ujson)
195+
)
196+
197+
lazy val upack = MillCommunityProject(
198+
project = "upickle",
199+
baseCommand = s"upack.jvm[$compilerVersion]",
200+
dependencies = List(ujson, upickleCore)
201+
)
202+
191203
lazy val geny = MillCommunityProject(
192204
project = "geny",
193205
baseCommand = s"geny.jvm[$compilerVersion]",
@@ -214,6 +226,12 @@ object projects:
214226
dependencies = List(geny, utest, ujson, upickleCore)
215227
)
216228

229+
lazy val cask = MillCommunityProject(
230+
project = "cask",
231+
baseCommand = s"cask[$compilerVersion]",
232+
dependencies = List(utest, geny, sourcecode, pprint, upickle, upickleImplicits, upack, requests)
233+
)
234+
217235
lazy val scas = MillCommunityProject(
218236
project = "scas",
219237
baseCommand = "scas.application"
@@ -319,7 +337,7 @@ object projects:
319337
project = "shapeless",
320338
sbtTestCommand = "test",
321339
sbtDocCommand = forceDoc("typeable", "deriving", "data"),
322-
scalacOptions = Nil // disable -Ycheck-init, due to -Xfatal-warnings
340+
scalacOptions = Nil // disable -Ysafe-init, due to -Xfatal-warnings
323341
)
324342

325343
lazy val xmlInterpolator = SbtCommunityProject(
@@ -458,7 +476,7 @@ object projects:
458476
project = "verify",
459477
sbtTestCommand = "verifyJVM/test",
460478
sbtDocCommand = "verifyJVM/doc",
461-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ycheck:macros") // TODO enable -Ycheck:macros
479+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Xcheck-macros") // TODO enable -Xcheck-macros
462480
)
463481

464482
lazy val discipline = SbtCommunityProject(
@@ -480,7 +498,7 @@ object projects:
480498
sbtTestCommand = "test",
481499
sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal",
482500
dependencies = List(discipline),
483-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ycheck-init")
501+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init")
484502
)
485503

486504
lazy val simulacrumScalafixAnnotations = SbtCommunityProject(
@@ -494,7 +512,7 @@ object projects:
494512
sbtTestCommand = "set scalaJSStage in Global := FastOptStage;buildJVM;validateAllJS",
495513
sbtPublishCommand = "catsJVM/publishLocal;catsJS/publishLocal",
496514
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
497-
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ycheck-init") // disable -Ycheck-init, due to -Xfatal-warning
515+
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") // disable -Ysafe-init, due to -Xfatal-warning
498516

499517
)
500518

@@ -611,7 +629,14 @@ object projects:
611629
sbtTestCommand = "test",
612630
sbtPublishCommand = "publishLocal",
613631
dependencies = List(), // TODO add scalatest and pprint (see protoquill/build.sbt)
614-
scalacOptions = List("-language:implicitConversions"), // disabled -Ycheck-init, due to bug in macro
632+
scalacOptions = List("-language:implicitConversions"), // disabled -Ysafe-init, due to bug in macro
633+
)
634+
635+
lazy val onnxScala = SbtCommunityProject(
636+
project = "onnx-scala",
637+
sbtTestCommand = "test",
638+
sbtPublishCommand = "publishLocal",
639+
dependencies = List(scalatest)
615640
)
616641

617642
end projects
@@ -624,10 +649,13 @@ def allProjects = List(
624649
projects.ujson,
625650
projects.upickle,
626651
projects.upickleCore,
652+
projects.upickleImplicits,
653+
projects.upack,
627654
projects.geny,
628655
projects.fansi,
629656
projects.pprint,
630657
projects.requests,
658+
projects.cask,
631659
projects.scas,
632660
projects.intent,
633661
projects.algebra,
@@ -680,6 +708,7 @@ def allProjects = List(
680708
projects.perspective,
681709
projects.akka,
682710
projects.protoquill,
711+
projects.onnxScala,
683712
)
684713

685714
lazy val projectMap = allProjects.groupBy(_.project)

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class CommunityBuildTestA extends CommunityBuildTest:
109109
@Test def utest = projects.utest.run()
110110
@Test def zio = projects.zio.run()
111111
@Test def protoquill = projects.protoquill.run()
112+
@Test def onnxScala = projects.onnxScala.run()
112113

113114
// 'scala-stm' and 'Sciss/Lucre':
114115
// @Test def scissEqual = projects.scissEqual .run()

compiler/src/dotty/tools/backend/jvm/BCodeAsmCommon.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final class BCodeAsmCommon[I <: DottyBackendInterface](val interface: I) {
2626
// always top-level. However, SI-8900 shows an example where the weak name-based implementation
2727
// of isDelambdafyFunction failed (for a function declared in a package named "lambda").
2828
classSym.isAnonymousClass || {
29-
val originalOwnerLexicallyEnclosingClass = classSym.originalOwner.originalLexicallyEnclosingClass
30-
originalOwnerLexicallyEnclosingClass != NoSymbol && !originalOwnerLexicallyEnclosingClass.isClass
29+
val originalOwner = classSym.originalOwner
30+
originalOwner != NoSymbol && !originalOwner.isClass
3131
}
3232
}
3333

@@ -59,9 +59,9 @@ final class BCodeAsmCommon[I <: DottyBackendInterface](val interface: I) {
5959
def enclosingMethod(sym: Symbol): Option[Symbol] = {
6060
if (sym.isClass || sym == NoSymbol) None
6161
else if (sym.is(Method)) Some(sym)
62-
else enclosingMethod(sym.originalOwner.originalLexicallyEnclosingClass)
62+
else enclosingMethod(sym.originalOwner)
6363
}
64-
enclosingMethod(classSym.originalOwner.originalLexicallyEnclosingClass)
64+
enclosingMethod(classSym.originalOwner)
6565
}
6666

6767
/**

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ trait BCodeSkelBuilder extends BCodeHelpers {
221221
addClassFields()
222222

223223
innerClassBufferASM ++= classBTypeFromSymbol(claszSymbol).info.memberClasses
224+
225+
val companion = claszSymbol.companionClass
226+
if companion.isTopLevelModuleClass then
227+
innerClassBufferASM ++= classBTypeFromSymbol(companion).info.memberClasses
228+
224229
gen(cd.rhs)
225230
addInnerClassesASM(cnode, innerClassBufferASM.toList)
226231

compiler/src/dotty/tools/dotc/ast/MainProxies.scala

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ object MainProxies {
3939
mainMethods(stats).flatMap(mainProxy)
4040
}
4141

42-
private def checkNoShadowing(mainFun: Symbol)(using Context) =
43-
val cls = ctx.typer.findRef(mainFun.name.toTypeName, WildcardType, EmptyFlags, EmptyFlags, mainFun).typeSymbol
44-
if cls.exists && cls.owner != ctx.owner then
45-
report.warning(
46-
i"""The class `${ctx.printer.fullNameString(mainFun)}` generated from `@main` will shadow the existing ${cls.showLocated}.
47-
|The existing definition might no longer be found on recompile.""", mainFun)
48-
4942
import untpd._
5043
def mainProxy(mainFun: Symbol)(using Context): List[TypeDef] = {
5144
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span
@@ -93,7 +86,6 @@ object MainProxies {
9386
case _ =>
9487
report.error(s"@main can only annotate a method", pos)
9588
}
96-
checkNoShadowing(mainFun)
9789
val errVar = Ident(nme.error)
9890
val handler = CaseDef(
9991
Typed(errVar, TypeTree(defn.CLP_ParseError.typeRef)),
@@ -106,7 +98,7 @@ object MainProxies {
10698
.withFlags(JavaStatic)
10799
val mainTempl = Template(emptyConstructor, Nil, Nil, EmptyValDef, mainMeth :: Nil)
108100
val mainCls = TypeDef(mainFun.name.toTypeName, mainTempl)
109-
.withFlags(Final)
101+
.withFlags(Final | Invisible)
110102
if (!ctx.reporter.hasErrors) result = mainCls.withSpan(mainAnnotSpan.toSynthetic) :: Nil
111103
}
112104
result

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
946946

947947
/** The current tree applied to given type argument list: `tree[targs(0), ..., targs(targs.length - 1)]` */
948948
def appliedToTypeTrees(targs: List[Tree])(using Context): Tree =
949-
if (targs.isEmpty) tree else TypeApply(tree, targs)
949+
if targs.isEmpty then tree else TypeApply(tree, targs)
950950

951951
/** Apply to `()` unless tree's widened type is parameterless */
952952
def ensureApplied(using Context): Tree =

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
103103
val semanticdbTarget: Setting[String] = PathSetting("-semanticdb-target", "Specify an alternative output directory for SemanticDB files.", "")
104104

105105
val deprecation: Setting[Boolean] = BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.", aliases = List("--deprecation"))
106-
val explainTypes: Setting[Boolean] = BooleanSetting("-explain-types", "Explain type errors in more detail.", aliases = List("--explain-types"))
106+
val explainTypes: Setting[Boolean] = BooleanSetting("-explain-types", "Explain type errors in more detail (deprecated, use -explain instead).", aliases = List("--explain-types"))
107+
// this setting is necessary for cross compilation, since it is mentioned in sbt-tpolecat, for instance
108+
// it is otherwise subsumed by -explain, and should be dropped as soon as we can.
107109
val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.", aliases = List("--explain"))
108110
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
109111
val release: Setting[String] = ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", supportedReleaseVersions, "", aliases = List("--release"))
@@ -150,6 +152,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
150152
val XimportSuggestionTimeout: Setting[Int] = IntSetting("-Ximport-suggestion-timeout", "Timeout (in ms) for searching for import suggestions when errors are reported.", 8000)
151153
val Xsemanticdb: Setting[Boolean] = BooleanSetting("-Xsemanticdb", "Store information in SemanticDB.", aliases = List("-Ysemanticdb"))
152154
val Xtarget: Setting[String] = ChoiceSetting("-Xtarget", "target", "Emit bytecode for the specified version of the Java platform. This might produce bytecode that will break at runtime. When on JDK 9+, consider -release as a safer alternative.", supportedTargetVersions, "", aliases = List("--Xtarget"))
155+
val XcheckMacros: Setting[Boolean] = BooleanSetting("-Xcheck-macros", "Check some invariants of macro generated code while expanding macros", aliases = List("--Xcheck-macros"))
153156

154157
val XmixinForceForwarders = ChoiceSetting(
155158
name = "-Xmixin-force-forwarders",
@@ -225,7 +228,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
225228
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
226229
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
227230
val YerasedTerms: Setting[Boolean] = BooleanSetting("-Yerased-terms", "Allows the use of erased terms.")
228-
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ycheck-init", "Check initialization of objects")
231+
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
229232
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
230233

231234
/** Area-specific debug output */

compiler/src/dotty/tools/dotc/core/Constraint.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,7 @@ abstract class Constraint extends Showable {
168168

169169
/** Check that constraint only refers to TypeParamRefs bound by itself */
170170
def checkClosed()(using Context): Unit
171+
172+
/** A string describing the constraint's contents without a header or trailer */
173+
def contentsToString(using Context): String
171174
}

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -452,27 +452,11 @@ class Definitions {
452452
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyType))
453453
def NothingType: TypeRef = NothingClass.typeRef
454454
@tu lazy val NullClass: ClassSymbol = {
455-
val parent = if (ctx.explicitNulls) AnyType else ObjectType
455+
val parent = if ctx.explicitNulls then AnyType else ObjectType
456456
enterCompleteClassSymbol(ScalaPackageClass, tpnme.Null, AbstractFinal, parent :: Nil)
457457
}
458458
def NullType: TypeRef = NullClass.typeRef
459459

460-
/** An alias for null values that originate in Java code.
461-
* This type gets special treatment in the Typer. Specifically, `UncheckedNull` can be selected through:
462-
* e.g.
463-
* ```
464-
* // x: String|Null
465-
* x.length // error: `Null` has no `length` field
466-
* // x2: String|UncheckedNull
467-
* x2.length // allowed by the Typer, but unsound (might throw NPE)
468-
* ```
469-
*/
470-
lazy val UncheckedNullAlias: TypeSymbol = {
471-
assert(ctx.explicitNulls)
472-
enterAliasType(tpnme.UncheckedNull, NullType)
473-
}
474-
def UncheckedNullAliasType: TypeRef = UncheckedNullAlias.typeRef
475-
476460
@tu lazy val ImplicitScrutineeTypeSym =
477461
newPermanentSymbol(ScalaPackageClass, tpnme.IMPLICITkw, EmptyFlags, TypeBounds.empty).entered
478462
def ImplicitScrutineeTypeRef: TypeRef = ImplicitScrutineeTypeSym.typeRef
@@ -633,7 +617,7 @@ class Definitions {
633617
@tu lazy val StringModule: Symbol = StringClass.linkedClass
634618
@tu lazy val String_+ : TermSymbol = enterMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final)
635619
@tu lazy val String_valueOf_Object: Symbol = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
636-
case List(pt) => pt.isAny || pt.isAnyRef
620+
case List(pt) => pt.isAny || pt.stripNull.isAnyRef
637621
case _ => false
638622
}).symbol
639623

@@ -645,15 +629,13 @@ class Definitions {
645629
@tu lazy val ClassCastExceptionClass: ClassSymbol = requiredClass("java.lang.ClassCastException")
646630
@tu lazy val ClassCastExceptionClass_stringConstructor: TermSymbol = ClassCastExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
647631
case List(pt) =>
648-
val pt1 = if (ctx.explicitNulls) pt.stripNull() else pt
649-
pt1.isRef(StringClass)
632+
pt.stripNull.isRef(StringClass)
650633
case _ => false
651634
}).symbol.asTerm
652635
@tu lazy val ArithmeticExceptionClass: ClassSymbol = requiredClass("java.lang.ArithmeticException")
653636
@tu lazy val ArithmeticExceptionClass_stringConstructor: TermSymbol = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
654637
case List(pt) =>
655-
val pt1 = if (ctx.explicitNulls) pt.stripNull() else pt
656-
pt1.isRef(StringClass)
638+
pt.stripNull.isRef(StringClass)
657639
case _ => false
658640
}).symbol.asTerm
659641

@@ -1236,7 +1218,8 @@ class Definitions {
12361218
idx == name.length || name(idx).isDigit && digitsOnlyAfter(name, idx + 1)
12371219

12381220
def isBottomClass(cls: Symbol): Boolean =
1239-
if (ctx.explicitNulls && !ctx.phase.erasedTypes) cls == NothingClass
1221+
if ctx.mode.is(Mode.SafeNulls) && !ctx.phase.erasedTypes
1222+
then cls == NothingClass
12401223
else isBottomClassAfterErasure(cls)
12411224

12421225
def isBottomClassAfterErasure(cls: Symbol): Boolean = cls == NothingClass || cls == NullClass
@@ -1700,8 +1683,8 @@ class Definitions {
17001683
// ----- Initialization ---------------------------------------------------
17011684

17021685
/** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
1703-
@tu lazy val syntheticScalaClasses: List[TypeSymbol] = {
1704-
val synth = List(
1686+
@tu lazy val syntheticScalaClasses: List[TypeSymbol] =
1687+
List(
17051688
AnyClass,
17061689
MatchableClass,
17071690
AnyRefAlias,
@@ -1715,9 +1698,6 @@ class Definitions {
17151698
NothingClass,
17161699
SingletonClass)
17171700

1718-
if (ctx.explicitNulls) synth :+ UncheckedNullAlias else synth
1719-
}
1720-
17211701
@tu lazy val syntheticCoreClasses: List[Symbol] = syntheticScalaClasses ++ List(
17221702
EmptyPackageVal,
17231703
OpsPackageClass)

0 commit comments

Comments
 (0)