Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin committed Oct 27, 2022
2 parents d6b109f + e86724e commit 9a12064
Show file tree
Hide file tree
Showing 78 changed files with 629 additions and 142 deletions.
8 changes: 8 additions & 0 deletions .mailmap
Expand Up @@ -24,16 +24,19 @@ Christopher Vogt <vogt@epfl.ch> <github.com.nsp@cvogt.org>
Damien Obristi <damien.obrist@gmail.com>
Daniel C. Sobral <dcsobral@gmail.com>
Daniel C. Sobral <dcsobral@gmail.com> <dcs@dcs-132-CK-NF79.(none)>
Daniel Esik <e.danicheg@yandex.ru>
Daniel Lorch <lorch@epfl.ch>
Darcy Shen <da@tubi.tv>
Diego E. Alonso Blas <diesalbla@gmail.com>
Diego E. Alonso Blas <diego.e.a@47deg.com>
Eric Huang <ericdx.hung@gmail.com>
Erik Stenman <stenman@epfl.ch>
Eugene Burmako <xeno.by@gmail.com>
Eugene Burmako <xeno.by@gmail.com> <burmako@epfl.ch>
Eugene Vigdorchik <eugenevigdorchik@epfl.ch> <eugene.vigdorchik@gmail.com>
François Garillot <francois@garillot.net>
Geoff Reedy <geoff@programmer-monk.net> <gereedy@sandia.gov>
Gilad Hoch <giladhoch@gmail.com>
Harrison Houghton <hora.rhino@gmail.com> <hhoughton@learningobjects.com>
Ilya Sergei <ilyas@epfl.ch>
Ingo Maier <ingo.maier@epfl.ch>
Expand All @@ -45,6 +48,8 @@ Josh Suereth <joshua.suereth@gmail.com>
Josh Suereth <joshua.suereth@gmail.com> <Joshua.Suereth@gmail.com>
Julien Eberle <jeberle@epfl.ch>
Kenji Yoshida <6b656e6a69@gmail.com>
Liang Yan <35164941+liang3zy22@users.noreply.github.com>
Liang Yan <ckgppl_yan@sina.cn>
Luc Bourlier <luc.bourlier@typesafe.com>
Luc Bourlier <luc.bourlier@typesafe.com> <skyluc@epfl.ch>
Luc Bourlier <skyluc@epfl.ch>
Expand Down Expand Up @@ -90,3 +95,6 @@ Vincent Cremet <cremet@epfl.ch>
Vladimir Nikolaev <vladimir.nikolaev9@gmail.com>
Vojin Jovanovic <vojin.jovanovic@epfl.ch>
Vojin Jovanovic <vojin.jovanovic@epfl.ch> <gvojin@gmail.com>
Zhang Zhipeng <pc175@uow.edu.au>
jxnu-liguobin <dreamylost@outlook.com>
philwalk <philwalk9@gmail.com>
29 changes: 17 additions & 12 deletions .scala-steward.conf
Expand Up @@ -2,17 +2,22 @@
# either. hopefully this is a reasonable compromise value?
pullRequests.frequency = "14 days"

