From 56d026868d9f67e03264c042ca93e3e5a162c1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 3 Nov 2022 10:31:20 +0100 Subject: [PATCH 01/17] Add changelog for 3.2.2-RC1 --- changelogs/3.2.2-RC1.md | 151 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 changelogs/3.2.2-RC1.md diff --git a/changelogs/3.2.2-RC1.md b/changelogs/3.2.2-RC1.md new file mode 100644 index 000000000000..75738995c995 --- /dev/null +++ b/changelogs/3.2.2-RC1.md @@ -0,0 +1,151 @@ +# Highlights of the release + +- Make truncation by characters in repl configurable [#16167](https://github.com/lampepfl/dotty/pull/16167) +- New (experimental for now) lazy vals implementation [#15296](https://github.com/lampepfl/dotty/pull/1) + +# Other changes and fixes + +## Coverage + +- Make coverage instrumentation more robust [#16235](https://github.com/lampepfl/dotty/pull/16235) + +## Default parameters + +- Resolve overloading: keep track of prefix and indices of all default getters [#16009](https://github.com/lampepfl/dotty/pull/16009) + +# Experimentals + +- Let accesors inherit @experimental annotations from accessed symbols [#16099](https://github.com/lampepfl/dotty/pull/16099) + +## Extension Methods + +- Fix i14451 [#16010](https://github.com/lampepfl/dotty/pull/16010) + +# GADTs + +- Add fixed GADT exhaustivity test cases [#16169](https://github.com/lampepfl/dotty/pull/16169) +- Eliminate class hierarchy in GadtConstraint [#16194](https://github.com/lampepfl/dotty/pull/16194) + +## Initialization + +- Code refactoring of initialization checker [#16066](https://github.com/lampepfl/dotty/pull/16066) + +## Inline + +- Refine checking for outer references [#16122](https://github.com/lampepfl/dotty/pull/16122) + +## Java interoperability + +- Parse native in Java bytecode as @native [#16232](https://github.com/lampepfl/dotty/pull/16232) + +## Opaque Types + +- Disallow opaque type aliases of context functions [#16041](https://github.com/lampepfl/dotty/pull/16041) + +## Parser + +- Align implementation with spec of soft modifiers [#15961](https://github.com/lampepfl/dotty/pull/15961) + +## Pattern Matching + +- Fix redundancy (unreachability) warning [#16179](https://github.com/lampepfl/dotty/pull/16179) + +# Polyfunctions + +- Avoid checking purity of Apply without symbols [#16221](https://github.com/lampepfl/dotty/pull/16221) + +## Reporting + +- Expose reason for unchecked warning [#16086](https://github.com/lampepfl/dotty/pull/16086) +- Refine AsSeenFrom approximation scheme [#15957](https://github.com/lampepfl/dotty/pull/15957) +- Better output under -Ydetailed-stats [#15950](https://github.com/lampepfl/dotty/pull/15950) +- Fix crash in -Vprofile code [#16007](https://github.com/lampepfl/dotty/pull/16007) +- Name stripped of module suffix must not be empty [#15597](https://github.com/lampepfl/dotty/pull/15597) +- Fix InlineMatch pos for `summonFrom` [#16025](https://github.com/lampepfl/dotty/pull/16025) + +## Rewrites + +- Rewrites are UTF-8 [#15622](https://github.com/lampepfl/dotty/pull/15622) + +## Scala-JS + +- Fix the detection of inferred types of `= js.native`. [#16184](https://github.com/lampepfl/dotty/pull/16184) +- Do not elide fields required for Scala.js interop semantics. [#16187](https://github.com/lampepfl/dotty/pull/16187) + +## Scaladoc + +- Update quick links for new ui [#15912](https://github.com/lampepfl/dotty/pull/15912) +- Avoid parsing code comment twice [#16154](https://github.com/lampepfl/dotty/pull/16154) +- Make footer text configurable [#16064](https://github.com/lampepfl/dotty/pull/16064) +- Add typography fallback fonts [#16063](https://github.com/lampepfl/dotty/pull/16063) + +## SemanticDB + +- Emit SymbolInformation and Occurrence for anonymous class [#15865](https://github.com/lampepfl/dotty/pull/15865) +- Fix regression in type apply synthetics [#16031](https://github.com/lampepfl/dotty/pull/16031) + +## Transform + +- Fix creating forwarders for simple alias givens [#16193](https://github.com/lampepfl/dotty/pull/16193) +- Only check for Scala2LocalSuffix in methods on Scala2x classes [#16014](https://github.com/lampepfl/dotty/pull/16014) +- Fix mapping TypeMaps over annotations [#15948](https://github.com/lampepfl/dotty/pull/15948) +- Peephole optimization to drop .apply from partially applied methods [#16022](https://github.com/lampepfl/dotty/pull/16022) + +## Typer + +- Fix approximateOr of (A & Double) | Null [#16241](https://github.com/lampepfl/dotty/pull/16241) +- Create boxed environments only for references and function values [#16136](https://github.com/lampepfl/dotty/pull/16136) +- Fix higher-order unification incorrectly substituting tparams [#16181](https://github.com/lampepfl/dotty/pull/16181) +- Handle copies of constrained type lambdas when determining an implicit scope [#16159](https://github.com/lampepfl/dotty/pull/16159) +- Create message for missing arguments [#16158](https://github.com/lampepfl/dotty/pull/16158) +- Make singleton types subtypes of their refined type [#16135](https://github.com/lampepfl/dotty/pull/16135) +- Disallow overriding val parameters [#16096](https://github.com/lampepfl/dotty/pull/16096) +- Avoid crash where creator proxies are referenced indirectly [#16098](https://github.com/lampepfl/dotty/pull/16098) +- Refine estimation of default arguments in overloading resolution [#15962](https://github.com/lampepfl/dotty/pull/15962) +- Harden canAssign [#15963](https://github.com/lampepfl/dotty/pull/15963) +- Fix isSubType for static objects filling in type projections [#15959](https://github.com/lampepfl/dotty/pull/15959) +- Fix expected type of TupleXXL unapply [#16248](https://github.com/lampepfl/dotty/pull/16248) +- Drop lazy recursive application in approximateParent [#16073](https://github.com/lampepfl/dotty/pull/16073) +- Type match with a match type when a match type is expected [#15599](https://github.com/lampepfl/dotty/pull/15599) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.1..3.2.2-RC1` these are: + +``` + 83 Martin Odersky + 24 Yichen Xu + 23 Quentin Bernet + 18 Michael Pollmeier + 17 Dale Wijnand + 8 Fengyun Liu + 8 Paweł Marks + 7 Guillaume Raffin + 6 Som Snytt + 6 Szymon Rodziewicz + 5 Kacper Korban + 4 Chris Kipp + 3 Matt Bovel + 3 Rikito Taniguchi + 2 Ben Hutchison + 2 Florian3k + 2 Guillaume Martres + 2 Jamie Thompson + 2 João Costa + 2 Julien Richard-Foy + 2 Lukas Rytz + 2 Sébastien Doeraene + 1 Anton Sviridov + 1 Gabriel Volpe + 1 Liang Yan + 1 Noah Rosamilia + 1 Ondra Pelech + 1 Seth Tisue + 1 Tomasz Godzik + 1 Vadim Chelyshov + 1 nmc.borst + 1 nmcb + 1 olsdavis +``` From 6d1df2eaa6389945356588c46c912af7f61e56ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 3 Nov 2022 10:32:36 +0100 Subject: [PATCH 02/17] Release 3.2.2-RC1 --- tasty/src/dotty/tools/tasty/TastyFormat.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasty/src/dotty/tools/tasty/TastyFormat.scala b/tasty/src/dotty/tools/tasty/TastyFormat.scala index 66b56d30a6a4..98cba90bdccf 100644 --- a/tasty/src/dotty/tools/tasty/TastyFormat.scala +++ b/tasty/src/dotty/tools/tasty/TastyFormat.scala @@ -288,7 +288,7 @@ object TastyFormat { * compatibility, but remains backwards compatible, with all * preceeding `MinorVersion`. */ - final val MinorVersion: Int = 3 + final val MinorVersion: Int = 2 /** Natural Number. The `ExperimentalVersion` allows for * experimentation with changes to TASTy without committing @@ -304,7 +304,7 @@ object TastyFormat { * is able to read final TASTy documents if the file's * `MinorVersion` is strictly less than the current value. */ - final val ExperimentalVersion: Int = 1 + final val ExperimentalVersion: Int = 0 /**This method implements a binary relation (`<:<`) between two TASTy versions. * From 188e595ac9f05896fb87138773dd4912924403e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Mon, 7 Nov 2022 16:55:01 +0100 Subject: [PATCH 03/17] Use `baseVersion` for reference documentation --- project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index ef5cf3839210..c843dd187d91 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1498,7 +1498,7 @@ object Build { .add(OutputDir("scaladoc/output/reference")) .add(SiteRoot(s"${temp.getAbsolutePath}/docs")) .add(ProjectName("Scala 3 Reference")) - .add(ProjectVersion("3.2.0")) // TODO: Change that later to the current version tag. (This must happen on first forward this branch to stable release tag) + .add(ProjectVersion(baseVersion)) .remove[VersionsDictionaryUrl] .add(SourceLinks(List( s"${temp.getAbsolutePath}=github://lampepfl/dotty/language-reference-stable" From f55009330719b57c5e00582e4e6d92759fa23153 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 19 Dec 2022 11:38:54 -0800 Subject: [PATCH 04/17] Backport completions are at typer --- compiler/src/dotty/tools/dotc/interactive/Completion.scala | 3 ++- compiler/test/dotty/tools/repl/TabcompleteTests.scala | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/interactive/Completion.scala b/compiler/src/dotty/tools/dotc/interactive/Completion.scala index 414d406e870a..6af34dc88362 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Completion.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Completion.scala @@ -11,6 +11,7 @@ import dotty.tools.dotc.core.Flags._ import dotty.tools.dotc.core.Names.{Name, TermName} import dotty.tools.dotc.core.NameKinds.SimpleNameKind import dotty.tools.dotc.core.NameOps._ +import dotty.tools.dotc.core.Phases import dotty.tools.dotc.core.Scopes._ import dotty.tools.dotc.core.Symbols.{NoSymbol, Symbol, defn, newSymbol} import dotty.tools.dotc.core.StdNames.nme @@ -45,7 +46,7 @@ object Completion { */ def completions(pos: SourcePosition)(using Context): (Int, List[Completion]) = { val path = Interactive.pathTo(ctx.compilationUnit.tpdTree, pos.span) - computeCompletions(pos, path)(using Interactive.contextOfPath(path)) + computeCompletions(pos, path)(using Interactive.contextOfPath(path).withPhase(Phases.typerPhase)) } /** diff --git a/compiler/test/dotty/tools/repl/TabcompleteTests.scala b/compiler/test/dotty/tools/repl/TabcompleteTests.scala index ecb01d6863da..9cdb896963f1 100644 --- a/compiler/test/dotty/tools/repl/TabcompleteTests.scala +++ b/compiler/test/dotty/tools/repl/TabcompleteTests.scala @@ -228,4 +228,9 @@ class TabcompleteTests extends ReplTest { tabComplete(":d") ) } + + @Test def `i16551 typer phase for implicits` = initially { + val comp = tabComplete("BigInt(1).") + assertTrue(comp.distinct.nonEmpty) + } } From 527834657f8a7a2bc80924b838314fa72befc2e6 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 7 Dec 2022 21:45:32 +0100 Subject: [PATCH 05/17] Only include accessible base classes in orDominator By joining union types we could previously uncover inaccessible base classes that could lead to access errors at runtime. We now filter out such classes when computing the orDominator. Fixes #16474 --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 10 ++++++++-- tests/pos/i16474.scala | 13 +++++++++++++ tests/run/i16474/BaseProvider.java | 6 ++++++ tests/run/i16474/Case1.java | 9 +++++++++ tests/run/i16474/Case1Provider.java | 5 +++++ tests/run/i16474/Case2.java | 8 ++++++++ tests/run/i16474/Case2Provider.java | 5 +++++ tests/run/i16474/Encrypter.java | 4 ++++ tests/run/i16474/test.scala | 14 ++++++++++++++ 9 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i16474.scala create mode 100644 tests/run/i16474/BaseProvider.java create mode 100644 tests/run/i16474/Case1.java create mode 100644 tests/run/i16474/Case1Provider.java create mode 100644 tests/run/i16474/Case2.java create mode 100644 tests/run/i16474/Case2Provider.java create mode 100644 tests/run/i16474/Encrypter.java create mode 100644 tests/run/i16474/test.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 739a06abb7f3..5a6b373561f1 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -209,7 +209,7 @@ object TypeOps: /** Approximate union type by intersection of its dominators. * That is, replace a union type Tn | ... | Tn - * by the smallest intersection type of base-class instances of T1,...,Tn. + * by the smallest intersection type of accessible base-class instances of T1,...,Tn. * Example: Given * * trait C[+T] @@ -370,8 +370,14 @@ object TypeOps: } } + def isAccessible(cls: ClassSymbol) = + if cls.isOneOf(AccessFlags) || cls.privateWithin.exists then + cls.isAccessibleFrom(tp.baseType(cls).normalizedPrefix) + else true + // Step 3: Intersect base classes of both sides - val commonBaseClasses = orBaseClasses(tp) + val commonBaseClasses = orBaseClasses(tp).filterConserve(isAccessible) + val doms = dominators(commonBaseClasses, Nil) def baseTp(cls: ClassSymbol): Type = tp.baseType(cls).mapReduceOr(identity)(mergeRefinedOrApplied) diff --git a/tests/pos/i16474.scala b/tests/pos/i16474.scala new file mode 100644 index 000000000000..834b22c7691f --- /dev/null +++ b/tests/pos/i16474.scala @@ -0,0 +1,13 @@ +object o: + + private[o] trait A + trait B + class C extends A, B + class D extends A, B + +def test = + def f[T](x: T): T => T = identity + val g = f(if ??? then o.C() else o.D()) + g(new o.B{}) + + diff --git a/tests/run/i16474/BaseProvider.java b/tests/run/i16474/BaseProvider.java new file mode 100644 index 000000000000..29346bcf7730 --- /dev/null +++ b/tests/run/i16474/BaseProvider.java @@ -0,0 +1,6 @@ +// BaseProvider.java +package repro.impl; + +import repro.*; +abstract class BaseProvider{} + diff --git a/tests/run/i16474/Case1.java b/tests/run/i16474/Case1.java new file mode 100644 index 000000000000..9d05a2abb6d6 --- /dev/null +++ b/tests/run/i16474/Case1.java @@ -0,0 +1,9 @@ +// Case1.java +package repro; + +import repro.impl.*; + +public class Case1 extends Case1Provider implements Encrypter { + public Case1(){} +} + diff --git a/tests/run/i16474/Case1Provider.java b/tests/run/i16474/Case1Provider.java new file mode 100644 index 000000000000..0b6c63d3bb3d --- /dev/null +++ b/tests/run/i16474/Case1Provider.java @@ -0,0 +1,5 @@ +// Case1Provider.java +package repro.impl; + +public abstract class Case1Provider extends BaseProvider {} + diff --git a/tests/run/i16474/Case2.java b/tests/run/i16474/Case2.java new file mode 100644 index 000000000000..37804d3b84eb --- /dev/null +++ b/tests/run/i16474/Case2.java @@ -0,0 +1,8 @@ +// Case2.java +package repro; + +import repro.impl.*; + +public class Case2 extends Case2Provider implements Encrypter { + public Case2(){} +} diff --git a/tests/run/i16474/Case2Provider.java b/tests/run/i16474/Case2Provider.java new file mode 100644 index 000000000000..e860964e59c3 --- /dev/null +++ b/tests/run/i16474/Case2Provider.java @@ -0,0 +1,5 @@ +// Case2Provider.java +package repro.impl; + +public abstract class Case2Provider extends BaseProvider {} + diff --git a/tests/run/i16474/Encrypter.java b/tests/run/i16474/Encrypter.java new file mode 100644 index 000000000000..ec721d27af9d --- /dev/null +++ b/tests/run/i16474/Encrypter.java @@ -0,0 +1,4 @@ +// Encrypter.java +package repro; +public interface Encrypter{} + diff --git a/tests/run/i16474/test.scala b/tests/run/i16474/test.scala new file mode 100644 index 000000000000..2b58807e119b --- /dev/null +++ b/tests/run/i16474/test.scala @@ -0,0 +1,14 @@ +// test.scala +import repro.* +import scala.util.Try + +def get(arg: Any): Try[Encrypter] = Try { + val x: Any = 1 + arg match + case 1 => new Case1() + case 2 => new Case2() + case _ => throw new RuntimeException(s"Unsupported got $arg") +} + +@main def Test = + val result = get(null) From 6237bc3692050670280df042e475c3ff686b5e42 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 7 Dec 2022 23:57:02 +0100 Subject: [PATCH 06/17] Skip test for scalaJS Add a magical comment instead of moving test --- tests/run/i16474/test.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/run/i16474/test.scala b/tests/run/i16474/test.scala index 2b58807e119b..2dc2900dd2a8 100644 --- a/tests/run/i16474/test.scala +++ b/tests/run/i16474/test.scala @@ -1,3 +1,4 @@ +// scalajs: --skip // test.scala import repro.* import scala.util.Try From 55dbf6413a5939f1a22011550f0d7e083387e8c9 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 9 Dec 2022 15:44:44 +0100 Subject: [PATCH 07/17] Fix curried overloading resolution for polymorphic methods Fixes #16484 --- compiler/src/dotty/tools/dotc/typer/Applications.scala | 2 +- tests/pos/i16484.scala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i16484.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 15493e6805dc..386bae6d5338 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -2140,7 +2140,7 @@ trait Applications extends Compatibility { val reverseMapping = alts.flatMap { alt => val t = f(alt) if t.exists then - val (trimmed, skipped) = trimParamss(t, alt.symbol.rawParamss) + val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss) val mappedSym = alt.symbol.asTerm.copy(info = t) mappedSym.rawParamss = trimmed val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match diff --git a/tests/pos/i16484.scala b/tests/pos/i16484.scala new file mode 100644 index 000000000000..b0a5bf1f8a17 --- /dev/null +++ b/tests/pos/i16484.scala @@ -0,0 +1,3 @@ +trait JWTEncoder: + def encode[P](arg: String)(opt: Option[String] = None): String + def encode[P](arg: String): String = encode(arg)() From 0d7978043175103c91b151a97442b799dedd8791 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 11 Oct 2022 10:48:00 +0100 Subject: [PATCH 08/17] Fix exhaustivity warning --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 4 ++++ tests/pos/i15967.scala | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/pos/i15967.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 739a06abb7f3..9932bee26f4a 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -863,6 +863,10 @@ object TypeOps: } def instantiate(): Type = { + // if there's a change in variance in type parameters (between subtype tp1 and supertype tp2) + // then we don't want to maximise the type variables in the wrong direction. + // For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any + maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan) maximizeType(protoTp1, NoSpan) wildApprox(protoTp1) } diff --git a/tests/pos/i15967.scala b/tests/pos/i15967.scala new file mode 100644 index 000000000000..0ef00ae0cea1 --- /dev/null +++ b/tests/pos/i15967.scala @@ -0,0 +1,10 @@ +// scalac: -Werror +sealed trait A[-Z] +final case class B[Y]() extends A[Y] + +class Test: + def t1[X](a: A[X]) = a match // was inexhaustive + case _: B[X] @unchecked => + +//def t2[X](a: A[X]) = a match // was inexhaustive +// case _: B[X] => // expected unchecked warning From 99ba2a3181d39a659c40e60f5bbbe7c4c31cb08d Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 15 Sep 2022 17:35:51 +0100 Subject: [PATCH 09/17] Teach SpaceEngine that generic tuples are irrefutable --- .../tools/dotc/transform/patmat/Space.scala | 1 + tests/neg/i15991.abstract.scala | 20 +++++++++++++++++++ tests/neg/i15991.scala | 7 +++++++ tests/pos/i15991.abstract.scala | 20 +++++++++++++++++++ tests/pos/i15991.orig.scala | 9 +++++++++ tests/pos/i15991.scala | 8 ++++++++ 6 files changed, 65 insertions(+) create mode 100644 tests/neg/i15991.abstract.scala create mode 100644 tests/neg/i15991.scala create mode 100644 tests/pos/i15991.abstract.scala create mode 100644 tests/pos/i15991.orig.scala create mode 100644 tests/pos/i15991.scala diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index ca0e149f881f..8e891f822255 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -306,6 +306,7 @@ object SpaceEngine { val isEmptyTp = extractorMemberType(unappResult, nme.isEmpty, NoSourcePosition) isEmptyTp <:< ConstantType(Constant(false)) } + || unappResult.derivesFrom(defn.NonEmptyTupleClass) } /** Is the unapply or unapplySeq irrefutable? diff --git a/tests/neg/i15991.abstract.scala b/tests/neg/i15991.abstract.scala new file mode 100644 index 000000000000..aa974e487080 --- /dev/null +++ b/tests/neg/i15991.abstract.scala @@ -0,0 +1,20 @@ +object Foo: + def unapply[T <: Tuple](tup: T): String *: String *: T = + "a" *: "b" *: tup + +// like {pos,neg}/i15991, but with an abstract tuple tail +class Test: + val tup2: String *: String *: EmptyTuple = ("c", "d") + + def test3 = + val Foo(x, y, z) = tup2 // error: Wrong number of argument patterns for Foo; expected: (String, String, String, String) + x + y + z + + def test3a = + val x1x = tup2 match + case Foo(x, y, z) => // error: Wrong number of argument patterns for Foo; expected: (String, String, String, String) + (x, y, z) + val x = x1x._1 + val y = x1x._2 + val z = x1x._3 + x + y + z diff --git a/tests/neg/i15991.scala b/tests/neg/i15991.scala new file mode 100644 index 000000000000..9cd6b1c1d27e --- /dev/null +++ b/tests/neg/i15991.scala @@ -0,0 +1,7 @@ +object Foo: + def unapply(x: Any): String *: String *: EmptyTuple = ("a", "b") + +class Test: + def test = + val Foo(x, y, z) = 1 // error: Wrong number of argument patterns for Foo; expected: (String, String) + x + y + z diff --git a/tests/pos/i15991.abstract.scala b/tests/pos/i15991.abstract.scala new file mode 100644 index 000000000000..3499fa7a014d --- /dev/null +++ b/tests/pos/i15991.abstract.scala @@ -0,0 +1,20 @@ +object Foo: + def unapply[T <: Tuple](tup: T): String *: String *: T = + "a" *: "b" *: tup + +// like {pos,neg}/i15991, but with an abstract tuple tail +class Test: + val tup2: String *: String *: EmptyTuple = ("c", "d") + + def test2 = + val Foo(x, y, _, _) = tup2 + x + y + + // like test2, but as the desugaring of what PatternDef's become + def test2b = + val x1x = tup2 match + case Foo(x, y, _, _) => + (x, y) + val x = x1x._1 + val y = x1x._2 + x + y diff --git a/tests/pos/i15991.orig.scala b/tests/pos/i15991.orig.scala new file mode 100644 index 000000000000..f56bd2979b40 --- /dev/null +++ b/tests/pos/i15991.orig.scala @@ -0,0 +1,9 @@ +class Foo + +object Foo: +// def unapply(f: Foo): (Int, Int) = ??? // does not raise a warning + def unapply(f: Foo): Int *: Int *: EmptyTuple = ??? + +@main def example = + val Foo(x, y) = new Foo + println(x) diff --git a/tests/pos/i15991.scala b/tests/pos/i15991.scala new file mode 100644 index 000000000000..b5c30471bfdc --- /dev/null +++ b/tests/pos/i15991.scala @@ -0,0 +1,8 @@ +object Foo: + def unapply(x: Any): String *: String *: EmptyTuple = + ("a", "b") + +class Test: + def test = + val Foo(x, y) = 1 + x + y From 1152262671726fc859efaa76833c8c390f911f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 22 Dec 2022 18:53:24 +0100 Subject: [PATCH 10/17] Add changelog for 3.2.2-RC2 --- changelogs/3.2.2-RC2.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 changelogs/3.2.2-RC2.md diff --git a/changelogs/3.2.2-RC2.md b/changelogs/3.2.2-RC2.md new file mode 100644 index 000000000000..bf171a7e987f --- /dev/null +++ b/changelogs/3.2.2-RC2.md @@ -0,0 +1,20 @@ +# Backported fixes + +- Compute completions at `typerPhase` [#16371](https://github.com/lampepfl/dotty/pull/16371) +- Only include accessible base classes in `orDominator` [#16477](https://github.com/lampepfl/dotty/pull/16477) +- Fix curried overloading resolution for polymorphic methods [#16485](https://github.com/lampepfl/dotty/pull/16485) +- Teach SpaceEngine that generic tuples are irrefutable [#16051](https://github.com/lampepfl/dotty/pull/16051) +- Fix exhaustivity warning [#16168](https://github.com/lampepfl/dotty/pull/16168) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.2-RC1..3.2.2-RC2` these are: + +``` + 3 Martin Odersky + 3 Paweł Marks + 2 Dale Wijnand + 1 Som Snytt +``` From 92e1e43a59a2301655c7d3a334f8f90250ee88dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 22 Dec 2022 18:54:58 +0100 Subject: [PATCH 11/17] Release 3.2.2-RC2 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index c843dd187d91..d735daefde5b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.1" - val baseVersion = "3.2.2-RC1" + val baseVersion = "3.2.2-RC2" // Versions used by the vscode extension to create a new project // This should be the latest published releases. @@ -98,7 +98,7 @@ object Build { * set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest * 3.0.x release. */ - val previousDottyVersion = "3.2.1" + val previousDottyVersion = "3.2.2-RC1" object CompatMode { final val BinaryCompatible = 0 From 7730b09910a4fa46d7718e6ec125980216f7fb57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Wed, 11 Jan 2023 14:19:18 +0100 Subject: [PATCH 12/17] Add changelog for 3.2.2 --- changelogs/3.2.2.md | 160 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 changelogs/3.2.2.md diff --git a/changelogs/3.2.2.md b/changelogs/3.2.2.md new file mode 100644 index 000000000000..610e6ccf53b0 --- /dev/null +++ b/changelogs/3.2.2.md @@ -0,0 +1,160 @@ +# Highlights of the release + +- Make truncation by characters in repl configurable [#16167](https://github.com/lampepfl/dotty/pull/16167) +- New (experimental for now) lazy vals implementation [#15296](https://github.com/lampepfl/dotty/pull/1) + +# Other changes and fixes + +## Coverage + +- Make coverage instrumentation more robust [#16235](https://github.com/lampepfl/dotty/pull/16235) + +## Default parameters + +- Resolve overloading: keep track of prefix and indices of all default getters [#16009](https://github.com/lampepfl/dotty/pull/16009) + +# Experimentals + +- Let accesors inherit @experimental annotations from accessed symbols [#16099](https://github.com/lampepfl/dotty/pull/16099) + +## Extension Methods + +- Fix i14451 [#16010](https://github.com/lampepfl/dotty/pull/16010) + +# GADTs + +- Add fixed GADT exhaustivity test cases [#16169](https://github.com/lampepfl/dotty/pull/16169) +- Eliminate class hierarchy in GadtConstraint [#16194](https://github.com/lampepfl/dotty/pull/16194) + +## Initialization + +- Code refactoring of initialization checker [#16066](https://github.com/lampepfl/dotty/pull/16066) + +## Inline + +- Refine checking for outer references [#16122](https://github.com/lampepfl/dotty/pull/16122) + +## Java interoperability + +- Parse native in Java bytecode as @native [#16232](https://github.com/lampepfl/dotty/pull/16232) + +## Opaque Types + +- Disallow opaque type aliases of context functions [#16041](https://github.com/lampepfl/dotty/pull/16041) + +## Overloading + +- Fix curried overloading resolution for polymorphic methods [#16485](https://github.com/lampepfl/dotty/pull/16485) + +## Parser + +- Align implementation with spec of soft modifiers [#15961](https://github.com/lampepfl/dotty/pull/15961) + +## Pattern Matching + +- Fix redundancy (unreachability) warning [#16179](https://github.com/lampepfl/dotty/pull/16179) +- Teach SpaceEngine that generic tuples are irrefutable [#16051](https://github.com/lampepfl/dotty/pull/16051) +- Fix exhaustivity warning [#16168](https://github.com/lampepfl/dotty/pull/16168) + +# Polyfunctions + +- Avoid checking purity of Apply without symbols [#16221](https://github.com/lampepfl/dotty/pull/16221) + +## Reporting + +- Expose reason for unchecked warning [#16086](https://github.com/lampepfl/dotty/pull/16086) +- Refine AsSeenFrom approximation scheme [#15957](https://github.com/lampepfl/dotty/pull/15957) +- Better output under -Ydetailed-stats [#15950](https://github.com/lampepfl/dotty/pull/15950) +- Fix crash in -Vprofile code [#16007](https://github.com/lampepfl/dotty/pull/16007) +- Name stripped of module suffix must not be empty [#15597](https://github.com/lampepfl/dotty/pull/15597) +- Fix InlineMatch pos for `summonFrom` [#16025](https://github.com/lampepfl/dotty/pull/16025) + +## Rewrites + +- Rewrites are UTF-8 [#15622](https://github.com/lampepfl/dotty/pull/15622) + +## Scala-JS + +- Fix the detection of inferred types of `= js.native`. [#16184](https://github.com/lampepfl/dotty/pull/16184) +- Do not elide fields required for Scala.js interop semantics. [#16187](https://github.com/lampepfl/dotty/pull/16187) + +## Scaladoc + +- Update quick links for new ui [#15912](https://github.com/lampepfl/dotty/pull/15912) +- Avoid parsing code comment twice [#16154](https://github.com/lampepfl/dotty/pull/16154) +- Make footer text configurable [#16064](https://github.com/lampepfl/dotty/pull/16064) +- Add typography fallback fonts [#16063](https://github.com/lampepfl/dotty/pull/16063) + +## SemanticDB + +- Emit SymbolInformation and Occurrence for anonymous class [#15865](https://github.com/lampepfl/dotty/pull/15865) +- Fix regression in type apply synthetics [#16031](https://github.com/lampepfl/dotty/pull/16031) + +## Transform + +- Fix creating forwarders for simple alias givens [#16193](https://github.com/lampepfl/dotty/pull/16193) +- Only check for Scala2LocalSuffix in methods on Scala2x classes [#16014](https://github.com/lampepfl/dotty/pull/16014) +- Fix mapping TypeMaps over annotations [#15948](https://github.com/lampepfl/dotty/pull/15948) +- Peephole optimization to drop .apply from partially applied methods [#16022](https://github.com/lampepfl/dotty/pull/16022) + +## Typer + +- Fix approximateOr of (A & Double) | Null [#16241](https://github.com/lampepfl/dotty/pull/16241) +- Create boxed environments only for references and function values [#16136](https://github.com/lampepfl/dotty/pull/16136) +- Fix higher-order unification incorrectly substituting tparams [#16181](https://github.com/lampepfl/dotty/pull/16181) +- Handle copies of constrained type lambdas when determining an implicit scope [#16159](https://github.com/lampepfl/dotty/pull/16159) +- Create message for missing arguments [#16158](https://github.com/lampepfl/dotty/pull/16158) +- Make singleton types subtypes of their refined type [#16135](https://github.com/lampepfl/dotty/pull/16135) +- Disallow overriding val parameters [#16096](https://github.com/lampepfl/dotty/pull/16096) +- Avoid crash where creator proxies are referenced indirectly [#16098](https://github.com/lampepfl/dotty/pull/16098) +- Refine estimation of default arguments in overloading resolution [#15962](https://github.com/lampepfl/dotty/pull/15962) +- Harden canAssign [#15963](https://github.com/lampepfl/dotty/pull/15963) +- Fix isSubType for static objects filling in type projections [#15959](https://github.com/lampepfl/dotty/pull/15959) +- Fix expected type of TupleXXL unapply [#16248](https://github.com/lampepfl/dotty/pull/16248) +- Drop lazy recursive application in approximateParent [#16073](https://github.com/lampepfl/dotty/pull/16073) +- Type match with a match type when a match type is expected [#15599](https://github.com/lampepfl/dotty/pull/15599) +- Compute completions at `typerPhase` [#16371](https://github.com/lampepfl/dotty/pull/16371) +- Only include accessible base classes in `orDominator` [#16477](https://github.com/lampepfl/dotty/pull/16477) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.1..3.2.2` these are: + +``` + 86 Martin Odersky + 24 Yichen Xu + 23 Quentin Bernet + 19 Dale Wijnand + 18 Michael Pollmeier + 13 Paweł Marks + 8 Fengyun Liu + 7 Guillaume Raffin + 7 Som Snytt + 6 Szymon Rodziewicz + 5 Kacper Korban + 4 Chris Kipp + 3 Matt Bovel + 3 Rikito Taniguchi + 2 Ben Hutchison + 2 Florian3k + 2 Guillaume Martres + 2 Jamie Thompson + 2 João Costa + 2 Julien Richard-Foy + 2 Lukas Rytz + 2 Sébastien Doeraene + 1 Anton Sviridov + 1 Gabriel Volpe + 1 Liang Yan + 1 Noah Rosamilia + 1 Ondra Pelech + 1 Seth Tisue + 1 Tomasz Godzik + 1 Vadim Chelyshov + 1 nmc.borst + 1 nmcb + 1 olsdavis + +``` From 22193a395008c51f0db51a566c4570a40f2f616b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Wed, 11 Jan 2023 14:21:08 +0100 Subject: [PATCH 13/17] Release 3.2.2 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index d735daefde5b..94cfacb42727 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.1" - val baseVersion = "3.2.2-RC2" + val baseVersion = "3.2.2" // Versions used by the vscode extension to create a new project // This should be the latest published releases. @@ -98,7 +98,7 @@ object Build { * set to 3.1.3. If it is going to be 3.1.0, it must be set to the latest * 3.0.x release. */ - val previousDottyVersion = "3.2.2-RC1" + val previousDottyVersion = "3.2.1" object CompatMode { final val BinaryCompatible = 0 From 7aba7b019f6093869bd6d52aac8134b1c2c08c9b Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Mon, 12 Dec 2022 12:30:23 +0100 Subject: [PATCH 14/17] Allow PRs for GH actions bot --- project/scripts/check-cla.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/project/scripts/check-cla.sh b/project/scripts/check-cla.sh index 21efa74eb2eb..1a91363f5079 100755 --- a/project/scripts/check-cla.sh +++ b/project/scripts/check-cla.sh @@ -2,15 +2,19 @@ set -eux echo "Pull request submitted by $AUTHOR"; -signed=$(curl -s https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR | jq -r ".signed"); -if [ "$signed" = "true" ] ; then +if [ "$AUTHOR" = "github-actions[bot]" ] ; then echo "CLA check for $AUTHOR successful"; else - echo "CLA check for $AUTHOR failed"; - echo "Please sign the Scala CLA to contribute to the Scala compiler."; - echo "Go to https://www.lightbend.com/contribute/cla/scala and then"; - echo "comment on the pull request to ask for a new check."; - echo ""; - echo "Check if CLA is signed: https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR"; - exit 1; + signed=$(curl -s "https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR" | jq -r ".signed"); + if [ "$signed" = "true" ] ; then + echo "CLA check for $AUTHOR successful"; + else + echo "CLA check for $AUTHOR failed"; + echo "Please sign the Scala CLA to contribute to the Scala compiler."; + echo "Go to https://www.lightbend.com/contribute/cla/scala and then"; + echo "comment on the pull request to ask for a new check."; + echo ""; + echo "Check if CLA is signed: https://www.lightbend.com/contribute/cla/scala/check/$AUTHOR"; + exit 1; + fi; fi; From 62bcea0e09c0364df93629e51560c21e9f95aa32 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Mon, 12 Dec 2022 12:58:25 +0100 Subject: [PATCH 15/17] Not ignore language reference stable branch on CI --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b4b8da1b82a7..368766349bab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,8 +2,6 @@ name: Dotty on: push: - branches-ignore: - - 'language-reference-stable' tags: - '**' pull_request: From e1dbd87f615d217525950e1c443cccd0dcf0b8c4 Mon Sep 17 00:00:00 2001 From: Dmitrii Naumenko Date: Wed, 14 Dec 2022 09:42:19 +0100 Subject: [PATCH 16/17] trait-parameters.md: delete invalid code from example This code doesn't compile and produces error: >[error] 15 | ImpliedFormalGreeting(using iname) >[error] | ^^^^^^^^^^^^^^^^^^^^^ >[error] |constructor ImpliedFormalGreeting in trait ImpliedFormalGreeting does not take more parameters >[error] |---------------------------------------------------------------------------- >[error] | Explanation (enabled by `-explain`) >[error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >[error] | You have specified more parameter lists than defined in the method definition(s). This will compile: ```scala class F(using iname: ImpliedName) extends Object, ImpliedGreeting(using iname), ImpliedFormalGreeting ``` I understand, that maybe this is kinda pseudo-code. >The definition of `F` in the last line is implicitly expanded to But if it's stated that the original code will be "expanded" it sounds as if it we could do it ourselves manually and that would be effectively the same code. An alternative to deleting `(using iname)` could be commenting it out `//(using iname)`. --- docs/_docs/reference/other-new-features/trait-parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_docs/reference/other-new-features/trait-parameters.md b/docs/_docs/reference/other-new-features/trait-parameters.md index c704e73ce9b8..e46ba455c7b3 100644 --- a/docs/_docs/reference/other-new-features/trait-parameters.md +++ b/docs/_docs/reference/other-new-features/trait-parameters.md @@ -79,7 +79,7 @@ The definition of `F` in the last line is implicitly expanded to class F(using iname: ImpliedName) extends Object, ImpliedGreeting(using iname), - ImpliedFormalGreeting(using iname) + ImpliedFormalGreeting ``` Note the inserted reference to the super trait `ImpliedGreeting`, which was not mentioned explicitly. From 4a8766ca53598bdd2123423faa21df00f6c4c5f6 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Wed, 18 Jan 2023 16:56:29 +0100 Subject: [PATCH 17/17] Hide versions when versions dict. not available --- scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala | 1 + scaladoc/resources/dotty_res/styles/theme/layout/header.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala b/scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala index d8cdb946b852..465ee44d1ad4 100644 --- a/scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala +++ b/scaladoc-js/main/src/versions-dropdown/DropdownHandler.scala @@ -31,6 +31,7 @@ class DropdownHandler: private def disableButton() = val btn = document.getElementById("dropdown-trigger").asInstanceOf[html.Span] btn.classList.add("disabled") + btn.classList.add("hidden") private def getURLContent(url: String): Future[String] = Ajax.get(url).map(_.responseText) diff --git a/scaladoc/resources/dotty_res/styles/theme/layout/header.css b/scaladoc/resources/dotty_res/styles/theme/layout/header.css index 6447f111bc8f..034f9ed43087 100644 --- a/scaladoc/resources/dotty_res/styles/theme/layout/header.css +++ b/scaladoc/resources/dotty_res/styles/theme/layout/header.css @@ -41,6 +41,10 @@ margin-right: calc(2 * var(--base-spacing)); } +.header-container-left span.hidden { + display: none; +} + .header-container-right { display: flex; align-items: center;