From a3987d86ef64387decc277bdaa2fa48b68f07025 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 10 Apr 2017 11:04:04 -0700 Subject: Bump on 2.11.10 release --- build.number | 2 +- build.sbt | 2 +- scripts/jobs/integrate/windows | 2 +- test/benchmarks/build.sbt | 2 +- versions.properties | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.number b/build.number index eb7a952b15..6c222a08f6 100644 --- a/build.number +++ b/build.number @@ -4,7 +4,7 @@ version.major=2 version.minor=11 -version.patch=10 +version.patch=11 # This is the -N part of a version (2.9.1-1). If it's 0, it's dropped from maven versions. It should not be used again. version.bnum=0 diff --git a/build.sbt b/build.sbt index c7576bcc60..517dd03529 100644 --- a/build.sbt +++ b/build.sbt @@ -113,7 +113,7 @@ lazy val publishSettings : Seq[Setting[_]] = Seq( // VersionUtil.versionPropertiesImpl for details. The standard sbt `version` setting should not be set directly. It // is the same as the Maven version and derived automatically from `baseVersion` and `baseVersionSuffix`. globalVersionSettings -baseVersion in Global := "2.11.10" +baseVersion in Global := "2.11.11" baseVersionSuffix in Global := "SNAPSHOT" mimaReferenceVersion in Global := Some("2.11.0") diff --git a/scripts/jobs/integrate/windows b/scripts/jobs/integrate/windows index 83caaaa676..baed9f6236 100755 --- a/scripts/jobs/integrate/windows +++ b/scripts/jobs/integrate/windows @@ -12,7 +12,7 @@ javac -version ant -version ant \ - -Dstarr.version=2.11.9 \ + -Dstarr.version=2.11.10 \ -Dscalac.args.optimise=-optimise \ -Dlocker.skip=1 \ test diff --git a/test/benchmarks/build.sbt b/test/benchmarks/build.sbt index 7ffa4a4346..f80305f24b 100644 --- a/test/benchmarks/build.sbt +++ b/test/benchmarks/build.sbt @@ -1,5 +1,5 @@ scalaHome := Some(file("../../build/pack")) -scalaVersion := "2.11.9" +scalaVersion := "2.11.10" scalacOptions ++= Seq("-feature", "-Yopt:l:classpath") lazy val root = (project in file(".")). diff --git a/versions.properties b/versions.properties index 55420f6c3f..4318bfa6e3 100644 --- a/versions.properties +++ b/versions.properties @@ -8,7 +8,7 @@ # The scala version used for bootstrapping. This has no impact on the final classfiles: # there are two stages (locker and quick), so compiler and library are always built # with themselves. Stability is ensured by building a third stage (strap). -starr.version=2.11.9 +starr.version=2.11.10 # These are the versions of the modules that go with this release. # These properties are used during PR validation and in dbuild builds. @@ -22,7 +22,7 @@ starr.version=2.11.9 scala.binary.version=2.11 # e.g. 2.11.0-RC1, 2.11.0, 2.11.1-RC1, 2.11.1 # this defines the dependency on scala-continuations-plugin in scala-dist's pom -scala.full.version=2.11.9 +scala.full.version=2.11.10 # external modules shipped with distribution, as specified by scala-library-all's pom scala-xml.version.number=1.0.5 -- cgit v1.2.3 From 7a5df5702c64a8cc3ee1f356a000d89761e4db70 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 10 Apr 2017 11:07:00 -0700 Subject: Update README.md Fix table --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4babc4642..549045cbbc 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Please report bugs at the [scala/bug issue tracker](https://github.com/scala/bug # Get in touch! If you need some help with your PR at any time, please feel free to @-mention anyone from the list below, and we will do our best to help you out: - | username | talk to me about... | +| | username | talk to me about... | --------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---------------------------------------------------| | [`@adriaanm`](https://github.com/adriaanm) | type checker, pattern matcher, infrastructure, language spec | | [`@SethTisue`](https://github.com/SethTisue) | build, developer docs, community build, Jenkins, library, the welcome-to-Scala experience | -- cgit v1.2.3 From 5167b691bbc6eccc671ef3a49c7ecaf3343c0baa Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 10 Apr 2017 11:14:20 -0700 Subject: MathJax CDN change and version bump https://www.mathjax.org/cdn-shutting-down/ --- spec/_layouts/default.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/_layouts/default.yml b/spec/_layouts/default.yml index 61085b5a3e..20ebf22725 100644 --- a/spec/_layouts/default.yml +++ b/spec/_layouts/default.yml @@ -15,7 +15,7 @@ } }); - + -- cgit v1.2.3 From 77917e94c70759602be0dae833e798e894999254 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 12 Apr 2017 11:31:54 -0700 Subject: Actually retract clashing synthetic apply/unapply [backport] Also make this whole retraction of apply/unapply in case of a clashing user-defined member conditional on `-Xsource:2.12`. It turns out, as explained by lrytz, that the retraction mechanism was fragile because it relied on the order in which completers are run. We now cover both the case that: - the completer was run, the `IS_ERROR` flag was set, and the symbol was unlinked from its scope before `addSynthetics` in `typedStat` iterates over the scope (since the symbol is already unlinked, the tree is not added, irrespective of its flags). For this case, we also remove the symbol from the synthetics in its unit (for cleanliness). - the completer is triggered during the iteration in `addSynthetics`, which needs the check for the `IS_ERROR` flag during the iteration. Before, the completer just unlinked the symbol and set the IS_ERROR flag, and I assumed the typer dropped a synthetic tree with a symbol with that flag, because the tree was not shown in -Xprint output. In reality, the completer just always happened to run before the addSynthetics loop and unlinked the symbol from its scope in the test cases I came up with (including the 2.11 community build). Thankfully, the 2.12 community build caught my mistake, and lrytz provided a good analysis and review. Fix scala/bug#10261 --- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 17 +++++++++++++++-- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 +++++- test/files/neg/userdefined_apply.flags | 1 + test/files/pos/userdefined_apply.flags | 1 + test/files/pos/userdefined_apply_poly_overload.flags | 1 + test/files/run/t10261.flags | 1 + test/files/run/t10261/Companion_1.scala | 4 ++++ test/files/run/t10261/Test_2.scala | 14 ++++++++++++++ 8 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 test/files/neg/userdefined_apply.flags create mode 100644 test/files/pos/userdefined_apply.flags create mode 100644 test/files/pos/userdefined_apply_poly_overload.flags create mode 100644 test/files/run/t10261.flags create mode 100644 test/files/run/t10261/Companion_1.scala create mode 100644 test/files/run/t10261/Test_2.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index b755ee3ebd..81299dc425 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -691,8 +691,21 @@ trait Namers extends MethodSynthesis { if (suppress) { sym setInfo ErrorType + // There are two ways in which we exclude the symbol from being added in typedStats::addSynthetics, + // because we don't know when the completer runs with respect to this loop in addSynthetics + // for (sym <- scope) + // for (tree <- context.unit.synthetics.get(sym) if shouldAdd(sym)) { + // if (!sym.initialize.hasFlag(IS_ERROR)) + // newStats += typedStat(tree) + // (1) If we're already in the loop, set the IS_ERROR flag and trigger the condition + // `sym.initialize.hasFlag(IS_ERROR)` in typedStats::addSynthetics, + // (2) Or, if we are not yet in the addSynthetics loop (and we're not going to emit an error anyway), + // we unlink the symbol from its scope. sym setFlag IS_ERROR + // For good measure. Removing it from its owner's scope and setting the IS_ERROR flag is enough to exclude it from addSynthetics + companionContext.unit.synthetics -= sym + // Don't unlink in an error situation to generate less confusing error messages. // Ideally, our error reporting would distinguish overloaded from recursive user-defined apply methods without signature, // but this would require some form of partial-completion of method signatures, so that we can @@ -702,7 +715,7 @@ trait Namers extends MethodSynthesis { // I hesitate to provide more info, because it would involve a WildCard or something for its result type, // which could upset other code paths) if (!scopePartiallyCompleted) - companionContext.scope.unlink(sym) + companionContext.scope.unlink(sym) // (2) } } } @@ -770,7 +783,7 @@ trait Namers extends MethodSynthesis { val completer = if (sym hasFlag SYNTHETIC) { if (name == nme.copy) copyMethodCompleter(tree) - else if (sym hasFlag CASE) applyUnapplyMethodCompleter(tree, context) + else if (settings.isScala212 && (sym hasFlag CASE)) applyUnapplyMethodCompleter(tree, context) else completerOf(tree) } else completerOf(tree) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 00e0517df6..ac0a653626 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3093,6 +3093,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val scope = if (inBlock) context.scope else context.owner.info.decls var newStats = new ListBuffer[Tree] var moreToAdd = true + val retractErroneousSynthetics = settings.isScala212 + while (moreToAdd) { val initElems = scope.elems // SI-5877 The decls of a package include decls of the package object. But we don't want to add @@ -3101,7 +3103,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper inBlock || !context.isInPackageObject(sym, context.owner) for (sym <- scope) for (tree <- context.unit.synthetics get sym if shouldAdd(sym)) { // OPT: shouldAdd is usually true. Call it here, rather than in the outer loop - newStats += typedStat(tree) // might add even more synthetics to the scope + // if the completer set the IS_ERROR flag, retract the stat (currently only used by applyUnapplyMethodCompleter) + if (!(retractErroneousSynthetics && sym.initialize.hasFlag(IS_ERROR))) + newStats += typedStat(tree) // might add even more synthetics to the scope context.unit.synthetics -= sym } // the type completer of a synthetic might add more synthetics. example: if the diff --git a/test/files/neg/userdefined_apply.flags b/test/files/neg/userdefined_apply.flags new file mode 100644 index 0000000000..0acce1e7ce --- /dev/null +++ b/test/files/neg/userdefined_apply.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/pos/userdefined_apply.flags b/test/files/pos/userdefined_apply.flags new file mode 100644 index 0000000000..0acce1e7ce --- /dev/null +++ b/test/files/pos/userdefined_apply.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/pos/userdefined_apply_poly_overload.flags b/test/files/pos/userdefined_apply_poly_overload.flags new file mode 100644 index 0000000000..0acce1e7ce --- /dev/null +++ b/test/files/pos/userdefined_apply_poly_overload.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/run/t10261.flags b/test/files/run/t10261.flags new file mode 100644 index 0000000000..0acce1e7ce --- /dev/null +++ b/test/files/run/t10261.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/run/t10261/Companion_1.scala b/test/files/run/t10261/Companion_1.scala new file mode 100644 index 0000000000..9b8e2c73b2 --- /dev/null +++ b/test/files/run/t10261/Companion_1.scala @@ -0,0 +1,4 @@ +trait Companion[T] { + def parse(value: String): Option[T] + def apply(value: String): T = parse(value).get +} diff --git a/test/files/run/t10261/Test_2.scala b/test/files/run/t10261/Test_2.scala new file mode 100644 index 0000000000..d7d9fe9a0e --- /dev/null +++ b/test/files/run/t10261/Test_2.scala @@ -0,0 +1,14 @@ +import scala.util.Try + +object C extends Companion[C] { + def parse(v: String) = if (v.nonEmpty) Some(new C(v)) else None +} + +case class C(value: String) + +object Test { + def main(args: Array[String]): Unit = { + assert(Try{C("")}.isFailure, "Empty value should fail to parse") // check that parse is used to validate input + assert(C("a").value == "a", "Unexpected value") + } +} -- cgit v1.2.3