# only used internally, and they aren't ours (we aren't dogfooding
# them), and updates are unlikely to benefit us, so there's really no
# need to keep them current
updates.ignore = [ { groupId = "com.fasterxml.jackson.core"} ]
updates.ignore = [ { groupId = "org.slf4j"} ]
updates.ignore = [ { groupId = "org.eclipse.jgit"} ]
updates.ignore = [ { groupId = "org.openjdk.jol"} ]
updates.ignore = [

# Ant support is deprecated, so leave the version where it is
updates.ignore = [ { groupId = "org.apache.ant"} ]
# only used internally, and they aren't ours (we aren't dogfooding
# them), and updates are unlikely to benefit us, so there's really no
# need to keep them current
{ groupId = "com.fasterxml.jackson.core" },
{ groupId = "com.fasterxml.jackson.dataformat" },
{ groupId = "org.slf4j" },
{ groupId = "org.eclipse.jgit" },
{ groupId = "org.openjdk.jol" },

# OSGi stuff is fragile and we suspect it is little-used,
# so let's prefer stability
updates.ignore = [ { groupId = "biz.aQute.bnd"} ]
# Ant support is deprecated, so leave the version where it is
{ groupId = "org.apache.ant" },

# OSGi stuff is fragile and we suspect it is little-used,
# so let's prefer stability
{ groupId = "biz.aQute.bnd" }

]
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -187,7 +187,7 @@ Once you've started an `sbt` session you can run one of the core commands:
- Note that the `-bin` string marks the version binary compatible. Using it in
sbt will cause the `scalaBinaryVersion` to be `2.13`. If the version is not
binary compatible, we recommend using `-pre`, e.g., `2.14.0-pre-abcd123-SNAPSHOT`.
- Optionally `set publishArtifact in (Compile, packageDoc) in ThisBuild := false`
- Optionally `set ThisBuild / Compile / packageDoc / publishArtifact := false`
to skip generating / publishing API docs (speeds up the process).

If a command results in an error message like `a module is not authorized to depend on
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -73,7 +73,7 @@ lazy val publishSettings : Seq[Setting[_]] = Seq(
// should not be set directly. It is the same as the Maven version and derived automatically from `baseVersion` and
// `baseVersionSuffix`.
globalVersionSettings
Global / baseVersion := "2.13.9"
Global / baseVersion := "2.13.11"
Global / baseVersionSuffix := "SNAPSHOT"
ThisBuild / organization := "org.scala-lang"
ThisBuild / homepage := Some(url("https://www.scala-lang.org"))
Expand Down
15 changes: 1 addition & 14 deletions project/MimaFilters.scala
Expand Up @@ -13,7 +13,7 @@ object MimaFilters extends AutoPlugin {
import autoImport._

override val globalSettings = Seq(
mimaReferenceVersion := Some("2.13.8"),
mimaReferenceVersion := Some("2.13.10"),
)

val mimaFilters: Seq[ProblemFilter] = Seq[ProblemFilter](
Expand All @@ -31,19 +31,6 @@ object MimaFilters extends AutoPlugin {
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.Predef#ArrayCharSequence.isEmpty"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.ArrayCharSequence.isEmpty"),

// scala/scala#9819
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.mutable.PriorityQueue#ResizableArrayAccess.p_ensureAdditionalSize"), // private[PriorityQueue]
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.PStatics"), // private[scala]
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.PStatics$"), // private[scala]

// internal to wrappers
ProblemFilters.exclude[NewMixinForwarderProblem]("scala.collection.convert.JavaCollectionWrappers#JMapWrapperLike.getOrElseUpdate"),
ProblemFilters.exclude[NewMixinForwarderProblem]("scala.collection.convert.JavaCollectionWrappers#JMapWrapperLike.updateWith"),

// removing case classing from wrappers means synthetic methods and parent types and companions are missing
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.convert.JavaCollectionWrappers#*"),
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.convert.JavaCollectionWrappers$*"),
ProblemFilters.exclude[MissingClassProblem]("scala.collection.convert.JavaCollectionWrappers$*"),
)

override val buildSettings = Seq(
Expand Down
2 changes: 1 addition & 1 deletion project/ScaladocSettings.scala
Expand Up @@ -7,7 +7,7 @@ object ScaladocSettings {

// when this changes, the integrity check in HtmlFactory.scala also needs updating
val webjarResources = Seq(
"org.webjars" % "jquery" % "3.6.0"
"org.webjars" % "jquery" % "3.6.1"
)

def extractResourcesFromWebjar = Def.task {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=1.7.1
sbt.version=1.7.2
2 changes: 1 addition & 1 deletion project/plugins.sbt
Expand Up @@ -17,7 +17,7 @@ buildInfoKeys := Seq[BuildInfoKey](buildClasspath)

buildInfoPackage := "scalabuild"

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")

libraryDependencies ++= Seq(
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.11.9.201909030838-r",
Expand Down
2 changes: 1 addition & 1 deletion spec/03-types.md
Expand Up @@ -1025,7 +1025,7 @@ A value member of a volatile type cannot appear in a [path](#paths).
A type is _volatile_ if it falls into one of four categories:

A compound type `´T_1´ with … with ´T_n´ {´R\,´}`
is volatile if one of the following two conditions hold.
is volatile if one of the following three conditions hold.

1. One of ´T_2 , \ldots , T_n´ is a type parameter or abstract type, or
1. ´T_1´ is an abstract type and either the refinement ´R´
Expand Down
2 changes: 1 addition & 1 deletion spec/06-expressions.md
Expand Up @@ -599,7 +599,7 @@ Evaluation of the block entails evaluation of its
statement sequence, followed by an evaluation of the final expression
´e´, which defines the result of the block.

A block expression `{´c_1´; ´\ldots´; ´c_n´; ´}` where ´s_1 , \ldots , s_n´ are
A block expression `{´c_1´; ´\ldots´; ´c_n´}` where ´s_1 , \ldots , s_n´ are
case clauses forms a [pattern matching anonymous function](08-pattern-matching.html#pattern-matching-anonymous-functions).

###### Example
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/reflect/reify/package.scala
Expand Up @@ -72,7 +72,7 @@ package object reify {
if (tpe.isSpliceable) {
val classTagInScope = typer0.resolveClassTag(enclosingMacroPosition, tpe, allowMaterialization = false)
if (!classTagInScope.isEmpty) return Select(classTagInScope, nme.runtimeClass)
if (concrete) throw ReificationException(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
if (concrete) throw ReificationException(enclosingMacroPosition, s"type $tpe is an unresolved spliceable type")
}

tpe.dealiasWiden match {
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/CompilerCommand.scala
Expand Up @@ -126,11 +126,11 @@ class CompilerCommand(arguments: List[String], val settings: Settings) {
def expandArg(arg: String): List[String] = {
import java.nio.file.{Files, Paths}
import scala.jdk.CollectionConverters._
def stripComment(s: String) = s.takeWhile(_ != '#')
val file = Paths.get(arg stripPrefix "@")
def stripComment(s: String) = s.takeWhile(_ != '#').trim() // arg can be "" but not " "
val file = Paths.get(arg.stripPrefix("@"))
if (!Files.exists(file))
throw new java.io.FileNotFoundException(s"argument file $file could not be found")
settings.splitParams(Files.readAllLines(file).asScala.map(stripComment).mkString(" "))
Files.readAllLines(file).asScala.filter(!_.startsWith("#")).map(stripComment).toList
}

// override this if you don't want arguments processed here
Expand Down
14 changes: 5 additions & 9 deletions src/compiler/scala/tools/nsc/Global.scala
Expand Up @@ -1491,23 +1491,19 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
}
}

/** Compile list of source files,
* unless there is a problem already,
* such as a plugin was passed a bad option.
/** Compile a list of source files, unless there is a problem already, e.g., a plugin was passed a bad option.
*/
def compileSources(sources: List[SourceFile]): Unit = if (!reporter.hasErrors) {
printArgs(sources)

def checkDeprecations() = {
warnDeprecatedAndConflictingSettings()
reporting.summarizeErrors()
}

val units = sources map scripted map (file => new CompilationUnit(file, warningFreshNameCreator))

units match {
sources match {
case Nil => checkDeprecations() // nothing to compile, report deprecated options
case _ => compileUnits(units)
case _ =>
val units = sources.map(src => new CompilationUnit(scripted(src), warningFreshNameCreator))
compileUnits(units)
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/compiler/scala/tools/nsc/profile/ExtendedThreadMxBean.java
Expand Up @@ -260,13 +260,14 @@ public SunThreadMxBean(ThreadMXBean underlying) {
super(underlying);
this.real = underlying;
try {
getThreadUserTimeMethod = real.getClass().getMethod("getThreadUserTime", long[].class);
isThreadAllocatedMemoryEnabledMethod = real.getClass().getMethod("isThreadAllocatedMemoryEnabled");
setThreadAllocatedMemoryEnabledMethod = real.getClass().getMethod("setThreadAllocatedMemoryEnabled", Boolean.TYPE);
getThreadAllocatedBytesMethod1 = real.getClass().getMethod("getThreadAllocatedBytes", Long.TYPE);
getThreadAllocatedBytesMethod2 = real.getClass().getMethod("getThreadAllocatedBytes", long[].class);
isThreadAllocatedMemorySupportedMethod = real.getClass().getMethod("isThreadAllocatedMemorySupported");
getThreadCpuTimeMethod = real.getClass().getMethod("getThreadCpuTime", long[].class);
Class<?> cls = Class.forName("com.sun.management.ThreadMXBean");
getThreadUserTimeMethod = cls.getMethod("getThreadUserTime", long[].class);
isThreadAllocatedMemoryEnabledMethod = cls.getMethod("isThreadAllocatedMemoryEnabled");
setThreadAllocatedMemoryEnabledMethod = cls.getMethod("setThreadAllocatedMemoryEnabled", Boolean.TYPE);
getThreadAllocatedBytesMethod1 = cls.getMethod("getThreadAllocatedBytes", Long.TYPE);
getThreadAllocatedBytesMethod2 = cls.getMethod("getThreadAllocatedBytes", long[].class);
isThreadAllocatedMemorySupportedMethod = cls.getMethod("isThreadAllocatedMemorySupported");
getThreadCpuTimeMethod = cls.getMethod("getThreadCpuTime", long[].class);

getThreadUserTimeMethod.setAccessible(true);
isThreadAllocatedMemoryEnabledMethod.setAccessible(true);
Expand Down
Expand Up @@ -973,5 +973,5 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory)
}

private object Optionlike {
def unapply(s: String): Boolean = s.startsWith("-")
def unapply(s: String): Boolean = s.startsWith("-") && s != "-"
}
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -39,7 +39,7 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
protected def defaultClasspath = Option(System.getenv("CLASSPATH")).getOrElse(".")

/** If any of these settings is enabled, the compiler should print a message and exit. */
def infoSettings = List[Setting](version, help, Vhelp, Whelp, Xhelp, Yhelp, showPlugins, showPhases, genPhaseGraph, printArgs)
def infoSettings = List[Setting](version, help, Vhelp, Whelp, Xhelp, Yhelp, showPlugins, showPhases, genPhaseGraph)

/** Is an info setting set? Any -option:help? */
def isInfo = infoSettings.exists(_.isSetByUser) || allSettings.valuesIterator.exists(_.isHelping)
Expand Down
27 changes: 22 additions & 5 deletions src/compiler/scala/tools/nsc/typechecker/Namers.scala
Expand Up @@ -1132,14 +1132,34 @@ trait Namers extends MethodSynthesis {

/** Computes the type of the body in a ValDef or DefDef, and
* assigns the type to the tpt's node. Returns the type.
*
* Under `-Xsource:3`, use `pt`, the type of the overridden member.
* But preserve the precise type of a whitebox macro.
* For `def f = macro g`, here we see `def f = xp(g)` the expansion,
* not the `isMacro` case: `openMacros` will be nonEmpty.
* For `def m = f`, retrieve the typed RHS and check if it is an expansion;
* in that case, check if the expandee `f` is whitebox and preserve
* the precise type if it is. The user must provide an explicit type
* to "opt out" of the inferred narrow type; in Scala 3, they would
* inline the def to "opt in".
*/
private def assignTypeToTree(tree: ValOrDefDef, defnTyper: Typer, pt: Type): Type = {
val rhsTpe = tree match {
case ddef: DefDef if tree.symbol.isTermMacro => defnTyper.computeMacroDefType(ddef, pt)
case ddef: DefDef if tree.symbol.isTermMacro => defnTyper.computeMacroDefType(ddef, pt) // unreached, see methodSig
case _ => defnTyper.computeType(tree.rhs, pt)
}
tree.tpt.defineType {
if (currentRun.isScala3 && !pt.isWildcard && pt != NoType && !pt.isErroneous) pt
val inferOverridden = currentRun.isScala3 &&
!pt.isWildcard && pt != NoType && !pt.isErroneous &&
openMacros.isEmpty && {
context.unit.transformed.get(tree.rhs) match {
case Some(t) if t.hasAttachment[MacroExpansionAttachment] =>
val xp = macroExpandee(t)
xp.symbol == null || isBlackbox(xp.symbol)
case _ => true
}
}
if (inferOverridden) pt
else dropIllegalStarTypes(widenIfNecessary(tree.symbol, rhsTpe, pt, tree.tpt))
}.setPos(tree.pos.focus)
tree.tpt.tpe
Expand Down Expand Up @@ -1331,7 +1351,6 @@ trait Namers extends MethodSynthesis {
val tparamSyms = typer.reenterTypeParams(tparams)
val tparamSkolems = tparams.map(_.symbol)


/*
* Creates a method type using tparamSyms and vparamsSymss as argument symbols and `respte` as result type.
* All typeRefs to type skolems are replaced by references to the corresponding non-skolem type parameter,
Expand All @@ -1343,7 +1362,6 @@ trait Namers extends MethodSynthesis {
def deskolemizedPolySig(vparamSymss: List[List[Symbol]], restpe: Type) =
GenPolyType(tparamSyms, methodTypeFor(meth, vparamSymss, restpe).substSym(tparamSkolems, tparamSyms))


if (tpt.isEmpty && meth.name == nme.CONSTRUCTOR) {
tpt defineType context.enclClass.owner.tpe_*
tpt setPos meth.pos.focus
Expand All @@ -1363,7 +1381,6 @@ trait Namers extends MethodSynthesis {
tptTyped.tpe
}


// ignore missing types unless we can look to overridden method to recover the missing information
val canOverride = methOwner.isClass && !meth.isConstructor
val inferResTp = canOverride && tpt.isEmpty
Expand Down
Expand Up @@ -24,6 +24,7 @@ import symtab.Flags._
* def productArity: Int
* def productElement(n: Int): Any
* def productPrefix: String
* def productIterator: Iterator[Any] // required for binary compatibility of value classes
*
* Selectively added to case classes/objects, unless a non-default
* implementation already exists:
Expand Down Expand Up @@ -113,6 +114,10 @@ trait SyntheticMethods extends ast.TreeDSL {
(m0 ne meth) && !m0.isDeferred && !m0.isSynthetic && (m0.owner != AnyValClass) && (typeInClazz(m0) matches typeInClazz(meth))
}
}
def productIteratorMethod =
createMethod(nme.productIterator, iteratorOfType(AnyTpe))(_ =>
gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(AnyTpe), List(mkThis))
)

def perElementMethod(name: Name, returnType: Type)(caseFn: Symbol => Tree): Tree =
createSwitchMethod(name, accessors.indices, returnType)(idx => caseFn(accessors(idx)))
Expand Down Expand Up @@ -259,6 +264,7 @@ trait SyntheticMethods extends ast.TreeDSL {
Product_productPrefix -> (() => constantNullary(nme.productPrefix, clazz.name.decode)),
Product_productArity -> (() => constantNullary(nme.productArity, arity)),
Product_productElement -> (() => perElementMethod(nme.productElement, AnyTpe)(mkThisSelect)),
Product_iterator -> (() => productIteratorMethod),
Product_canEqual -> (() => canEqualMethod)
)
}
Expand Down
Expand Up @@ -547,7 +547,7 @@ trait TypeDiagnostics extends splain.SplainDiagnostics {
if (sym.isPrimaryConstructor)
for (cpa <- sym.owner.constrParamAccessors if cpa.isPrivateLocal) params += cpa
else if (sym.isSynthetic && sym.isImplicit) return
else if (!sym.isConstructor && !isTrivial(rhs))
else if (!sym.isConstructor && !sym.isVar && !isTrivial(rhs))
for (vs <- vparamss) params ++= vs.map(_.symbol)
defnTrees += m
case _ =>
Expand Down

0 comments on commit 9a12064

Please sign in to comment.