From e1bbbd102d3e6280672afbffa4bec3460e78cc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 1 Sep 2022 16:21:48 +0200 Subject: [PATCH 01/34] Add changelog for 3.2.1-RC1 --- changelogs/3.2.1-RC1.md | 189 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 changelogs/3.2.1-RC1.md diff --git a/changelogs/3.2.1-RC1.md b/changelogs/3.2.1-RC1.md new file mode 100644 index 000000000000..217152fed9b2 --- /dev/null +++ b/changelogs/3.2.1-RC1.md @@ -0,0 +1,189 @@ +# Highlights of the release + +- Add experimental capture checking [#15877](https://github.com/lampepfl/dotty/pull/15877) +- Scaladoc: New UI design [#15697](https://github.com/lampepfl/dotty/pull/15697) + +# Other changes and fixes + +## Backend + +- Set ACC_FINAL access flag to final variable accessors [#15707](https://github.com/lampepfl/dotty/pull/15707) + +## Coverage + +- Avoid instrumentation of inline and erased definitions [#15504](https://github.com/lampepfl/dotty/pull/15504) + +## Erasure + +- Fix #15199: Exclude JavaDefined Modules from bridge generation. [#15499](https://github.com/lampepfl/dotty/pull/15499) + +## Extension Methods + +- Merge nested polytypes in more cases in resolveOverloaded [#15636](https://github.com/lampepfl/dotty/pull/15636) + +## GADTs + +- Fix GADT casting when typing if expressions [#15646](https://github.com/lampepfl/dotty/pull/15646) +- Use GADT constraints in maximiseType [#15544](https://github.com/lampepfl/dotty/pull/15544) +- Add the expected type to Poly's desugaring [#15570](https://github.com/lampepfl/dotty/pull/15570) +- Allow refineUsingParent to infer GADT bounds [#15706](https://github.com/lampepfl/dotty/pull/15706) +- Avoid leaking internal types in GadtConstraint.approximation [#15558](https://github.com/lampepfl/dotty/pull/15558) +- Improve GADT usage tracing for MatchType reduction [#15872](https://github.com/lampepfl/dotty/pull/15872) +- Add `gadtAddBound` to ExplainingTypeComparer tracing [#15819](https://github.com/lampepfl/dotty/pull/15819) + +## IDE Support + +- Recover from TypeErrors in isErroneous [#15442](https://github.com/lampepfl/dotty/pull/15442) +- Add a guard against empty ident [#15542](https://github.com/lampepfl/dotty/pull/15542) + +## Initialization + +- Fix #15465: Use resolveThis for outerSelect resolution [#15606](https://github.com/lampepfl/dotty/pull/15606) +- Fix #15459: Display uninitialized fields in promotion error [#15488](https://github.com/lampepfl/dotty/pull/15488) +- Fix #15363: Improve error messages for leaking of this [#15364](https://github.com/lampepfl/dotty/pull/15364) +- Make sure inner classes are checked first [#15527](https://github.com/lampepfl/dotty/pull/15527) +- Handle super accessors in initialization checker [#15703](https://github.com/lampepfl/dotty/pull/15703) + +## Inline + +- Check is inline unapply has leading implicits [#15583](https://github.com/lampepfl/dotty/pull/15583) +- Fix #15374: Make sure prefix of outer select has the correct class symbol [#15592](https://github.com/lampepfl/dotty/pull/15592) + +## Java Interoperability + +- Don't check import selectors for Java code [#15617](https://github.com/lampepfl/dotty/pull/15617) + +## JS Interoperability + +- Fix #15701: Implement js.dynamicImport for dynamic module loading. [#15720](https://github.com/lampepfl/dotty/pull/15720) +- Implement support for js.`new`.target. [#15734](https://github.com/lampepfl/dotty/pull/15734) +- Fix #14488: Scala.js: Add compiler support for scala.Enumeration. [#15770](https://github.com/lampepfl/dotty/pull/15770) + +## Match Types + +- Avoid null types when reducing match types [#15748](https://github.com/lampepfl/dotty/pull/15748) +- Avoid references to unbound parameters in applied type patterns [#15710](https://github.com/lampepfl/dotty/pull/15710) + +## Nullability + +- Fix checking ctx to carry correct modes [#15350](https://github.com/lampepfl/dotty/pull/15350) + +## Pattern Matching + +- Teach provablyDisjoint to handle FromJavaObject [#15769](https://github.com/lampepfl/dotty/pull/15769) +- Don't trust case class extractors with explicit type arguments [#15669](https://github.com/lampepfl/dotty/pull/15669) +- Space: Fix how sealed abstract classes decompose [#15553](https://github.com/lampepfl/dotty/pull/15553) +- Local classes are uncheckable (type tests) [#15134](https://github.com/lampepfl/dotty/pull/15134) +- Fix ValDef span assignment in PatternMatcher [#15783](https://github.com/lampepfl/dotty/pull/15783) +- Reject all explicitly written type references with bad bounds [#15577](https://github.com/lampepfl/dotty/pull/15577) + +## Pickling + +- Make simplify replace type parameters inside method types [#15430](https://github.com/lampepfl/dotty/pull/15430) + +## Quotes + +- Ignore types in macro runtime dependencies [#15529](https://github.com/lampepfl/dotty/pull/15529) + +## REPL + +- ReplDriver.run and :load take complete input [#15811](https://github.com/lampepfl/dotty/pull/15811) +- REPL goes through a phase [#15663](https://github.com/lampepfl/dotty/pull/15663) +- Avoid assertion failure for illegal trait inheritance [#15631](https://github.com/lampepfl/dotty/pull/15631) + +## Reporting + +- Underline assignment correctly in error message [#15584](https://github.com/lampepfl/dotty/pull/15584) +- Better error message for "implicit search must be more specific" [#15747](https://github.com/lampepfl/dotty/pull/15747) +- Provide better info on compiler crashes [#15890](https://github.com/lampepfl/dotty/pull/15890) + +## SemanticDB + +- Handle colons in file names when producing SemanticDB [#15863](https://github.com/lampepfl/dotty/pull/15863) + +## Standard Library + +- Fix `throwReturn` of `NonLocalReturns` to allow wider usage [#15495](https://github.com/lampepfl/dotty/pull/15495) + +## Tooling + +- Fix scala runner exit codes [#15604](https://github.com/lampepfl/dotty/pull/15604) +- Command line parser respects outer escaped quote [#15497](https://github.com/lampepfl/dotty/pull/15497) +- Added quotes to Scala home paths in scala and scalac scripts [#15824](https://github.com/lampepfl/dotty/pull/15824) +- Retain partial type params typying information on error [#15825](https://github.com/lampepfl/dotty/pull/15825) + +## Transform + +- Implementation restriction: No partial functions with CFT results [#15744](https://github.com/lampepfl/dotty/pull/15744) +- Fix treatment of parameter selections via this in constructors. [#15737](https://github.com/lampepfl/dotty/pull/15737) +- Fix expansion and unexpansion of mixin qualified names [#15712](https://github.com/lampepfl/dotty/pull/15712) +- Fix #15514 in Parser [#15524](https://github.com/lampepfl/dotty/pull/15524) +- Check type arguments for bad bounds [#15571](https://github.com/lampepfl/dotty/pull/15571) + +## Typer + +- Fix swapKey [#15894](https://github.com/lampepfl/dotty/pull/15894) +- Insert GADT casts for needy match types [#15851](https://github.com/lampepfl/dotty/pull/15851) +- Add missing dealias in isContextFunctionRef [#15742](https://github.com/lampepfl/dotty/pull/15742) +- Look for synthetic applies also under type applications [#15572](https://github.com/lampepfl/dotty/pull/15572) +- Optimize isSameType for invariant applied types with the same structure [#15556](https://github.com/lampepfl/dotty/pull/15556) +- Fix cycle detection for type aliases with wildcard arguments [#15508](https://github.com/lampepfl/dotty/pull/15508) +- Handle recursions in isFullyDefined [#15443](https://github.com/lampepfl/dotty/pull/15443) +- Do level checking on instantiation [#15746](https://github.com/lampepfl/dotty/pull/15746) +- Use fullyDefinedType for mirror synthesis [#15814](https://github.com/lampepfl/dotty/pull/15814) +- Instantiate more type variables to hard unions [#15632](https://github.com/lampepfl/dotty/pull/15632) +- Simplify level fixing scheme [#15936](https://github.com/lampepfl/dotty/pull/15936) +- Don't normalize in `AppliedType#superType` [#15453](https://github.com/lampepfl/dotty/pull/15453) +- Try promotion while widening arguments [#15467](https://github.com/lampepfl/dotty/pull/15467) +- Check import selectors at Typer [#15477](https://github.com/lampepfl/dotty/pull/15477) +- Turn some calls to `underlying` into `superType`. [#15455](https://github.com/lampepfl/dotty/pull/15455) +- Find more looping implicits [#15481](https://github.com/lampepfl/dotty/pull/15481) +- Fix `findFunctionType` for `OrTypes` [#15478](https://github.com/lampepfl/dotty/pull/15478) +- Fix looping implicits check [#15655](https://github.com/lampepfl/dotty/pull/15655) +- Try to avoid static symbols if leaving them would make a leak [#15548](https://github.com/lampepfl/dotty/pull/15548) +- Do not fold `IsConst` applied to dependent parameters [#15759](https://github.com/lampepfl/dotty/pull/15759) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.1.3..3.2.0` these are: + +``` + 204 Martin Odersky + 94 Filip Łukasik + 69 Fengyun Liu + 57 Filip Zybała + 31 Dale Wijnand + 14 Sébastien Doeraene + 10 Guillaume Raffin + 9 rochala + 8 Chris Kipp + 8 Paweł Marks + 8 Som Snytt + 7 Jędrzej Rochala + 7 Nicolas Stucki + 7 Yichen Xu + 6 Jamie Thompson + 6 Tom Grigg + 5 noti0na1 + 2 Arman Bilge + 2 Kacper Korban + 2 Matt Bovel + 2 Ondrej Lhotak + 2 Quentin Bernet + 2 Tomasz Godzik + 1 Adrien Piquerez + 1 Florian3k + 1 Gagandeep Kalra + 1 Jentsch + 1 Kieren Davies + 1 Michał Pałka + 1 Naveen + 1 Oron Port + 1 Rubin Simons + 1 Seth Tisue + 1 Wojciech Mazur + 1 esteban marin + 1 naveen +``` From 8d966d71ca2475bc827bdbc61751ffe521de289e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 1 Sep 2022 16:40:55 +0200 Subject: [PATCH 02/34] Release 3.2.1-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 03df624aefcd295a563938e61733540921cc18cd Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Mon, 5 Sep 2022 00:35:37 +0200 Subject: [PATCH 03/34] Only look for synthetic applies under TypeApply with inferred arguments fixes lampepfl#15969 --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/pos/i15969.scala | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15969.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index d802ef0df973..4c6875ddace3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -105,7 +105,7 @@ object Typer { */ private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match { case tree: tpd.Select => tree.hasAttachment(InsertedApply) - case TypeApply(fn, _) => isSyntheticApply(fn) + case TypeApply(fn, targs) if targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) => isSyntheticApply(fn) case _ => false } diff --git a/tests/pos/i15969.scala b/tests/pos/i15969.scala new file mode 100644 index 000000000000..827f3ae1f233 --- /dev/null +++ b/tests/pos/i15969.scala @@ -0,0 +1,7 @@ +object Obj { + def apply[L]: Unit = ??? + + extension (make: Unit) def apply(value: Int): String = ??? + + def test: String = Obj[Int](1) +} From 6a7a9fa0f0f6ce43f3c0fde10b144fdc7f941f0f Mon Sep 17 00:00:00 2001 From: Kacper Korban <39772805+KacperFKorban@users.noreply.github.com> Date: Mon, 5 Sep 2022 11:25:42 +0200 Subject: [PATCH 04/34] Combine conditions for TypeApply in isSyntheticApply Co-authored-by: odersky --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 4c6875ddace3..dd3e6f2ee8ca 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -105,7 +105,7 @@ object Typer { */ private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match { case tree: tpd.Select => tree.hasAttachment(InsertedApply) - case TypeApply(fn, targs) if targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) => isSyntheticApply(fn) + case TypeApply(fn, targs) => isSyntheticApply(fn) && targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) case _ => false } From d9707aacd8f5895a90a6b9b2902d0180b98b24ff Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 8 Sep 2022 18:09:02 +0200 Subject: [PATCH 05/34] Better diagnostics for too unspecific implicit searches Fixes #15998 --- .../tools/dotc/typer/ErrorReporting.scala | 11 +++--- .../dotty/tools/dotc/typer/Implicits.scala | 11 +++--- tests/neg/i15998.check | 36 +++++++++++++++++++ tests/neg/i15998.scala | 21 +++++++++++ 4 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 tests/neg/i15998.check create mode 100644 tests/neg/i15998.scala diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala index 3c92a217206d..dbb35c0ab761 100644 --- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -125,25 +125,25 @@ object ErrorReporting { def typeMismatch(tree: Tree, pt: Type, implicitFailure: SearchFailureType = NoMatchingImplicits): Tree = { val normTp = normalize(tree.tpe, pt) val normPt = normalize(pt, pt) - + def contextFunctionCount(tp: Type): Int = tp.stripped match case defn.ContextFunctionType(_, restp, _) => 1 + contextFunctionCount(restp) case _ => 0 def strippedTpCount = contextFunctionCount(tree.tpe) - contextFunctionCount(normTp) def strippedPtCount = contextFunctionCount(pt) - contextFunctionCount(normPt) - + val (treeTp, expectedTp) = if normTp <:< normPt || strippedTpCount != strippedPtCount then (tree.tpe, pt) else (normTp, normPt) // use normalized types if that also shows an error, and both sides stripped // the same number of context functions. Use original types otherwise. - + def missingElse = tree match case If(_, _, elsep @ Literal(Constant(()))) if elsep.span.isSynthetic => "\nMaybe you are missing an else part for the conditional?" case _ => "" - + errorTree(tree, TypeMismatch(treeTp, expectedTp, Some(tree), implicitFailure.whyNoConversion, missingElse)) } @@ -262,6 +262,9 @@ class ImplicitSearchError( case _ => defaultAmbiguousImplicitMsg(ambi) } + case ambi @ TooUnspecific(target) => + ex"""No implicit search was attempted${location("for")} + |since the expected type $target is too unspecific""" case _ => val shortMessage = userDefinedImplicitNotFoundParamMessage .orElse(userDefinedImplicitNotFoundTypeMessage) diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index ac86702ac588..ede44c2b7f86 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -411,14 +411,14 @@ object Implicits: /** A failed search */ case class SearchFailure(tree: Tree) extends SearchResult { - final def isAmbiguous: Boolean = tree.tpe.isInstanceOf[AmbiguousImplicits] + final def isAmbiguous: Boolean = tree.tpe.isInstanceOf[AmbiguousImplicits | TooUnspecific] final def reason: SearchFailureType = tree.tpe.asInstanceOf[SearchFailureType] } object SearchFailure { def apply(tpe: SearchFailureType, span: Span)(using Context): SearchFailure = { val id = tpe match - case tpe: AmbiguousImplicits => + case tpe: (AmbiguousImplicits | TooUnspecific) => untpd.SearchFailureIdent(nme.AMBIGUOUS, s"/* ambiguous: ${tpe.explanation} */") case _ => untpd.SearchFailureIdent(nme.MISSING, "/* missing */") @@ -504,11 +504,14 @@ object Implicits: SearchFailure(ImplicitSearchTooLarge, NoSpan)(using NoContext) /** A failure value indicating that an implicit search for a conversion was not tried */ - class TooUnspecific(target: Type) extends NoMatchingImplicits(NoType, EmptyTree, OrderingConstraint.empty): + case class TooUnspecific(target: Type) extends NoMatchingImplicits(NoType, EmptyTree, OrderingConstraint.empty): override def whyNoConversion(using Context): String = i""" |Note that implicit conversions were not tried because the result of an implicit conversion |must be more specific than $target""" + override def explanation(using Context) = + i"""${super.explanation}. + |The expected type $target is not specific enough, so no search was attempted""" override def toString = s"TooUnspecific" /** An ambiguous implicits failure */ @@ -1484,7 +1487,7 @@ trait Implicits: private def searchImplicit(contextual: Boolean): SearchResult = if isUnderspecified(wildProto) then - NoMatchingImplicitsFailure + SearchFailure(TooUnspecific(pt), span) else val eligible = if contextual then diff --git a/tests/neg/i15998.check b/tests/neg/i15998.check new file mode 100644 index 000000000000..6e0e402ad92b --- /dev/null +++ b/tests/neg/i15998.check @@ -0,0 +1,36 @@ +-- [E007] Type Mismatch Error: tests/neg/i15998.scala:11:23 ------------------------------------------------------------ +11 | RingSeq.isRotationOf("DAB") // error + | ^^^^^ + | Found: ("DAB" : String) + | Required: CC[A] + | + | where: A is a type variable + | CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]] + | + | Note that implicit conversions were not tried because the result of an implicit conversion + | must be more specific than CC[A] + | + | longer explanation available when compiling with `-explain` +-- [E008] Not Found Error: tests/neg/i15998.scala:12:9 ----------------------------------------------------------------- +12 | "ABCD".isRotationOf("DAB") // error + | ^^^^^^^^^^^^^^^^^^^ + | value isRotationOf is not a member of String. + | An extension method was tried, but could not be fully constructed: + | + | RingSeq.isRotationOf[A, CC]("ABCD") failed with + | + | Found: ("ABCD" : String) + | Required: CC[A] + | + | where: A is a type variable + | CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]] + | + | Note that implicit conversions were not tried because the result of an implicit conversion + | must be more specific than CC[A] +-- Error: tests/neg/i15998.scala:21:13 --------------------------------------------------------------------------------- +21 | val x = foo // error + | ^ + | No implicit search was attempted for parameter x of method foo + | since the expected type X is too unspecific + | + | where: X is a type variable diff --git a/tests/neg/i15998.scala b/tests/neg/i15998.scala new file mode 100644 index 000000000000..6535f2b9ef84 --- /dev/null +++ b/tests/neg/i15998.scala @@ -0,0 +1,21 @@ +import scala.collection.SeqOps + +trait ComparingOps: + extension[A, CC[B] <: SeqOps[B, CC, CC[B]]](ring: CC[A]) + def isRotationOf(that: CC[A]): Boolean = ??? + +object RingSeq extends ComparingOps +import RingSeq.* + +@main def Test = + RingSeq.isRotationOf("DAB") // error + "ABCD".isRotationOf("DAB") // error + + // workaround + RingSeq.isRotationOf[Char, IndexedSeq]("DAB") + RingSeq.isRotationOf(wrapString("DAB")) + wrapString("ABCD").isRotationOf("DAB") + + def foo[X](using x: X): X = x + + val x = foo // error From 8472f5b2309de62a68086b96e051d1744b3db636 Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 8 Sep 2022 23:17:34 +0200 Subject: [PATCH 06/34] Better wildcard approximations of higher-kinded applications --- .../tools/dotc/typer/ErrorReporting.scala | 2 +- .../dotty/tools/dotc/typer/ProtoTypes.scala | 13 +++-- tests/neg/i15998.check | 54 +++++++------------ tests/neg/i15998.scala | 20 ++----- tests/run/i13986.scala | 15 ++++++ tests/{neg => run}/i13987.scala | 4 +- tests/run/i15998.scala | 17 ++++++ 7 files changed, 68 insertions(+), 57 deletions(-) create mode 100644 tests/run/i13986.scala rename tests/{neg => run}/i13987.scala (84%) create mode 100644 tests/run/i15998.scala diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala index dbb35c0ab761..cdd37a2f0be7 100644 --- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -264,7 +264,7 @@ class ImplicitSearchError( } case ambi @ TooUnspecific(target) => ex"""No implicit search was attempted${location("for")} - |since the expected type $target is too unspecific""" + |since the expected type $target is not specific enough""" case _ => val shortMessage = userDefinedImplicitNotFoundParamMessage .orElse(userDefinedImplicitNotFoundTypeMessage) diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 71b500dc04a9..8dff12d82637 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -822,17 +822,22 @@ object ProtoTypes { /** Approximate occurrences of parameter types and uninstantiated typevars * by wildcard types. */ - private def wildApprox(tp: Type, theMap: WildApproxMap | Null, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = tp match { + private def wildApprox(tp: Type, theMap: WildApproxMap | Null, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = + tp match { case tp: NamedType => // default case, inlined for speed val isPatternBoundTypeRef = tp.isInstanceOf[TypeRef] && tp.symbol.isPatternBound if (isPatternBoundTypeRef) WildcardType(tp.underlying.bounds) else if (tp.symbol.isStatic || (tp.prefix `eq` NoPrefix)) tp else tp.derivedSelect(wildApprox(tp.prefix, theMap, seen, internal)) case tp @ AppliedType(tycon, args) => + def wildArgs = args.mapConserve(arg => wildApprox(arg, theMap, seen, internal)) wildApprox(tycon, theMap, seen, internal) match { - case _: WildcardType => WildcardType // this ensures we get a * type - case tycon1 => tp.derivedAppliedType(tycon1, - args.mapConserve(arg => wildApprox(arg, theMap, seen, internal))) + case WildcardType(TypeBounds(lo, hi)) if hi.typeParams.hasSameLengthAs(args) => + val lo1 = if lo.typeParams.hasSameLengthAs(args) then lo.appliedTo(wildArgs) else lo + WildcardType(TypeBounds(lo1, hi.appliedTo(wildArgs))) + case WildcardType(_) => + WildcardType + case tycon1 => tp.derivedAppliedType(tycon1, wildArgs) } case tp: RefinedType => // default case, inlined for speed tp.derivedRefinedType( diff --git a/tests/neg/i15998.check b/tests/neg/i15998.check index 6e0e402ad92b..c745c7a84309 100644 --- a/tests/neg/i15998.check +++ b/tests/neg/i15998.check @@ -1,36 +1,20 @@ --- [E007] Type Mismatch Error: tests/neg/i15998.scala:11:23 ------------------------------------------------------------ -11 | RingSeq.isRotationOf("DAB") // error - | ^^^^^ - | Found: ("DAB" : String) - | Required: CC[A] +-- [E007] Type Mismatch Error: tests/neg/i15998.scala:6:12 ------------------------------------------------------------- +6 |val _ = foo(1) // error + | ^ + | Found: (1 : Int) + | Required: CC[A] + | + | where: A is a type variable + | CC is a type variable with constraint <: [B] =>> Any + | + | Note that implicit conversions were not tried because the result of an implicit conversion + | must be more specific than CC[A] + | + | longer explanation available when compiling with `-explain` +-- Error: tests/neg/i15998.scala:11:11 --------------------------------------------------------------------------------- +11 |val _ = bar // error + | ^ + | No implicit search was attempted for parameter x of method bar + | since the expected type X is not specific enough | - | where: A is a type variable - | CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]] - | - | Note that implicit conversions were not tried because the result of an implicit conversion - | must be more specific than CC[A] - | - | longer explanation available when compiling with `-explain` --- [E008] Not Found Error: tests/neg/i15998.scala:12:9 ----------------------------------------------------------------- -12 | "ABCD".isRotationOf("DAB") // error - | ^^^^^^^^^^^^^^^^^^^ - | value isRotationOf is not a member of String. - | An extension method was tried, but could not be fully constructed: - | - | RingSeq.isRotationOf[A, CC]("ABCD") failed with - | - | Found: ("ABCD" : String) - | Required: CC[A] - | - | where: A is a type variable - | CC is a type variable with constraint <: [B] =>> collection.SeqOps[B, CC, CC[B]] - | - | Note that implicit conversions were not tried because the result of an implicit conversion - | must be more specific than CC[A] --- Error: tests/neg/i15998.scala:21:13 --------------------------------------------------------------------------------- -21 | val x = foo // error - | ^ - | No implicit search was attempted for parameter x of method foo - | since the expected type X is too unspecific - | - | where: X is a type variable + | where: X is a type variable diff --git a/tests/neg/i15998.scala b/tests/neg/i15998.scala index 6535f2b9ef84..964e795fdfca 100644 --- a/tests/neg/i15998.scala +++ b/tests/neg/i15998.scala @@ -1,21 +1,11 @@ -import scala.collection.SeqOps -trait ComparingOps: - extension[A, CC[B] <: SeqOps[B, CC, CC[B]]](ring: CC[A]) - def isRotationOf(that: CC[A]): Boolean = ??? +given split: Conversion[Int, List[Int]] = ??? -object RingSeq extends ComparingOps -import RingSeq.* +def foo[A, CC[B]](ring: CC[A]): Unit = () -@main def Test = - RingSeq.isRotationOf("DAB") // error - "ABCD".isRotationOf("DAB") // error +val _ = foo(1) // error - // workaround - RingSeq.isRotationOf[Char, IndexedSeq]("DAB") - RingSeq.isRotationOf(wrapString("DAB")) - wrapString("ABCD").isRotationOf("DAB") - def foo[X](using x: X): X = x +def bar[X](using x: X): X = x - val x = foo // error +val _ = bar // error diff --git a/tests/run/i13986.scala b/tests/run/i13986.scala new file mode 100644 index 000000000000..e881a7e1486f --- /dev/null +++ b/tests/run/i13986.scala @@ -0,0 +1,15 @@ +package example + +sealed trait Xa[T] +sealed trait Mu[T] extends Xa[T] +object Xa { + implicit def convertMu[X[x] <: Xa[x], A, B](implicit t: X[A]): X[B] = t.asInstanceOf[X[B]] +} +object Mu { + implicit def mu: Mu[Int] = new Mu[Int] {} +} + +object Test extends App { + def constrain(a: Mu[Long]): Unit = () + constrain(Xa.convertMu) +} \ No newline at end of file diff --git a/tests/neg/i13987.scala b/tests/run/i13987.scala similarity index 84% rename from tests/neg/i13987.scala rename to tests/run/i13987.scala index b27cd444cda6..7ddaa69f0653 100644 --- a/tests/neg/i13987.scala +++ b/tests/run/i13987.scala @@ -10,7 +10,7 @@ object Mu { implicit def mu: Mu[Int] = new Mu[Int] {} } -object App extends App { - def constrain(a: Mu[Long]): Unit = println(a) +object Test extends App { + def constrain(a: Mu[Long]): Unit = () constrain(Xa.convertMu) // error } \ No newline at end of file diff --git a/tests/run/i15998.scala b/tests/run/i15998.scala new file mode 100644 index 000000000000..2e1ff697b433 --- /dev/null +++ b/tests/run/i15998.scala @@ -0,0 +1,17 @@ +import scala.collection.SeqOps + +trait ComparingOps: + extension[A, CC[B] <: SeqOps[B, CC, CC[B]]](ring: CC[A]) + def isRotationOf(that: CC[A]): Boolean = true + +object RingSeq extends ComparingOps +import RingSeq.* + +@main def Test = + RingSeq.isRotationOf("DAB") // error + "ABCD".isRotationOf("DAB") // error + + // workaround + RingSeq.isRotationOf[Char, IndexedSeq]("DAB") + RingSeq.isRotationOf(wrapString("DAB")) + wrapString("ABCD").isRotationOf("DAB") From 9c868c656c6b431b8d4ff49aa999b3ba806e9fbb Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 9 Sep 2022 09:04:17 +0200 Subject: [PATCH 07/34] Fix test --- tests/run/i13986.check | 1 + tests/run/i13986.scala | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 tests/run/i13986.check diff --git a/tests/run/i13986.check b/tests/run/i13986.check new file mode 100644 index 000000000000..92cfbd63ad69 --- /dev/null +++ b/tests/run/i13986.check @@ -0,0 +1 @@ +mu diff --git a/tests/run/i13986.scala b/tests/run/i13986.scala index e881a7e1486f..16f79622e92e 100644 --- a/tests/run/i13986.scala +++ b/tests/run/i13986.scala @@ -1,15 +1,15 @@ -package example - sealed trait Xa[T] sealed trait Mu[T] extends Xa[T] object Xa { implicit def convertMu[X[x] <: Xa[x], A, B](implicit t: X[A]): X[B] = t.asInstanceOf[X[B]] } object Mu { - implicit def mu: Mu[Int] = new Mu[Int] {} + implicit def mu: Mu[Int] = new Mu[Int] { + override def toString = "mu" + } } object Test extends App { - def constrain(a: Mu[Long]): Unit = () + def constrain(a: Mu[Long]): Unit = println(a) constrain(Xa.convertMu) } \ No newline at end of file From db09d12aa8755451a15fb0934defdd7b4177de8a Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 9 Sep 2022 10:52:16 +0200 Subject: [PATCH 08/34] More tests that work now --- tests/pos/i15160.scala | 17 +++++++++++++++++ tests/pos/i15670.scala | 29 +++++++++++++++++++++++++++++ tests/pos/i15820.scala | 8 ++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/pos/i15160.scala create mode 100644 tests/pos/i15670.scala create mode 100644 tests/pos/i15820.scala diff --git a/tests/pos/i15160.scala b/tests/pos/i15160.scala new file mode 100644 index 000000000000..cc55e0f5fb19 --- /dev/null +++ b/tests/pos/i15160.scala @@ -0,0 +1,17 @@ +trait Eq[A] { + def eqv(a1: A, a2: A): Boolean +} + +given stringEq: Eq[String] with { + def eqv(a1: String, a2: String) = a1 == a2 +} + +abstract class Newtype[Src] { + opaque type Type = Src + + protected final def derive[F[_]](using ev: F[Src]): F[Type] = ev +} + +object Sample extends Newtype[String] { + given eq: Eq[Type] = derive +} \ No newline at end of file diff --git a/tests/pos/i15670.scala b/tests/pos/i15670.scala new file mode 100644 index 000000000000..b46b3708fe4e --- /dev/null +++ b/tests/pos/i15670.scala @@ -0,0 +1,29 @@ +trait JsonRowEntry { + def readAs[E](implicit c: Read[E]): Option[E] = ??? +} +trait Read[T] +trait Codec[T] extends Read[T] +trait CodecTypeProjection[C[_]] +object JsonTransform { + given SetCodec[T, C[_]: CodecTypeProjection]: scala.Conversion[C[T], C[Set[T]]] = ??? + given SetCodecExp[T, C[_]: CodecTypeProjection](using codec: C[T]): C[Set[T]] = codec + given Codec[String] = ??? + given CodecTypeProjection[Read] = ??? +} + +@main def Test() = { + import JsonTransform.given + val tree = new JsonRowEntry {} + tree.readAs[Set[String]] +} + +trait Box[E] + +trait Domain + +def fun[E, D[_] <: Domain](box: Box[E])(implicit domain: D[E]): Unit = { + + val newBox: Box[E] = ??? + + fun(newBox) +} diff --git a/tests/pos/i15820.scala b/tests/pos/i15820.scala new file mode 100644 index 000000000000..4425760ffe3c --- /dev/null +++ b/tests/pos/i15820.scala @@ -0,0 +1,8 @@ +sealed trait Domain[E] + +final def splitBounds[E, D[X] <: Domain[X]]( + bounds: Seq[E], + )( using domain: D[E]): Seq[E] = + val newBounds: Seq[E] = ??? + splitBounds(newBounds) // does not compile + splitBounds[E,D](newBounds) // does compile \ No newline at end of file From a451baa0936d8df991483a4e55affc905a41f4f8 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 9 Sep 2022 14:13:01 +0200 Subject: [PATCH 09/34] Update compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala Co-authored-by: Guillaume Martres --- compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 8dff12d82637..b53ef28dc8f7 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -833,8 +833,9 @@ object ProtoTypes { def wildArgs = args.mapConserve(arg => wildApprox(arg, theMap, seen, internal)) wildApprox(tycon, theMap, seen, internal) match { case WildcardType(TypeBounds(lo, hi)) if hi.typeParams.hasSameLengthAs(args) => - val lo1 = if lo.typeParams.hasSameLengthAs(args) then lo.appliedTo(wildArgs) else lo - WildcardType(TypeBounds(lo1, hi.appliedTo(wildArgs))) + val args1 = wildArgs + val lo1 = if lo.typeParams.hasSameLengthAs(args) then lo.appliedTo(args1) else lo + WildcardType(TypeBounds(lo1, hi.appliedTo(args1))) case WildcardType(_) => WildcardType case tycon1 => tp.derivedAppliedType(tycon1, wildArgs) From b6c2c48a0e0fdabf7dd32f4e70d9953b32bef795 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 2 Sep 2022 11:52:39 +0200 Subject: [PATCH 10/34] Better types for class type parameters If we see a class type parameter that has a wildcard argument, we now intersect the original info of the class type parameter and the argument. Previously we replaced the class type parameter info with the argument info, but that might lose information. Fixes #15940 --- .../dotty/tools/dotc/core/Denotations.scala | 2 +- tests/pos/i15940.scala | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15940.scala diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index 61dd71603f64..8a60003258b0 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -1120,7 +1120,7 @@ object Denotations { then this else if symbol.isAllOf(ClassTypeParam) then val arg = symbol.typeRef.argForParam(pre, widenAbstract = true) - if arg.exists then derivedSingleDenotation(symbol, arg.bounds, pre) + if arg.exists then derivedSingleDenotation(symbol, symbol.info.bounds & arg.bounds, pre) else derived(symbol.info) else derived(symbol.info) } diff --git a/tests/pos/i15940.scala b/tests/pos/i15940.scala new file mode 100644 index 000000000000..e460367a6c03 --- /dev/null +++ b/tests/pos/i15940.scala @@ -0,0 +1,19 @@ +object Ops: + implicit class EitherSeqOps[E, T](private val seq: Seq[Either[E, T]]) extends AnyVal: + def sequence: Either[::[E], Seq[T]] = ??? + +trait BuildException +case class CompositeBuildException(ex: ::[BuildException]) extends BuildException + +trait ActionableDiagnostic +trait ActionableHandler[A <: ActionableDiagnostic]: + def exec: Either[BuildException, Seq[A]] + +import Ops._ + +val test: Either[BuildException, Seq[ActionableDiagnostic]] = + // Can be replaced with Seq[Either[BuildException, Seq[ _ <: ActionableDiagnostic]]] , but current version matches better type of missing implicit + Seq.empty[ActionableHandler[_]].map(_.exec) + .sequence + .left.map(_.head) + .map(_.flatten) // error \ No newline at end of file From 68325f6f04ed093f70e8f62aab2097a8159bc1a2 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 2 Sep 2022 15:17:34 +0200 Subject: [PATCH 11/34] Avoid cyclic references due to F-bounds --- compiler/src/dotty/tools/dotc/core/Denotations.scala | 7 ++++++- compiler/src/dotty/tools/dotc/core/Types.scala | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index 8a60003258b0..a35f4d4c20c4 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -1120,7 +1120,12 @@ object Denotations { then this else if symbol.isAllOf(ClassTypeParam) then val arg = symbol.typeRef.argForParam(pre, widenAbstract = true) - if arg.exists then derivedSingleDenotation(symbol, symbol.info.bounds & arg.bounds, pre) + if arg.exists then + val newBounds = + if symbol.isCompleted && !symbol.info.containsLazyRefs + then symbol.info.bounds & arg.bounds + else arg.bounds + derivedSingleDenotation(symbol, newBounds, pre) else derived(symbol.info) else derived(symbol.info) } diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 0df3fa368d5a..0c98cd789371 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -442,6 +442,14 @@ object Types { final def containsWildcardTypes(using Context) = existsPart(_.isInstanceOf[WildcardType], StopAt.Static, forceLazy = false) + /** Does this type contain LazyRef types? */ + final def containsLazyRefs(using Context) = + val acc = new TypeAccumulator[Boolean]: + def apply(x: Boolean, tp: Type): Boolean = tp match + case _: LazyRef => true + case _ => x || foldOver(x, tp) + acc(false, this) + // ----- Higher-order combinators ----------------------------------- /** Returns true if there is a part of this type that satisfies predicate `p`. From 97f6078a1eb237c9e5bd55c53c5b284020734796 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Sun, 4 Sep 2022 15:26:22 +0200 Subject: [PATCH 12/34] Avoid adding NoSymbol to gadt constraints in TypeOps.instantiateToSubType fixes lampepfl#15964 --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 2 +- tests/pos/i15964.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15964.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 35afab770259..dfdd66734cf9 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -854,7 +854,7 @@ object TypeOps: val getAbstractSymbols = new TypeAccumulator[List[Symbol]]: def apply(xs: List[Symbol], tp: Type) = tp.dealias match - case tp: TypeRef if !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp) + case tp: TypeRef if tp.symbol.exists && !tp.symbol.isClass => foldOver(tp.symbol :: xs, tp) case tp => foldOver(xs, tp) val syms2 = getAbstractSymbols(Nil, tp2).reverse if syms2.nonEmpty then ctx.gadt.addToConstraint(syms2) diff --git a/tests/pos/i15964.scala b/tests/pos/i15964.scala new file mode 100644 index 000000000000..5713f19e4419 --- /dev/null +++ b/tests/pos/i15964.scala @@ -0,0 +1,16 @@ +// scalac: -Werror +sealed trait T +class C extends T + +class AClass +type AType = AClass { + type TypeMember <: T +} + +def list2Product( + atype: AType, + opt: atype.TypeMember +): Unit = + opt match { + case _: C => () + } From 126856c70960395c585ad0e84346ac9d50fccf19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 15 Sep 2022 19:30:51 +0200 Subject: [PATCH 13/34] Add changelog for 3.2.1-RC2 --- changelogs/3.2.1-RC2.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 changelogs/3.2.1-RC2.md diff --git a/changelogs/3.2.1-RC2.md b/changelogs/3.2.1-RC2.md new file mode 100644 index 000000000000..5242481120d6 --- /dev/null +++ b/changelogs/3.2.1-RC2.md @@ -0,0 +1,18 @@ +# Backported fixes + +- Only look for synthetic applies under `TypeApply` with inferred arguments [#15970](https://github.com/lampepfl/dotty/pull/15970) +- Improvements for implicit searches with top-level type variables [#16001](https://github.com/lampepfl/dotty/pull/16001) +- Better types for class type parameters [#15951](https://github.com/lampepfl/dotty/pull/15951) +- Avoid adding `NoSymbol` to gadt constraints in `TypeOps.instantiateToSubType` [#15965](https://github.com/lampepfl/dotty/pull/15965) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.1-RC1..3.2.1-RC2` these are: + +``` + 7 Martin Odersky + 3 Kacper Korban + 2 Paweł Marks +``` From 8ccb2e39f205abf1f8f0e67ef9e3fc62ffd5d281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 15 Sep 2022 19:32:20 +0200 Subject: [PATCH 14/34] Release 3.2.1-RC2 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index bd467b14666d..4175751ca4ab 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.0" - val baseVersion = "3.2.1-RC1" + val baseVersion = "3.2.1-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.0" + val previousDottyVersion = "3.2.1-RC1" object CompatMode { final val BinaryCompatible = 0 From 11d71144d3059bcc0a07c04fcd2e880af8836ac8 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 19 Sep 2022 12:06:01 +0200 Subject: [PATCH 15/34] Be even more careful when combining argument and info bounds in `computeAsSeenFrom` --- compiler/src/dotty/tools/dotc/core/Denotations.scala | 8 ++++++-- tests/pos/i16049.scala | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i16049.scala diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index a35f4d4c20c4..4366515b8ce3 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -1121,9 +1121,13 @@ object Denotations { else if symbol.isAllOf(ClassTypeParam) then val arg = symbol.typeRef.argForParam(pre, widenAbstract = true) if arg.exists then + // take the argument bounds, but intersect with the symbols bounds if + // this forces nothing and gives a non-empty type. val newBounds = - if symbol.isCompleted && !symbol.info.containsLazyRefs - then symbol.info.bounds & arg.bounds + if symbol.isCompleted && !symbol.info.containsLazyRefs then + val combined @ TypeBounds(lo, hi) = symbol.info.bounds & arg.bounds + if lo frozen_<:< hi then combined + else arg.bounds else arg.bounds derivedSingleDenotation(symbol, newBounds, pre) else derived(symbol.info) diff --git a/tests/pos/i16049.scala b/tests/pos/i16049.scala new file mode 100644 index 000000000000..8cb84eb7f217 --- /dev/null +++ b/tests/pos/i16049.scala @@ -0,0 +1,10 @@ +trait BatchDiffFunction[T] + +abstract class FirstOrderMinimizer[T, DF <: BatchDiffFunction[T]]: + type State = FirstOrderMinimizer.State[T] + +object FirstOrderMinimizer: + case class State[+T](x: T) + + class OptParams: + def iterations[T](init: T): Iterator[FirstOrderMinimizer[T, BatchDiffFunction[T]]#State] = ??? \ No newline at end of file From cf888c4dfd2feb29846a0564fd5f41a33d11b985 Mon Sep 17 00:00:00 2001 From: odersky Date: Tue, 20 Sep 2022 16:31:09 +0200 Subject: [PATCH 16/34] Regression test for #16076 --- tests/pos/i16076.scala | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/pos/i16076.scala diff --git a/tests/pos/i16076.scala b/tests/pos/i16076.scala new file mode 100644 index 000000000000..8347f0094a2c --- /dev/null +++ b/tests/pos/i16076.scala @@ -0,0 +1,9 @@ +trait Column[V] +trait ColumnPath + +trait ColumnFactory[V, C <: Column[V]]: + def apply(columnPath: ColumnPath): C + +object ColumnFactory: + private def apply[V, C <: Column[V]](f: String => C): ColumnFactory[V, C] = + columnPath => f(columnPath.toString()) From d742bacd6b66825d6e4b2cd54f1b52b47df3b8c3 Mon Sep 17 00:00:00 2001 From: odersky Date: Tue, 27 Sep 2022 13:03:37 +0200 Subject: [PATCH 17/34] Be still more careful when computing denotations of class parameters Be still more careful when intersecting info and arguments of a class type parameter. This is the latest installment of a never-ending story. The problem is this: Given ```scala class C[T >: L1 <: H1] { val x: T } def f(): C[? >: L2 <: H2] ``` what is the type of `f().x`? With capture conversion (an extremely tricky aspect of the type system forced on us since Java does it), the type is something like `?1.T` where `?1` is a skolem variable of type `C[? >: L2 <: H2]`. OK, but what is the underlying (widened) type of `?1.T`? We used to say it's `C[T >: L1 <: H1]`. I.e. we forgot about the actual arguments. But then we had to change untupling desugarings from defs to vals in #14816 to fix #14783 and it turned out that was not good enough, we needed the information of the actual arguments, i.e. the type should be `C[T >: L2 <: H2]. Then something else started failing which relied on the formal arguiment bounds being preserved. So the new resolution was that the type would be the intersection of the formal parameter bounds and the actual bounds, i.e. `C[T >: L1 | L2 <: H1 & H2]`. Then there was a series of problems where _that_ failed, either because the parameter bound was F-bounded or because the intersection was an empty type. The latest installment is that the parameter bounds refer to another parameter in the same class, which requires a simultaneous substitution of all skolemized bounds for all dependent parameter references in the parameter bounds. But that's impossible or at least very hard to achieve since we are looking at the type of a single parameter after capture conversion here. So the current solution is to also back out of the intersection if there are cross-parameter references and to use just the argument bounds instead. --- .../dotty/tools/dotc/core/Denotations.scala | 33 +++++++++++++------ .../src/dotty/tools/dotc/core/Types.scala | 8 ----- tests/pos/i16105.scala | 12 +++++++ 3 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 tests/pos/i16105.scala diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index 4366515b8ce3..f267e6c85e03 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -1076,6 +1076,7 @@ object Denotations { def aggregate[T](f: SingleDenotation => T, g: (T, T) => T): T = f(this) type AsSeenFromResult = SingleDenotation + protected def computeAsSeenFrom(pre: Type)(using Context): SingleDenotation = { val symbol = this.symbol val owner = this match { @@ -1120,19 +1121,31 @@ object Denotations { then this else if symbol.isAllOf(ClassTypeParam) then val arg = symbol.typeRef.argForParam(pre, widenAbstract = true) - if arg.exists then - // take the argument bounds, but intersect with the symbols bounds if - // this forces nothing and gives a non-empty type. - val newBounds = - if symbol.isCompleted && !symbol.info.containsLazyRefs then - val combined @ TypeBounds(lo, hi) = symbol.info.bounds & arg.bounds - if lo frozen_<:< hi then combined - else arg.bounds - else arg.bounds - derivedSingleDenotation(symbol, newBounds, pre) + if arg.exists + then derivedSingleDenotation(symbol, normalizedArgBounds(arg.bounds), pre) else derived(symbol.info) else derived(symbol.info) } + + /** The argument bounds, possibly intersected with the parameter's info TypeBounds, + * if the latter is not F-bounded and does not refer to other type parameters + * of the same class, and the intersection is provably nonempty. + */ + private def normalizedArgBounds(argBounds: TypeBounds)(using Context): TypeBounds = + if symbol.isCompleted && !hasBoundsDependingOnParamsOf(symbol.owner) then + val combined @ TypeBounds(lo, hi) = symbol.info.bounds & argBounds + if (lo frozen_<:< hi) then combined + else argBounds + else argBounds + + private def hasBoundsDependingOnParamsOf(cls: Symbol)(using Context): Boolean = + val acc = new TypeAccumulator[Boolean]: + def apply(x: Boolean, tp: Type): Boolean = tp match + case _: LazyRef => true + case tp: TypeRef + if tp.symbol.isAllOf(ClassTypeParam) && tp.symbol.owner == cls => true + case _ => foldOver(x, tp) + acc(false, symbol.info) } abstract class NonSymSingleDenotation(symbol: Symbol, initInfo: Type, override val prefix: Type) extends SingleDenotation(symbol, initInfo) { diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 0c98cd789371..0df3fa368d5a 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -442,14 +442,6 @@ object Types { final def containsWildcardTypes(using Context) = existsPart(_.isInstanceOf[WildcardType], StopAt.Static, forceLazy = false) - /** Does this type contain LazyRef types? */ - final def containsLazyRefs(using Context) = - val acc = new TypeAccumulator[Boolean]: - def apply(x: Boolean, tp: Type): Boolean = tp match - case _: LazyRef => true - case _ => x || foldOver(x, tp) - acc(false, this) - // ----- Higher-order combinators ----------------------------------- /** Returns true if there is a part of this type that satisfies predicate `p`. diff --git a/tests/pos/i16105.scala b/tests/pos/i16105.scala new file mode 100644 index 000000000000..477e47e98aa7 --- /dev/null +++ b/tests/pos/i16105.scala @@ -0,0 +1,12 @@ +trait SQLSyntaxSupport[A] + +trait ResultNameSQLSyntaxProvider[S <: SQLSyntaxSupport[A], A] +trait QuerySQLSyntaxProvider[S <: SQLSyntaxSupport[A], A]{ + def resultName: ResultNameSQLSyntaxProvider[S, A] = ??? +} + +def include(syntaxProviders: QuerySQLSyntaxProvider[_, _]*) = { + syntax(syntaxProviders.map(_.resultName): _*) +} + +def syntax(resultNames: ResultNameSQLSyntaxProvider[_, _]*) = ??? \ No newline at end of file From 235f08bc901df3e7fec17de1a7c813de92fbe6d9 Mon Sep 17 00:00:00 2001 From: odersky Date: Tue, 27 Sep 2022 14:45:24 +0200 Subject: [PATCH 18/34] Fix tuple casting Was truncating tuples of size > 22 before. Fixes #16104 --- .../src/dotty/tools/dotc/typer/Typer.scala | 9 +++++---- tests/pos/i16104.scala | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/pos/i16104.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index dd3e6f2ee8ca..fbdbd3df5580 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3961,10 +3961,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer else tree else if tree.tpe.derivesFrom(defn.PairClass) && !defn.isTupleNType(tree.tpe.widenDealias) then // If this is a generic tuple we need to cast it to make the TupleN/ members accessible. - // This only works for generic tuples of know size up to 22. - defn.tupleTypes(tree.tpe.widenTermRefExpr, Definitions.MaxTupleArity) match - case Some(elems) => tree.cast(defn.tupleType(elems)) - case None => tree + // This works only for generic tuples of known size up to 22. + defn.tupleTypes(tree.tpe.widenTermRefExpr) match + case Some(elems) if elems.length <= Definitions.MaxTupleArity => + tree.cast(defn.tupleType(elems)) + case _ => tree else tree // other adaptations for selections are handled in typedSelect case _ if ctx.mode.is(Mode.ImplicitsEnabled) && tree.tpe.isValueType => if pt.isRef(defn.AnyValClass, skipRefined = false) diff --git a/tests/pos/i16104.scala b/tests/pos/i16104.scala new file mode 100644 index 000000000000..7624d5c68a4a --- /dev/null +++ b/tests/pos/i16104.scala @@ -0,0 +1,18 @@ +trait JsonVal + +val value = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "k", "l", "m", "n", "o", "p", "q") +val tree: JsonVal = ??? + +def Case2 = { + sealed trait Write[T] + object WriteOf: + final inline def tuple[T <: Tuple]: Write[T] = ??? + + given EntryToJson[T]: scala.Conversion[T, JsonStructureEntry[T]] = ??? + class JsonStructureEntry[T](t: T): + def writeAs[X >: T](using Write[X]): util.Try[JsonVal] = ??? + + value + .writeAs(using WriteOf.tuple[String *: String *: String *: String *: String *: String *: String *: String *: String *: String *: Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *: String *: String *: String *: String *: String *: String *: String *: EmptyTuple]) + .fold(_ => ???, _ == tree) +} \ No newline at end of file From 30628ace66aa7c46e21fa0eb821073e051121d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Mon, 17 Oct 2022 16:26:22 +0200 Subject: [PATCH 19/34] Add changelog for 3.2.1-RC3 --- changelogs/3.2.1-RC3.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 changelogs/3.2.1-RC3.md diff --git a/changelogs/3.2.1-RC3.md b/changelogs/3.2.1-RC3.md new file mode 100644 index 000000000000..13a186432c97 --- /dev/null +++ b/changelogs/3.2.1-RC3.md @@ -0,0 +1,16 @@ +# Backported fixes + +- Fix tuple casting [#16113](https://github.com/lampepfl/dotty/pull/16113) +- Be even more careful when combining argument and info in `computeAsSeenFrom` [#16070](https://github.com/lampepfl/dotty/pull/16070) +- Be still more careful when computing denotations of class parameters [#16112](https://github.com/lampepfl/dotty/pull/16112) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.1-RC2..3.2.1-RC3` these are: + +``` + 4 Martin Odersky + 2 Paweł Marks +``` From 558e21d71d2bbe773d76add8e1e8864b46dcfdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Mon, 17 Oct 2022 16:15:10 +0200 Subject: [PATCH 20/34] Release 3.2.1-RC3 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 4175751ca4ab..5d19e497b2e3 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.0" - val baseVersion = "3.2.1-RC2" + val baseVersion = "3.2.1-RC3" // 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-RC1" + val previousDottyVersion = "3.2.1-RC2" object CompatMode { final val BinaryCompatible = 0 From 77b36c1518b9dab83ab57246b378eb4d3d2fb363 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 19 Sep 2022 13:48:49 -0700 Subject: [PATCH 21/34] Scala 2.13.10 (was 2.13.8) --- community-build/community-projects/play-json | 2 +- community-build/community-projects/stdLib213 | 2 +- project/Build.scala | 4 ++-- .../scaladoc/ExternalLocationProviderIntegrationTest.scala | 4 ++-- tests/neg/i11982.check | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/community-build/community-projects/play-json b/community-build/community-projects/play-json index ac0fcf24a176..356b7044ed3e 160000 --- a/community-build/community-projects/play-json +++ b/community-build/community-projects/play-json @@ -1 +1 @@ -Subproject commit ac0fcf24a17657a7ed61be34ed792d4fd8d05293 +Subproject commit 356b7044ed3efd6cf9350eb9930be6abd4906b6e diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index 2c742834cf16..986dcc160aab 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit 2c742834cf162ab89e914bbc0a8b975874a2c3c2 +Subproject commit 986dcc160aab85298f6cab0bf8dd0345497cdc01 diff --git a/project/Build.scala b/project/Build.scala index 5d19e497b2e3..aa8bcf01fd1b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -120,8 +120,8 @@ object Build { * scala-library. */ def stdlibVersion(implicit mode: Mode): String = mode match { - case NonBootstrapped => "2.13.8" - case Bootstrapped => "2.13.8" + case NonBootstrapped => "2.13.10" + case Bootstrapped => "2.13.10" } val dottyOrganization = "org.scala-lang" diff --git a/scaladoc/test/dotty/tools/scaladoc/ExternalLocationProviderIntegrationTest.scala b/scaladoc/test/dotty/tools/scaladoc/ExternalLocationProviderIntegrationTest.scala index c1fc8f8cb044..59e274749f26 100644 --- a/scaladoc/test/dotty/tools/scaladoc/ExternalLocationProviderIntegrationTest.scala +++ b/scaladoc/test/dotty/tools/scaladoc/ExternalLocationProviderIntegrationTest.scala @@ -33,7 +33,7 @@ class Scaladoc2ExternalLocationProviderIntegrationTest extends ExternalLocationP "https://www.scala-lang.org/api/current/scala/util/matching/Regex$$Match.html", "https://www.scala-lang.org/api/current/scala/Predef$.html#String", "https://www.scala-lang.org/api/current/scala/collection/immutable/Map.html", - "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#addString(b:StringBuilder,start:String,sep:String,end:String):StringBuilder", + "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#addString(b:StringBuilder,start:String,sep:String,end:String):b.type", "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#mkString(start:String,sep:String,end:String):String", "https://external.stubs/api/tests/externalStubs/$div$bslash$.html", "https://external.stubs/api/tests/externalStubs/$bslash$div$.html" @@ -67,7 +67,7 @@ class Scaladoc2LegacyExternalLocationProviderIntegrationTest extends LegacyExter "https://www.scala-lang.org/api/current/scala/util/matching/Regex$$Match.html", "https://www.scala-lang.org/api/current/scala/Predef$.html#String", "https://www.scala-lang.org/api/current/scala/collection/immutable/Map.html", - "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#addString(b:StringBuilder,start:String,sep:String,end:String):StringBuilder", + "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#addString(b:StringBuilder,start:String,sep:String,end:String):b.type", "https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#mkString(start:String,sep:String,end:String):String" ) ) diff --git a/tests/neg/i11982.check b/tests/neg/i11982.check index d18fc31d68e7..48ec252a4410 100644 --- a/tests/neg/i11982.check +++ b/tests/neg/i11982.check @@ -1,4 +1,4 @@ -- Error: tests/neg/i11982.scala:22:38 --------------------------------------------------------------------------------- 22 | val p1: ("msg", 42) = unpair[Tshape] // error: no singleton value for Any | ^ - | No singleton value available for Any. + |No singleton value available for Any; eligible singleton types for `ValueOf` synthesis include literals and stable paths. From 2aa1afe5c407a095ab16b9d3b245519083f74676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Tue, 18 Oct 2022 16:02:02 +0200 Subject: [PATCH 22/34] Add changelog for 3.2.1-RC4 --- changelogs/3.2.1-RC4.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 changelogs/3.2.1-RC4.md diff --git a/changelogs/3.2.1-RC4.md b/changelogs/3.2.1-RC4.md new file mode 100644 index 000000000000..89957185c508 --- /dev/null +++ b/changelogs/3.2.1-RC4.md @@ -0,0 +1,14 @@ +# Backported fixes + +- Update Scala 2 library dependency to 2.13.10 [#16074](https://github.com/lampepfl/dotty/pull/16074) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.1-RC3..3.2.1-RC4` these are: + +``` + 2 Paweł Marks + 1 Seth Tisue +``` From 545b6792dbd78fc9ea5c51141e1fc88b9d8fea72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Tue, 18 Oct 2022 15:54:50 +0200 Subject: [PATCH 23/34] Release 3.2.1-RC4 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index aa8bcf01fd1b..daa72e8439e7 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.0" - val baseVersion = "3.2.1-RC3" + val baseVersion = "3.2.1-RC4" // 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-RC2" + val previousDottyVersion = "3.2.1-RC3" object CompatMode { final val BinaryCompatible = 0 From 9ac8479e291ad4a80667a1c0efbed0c3002f9b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Wed, 26 Oct 2022 15:48:01 +0200 Subject: [PATCH 24/34] Add changelog for 3.2.1 --- changelogs/3.2.1.md | 198 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 changelogs/3.2.1.md diff --git a/changelogs/3.2.1.md b/changelogs/3.2.1.md new file mode 100644 index 000000000000..c0292ca6a977 --- /dev/null +++ b/changelogs/3.2.1.md @@ -0,0 +1,198 @@ +# Highlights of the release + +- Add experimental capture checking [#15877](https://github.com/lampepfl/dotty/pull/15877) +- Scaladoc: New UI design [#15697](https://github.com/lampepfl/dotty/pull/15697) + +# Other changes and fixes + +## Backend + +- Set ACC_FINAL access flag to final variable accessors [#15707](https://github.com/lampepfl/dotty/pull/15707) + +## Coverage + +- Avoid instrumentation of inline and erased definitions [#15504](https://github.com/lampepfl/dotty/pull/15504) + +## Erasure + +- Fix #15199: Exclude JavaDefined Modules from bridge generation. [#15499](https://github.com/lampepfl/dotty/pull/15499) + +## Extension Methods + +- Merge nested polytypes in more cases in resolveOverloaded [#15636](https://github.com/lampepfl/dotty/pull/15636) + +## GADTs + +- Fix GADT casting when typing if expressions [#15646](https://github.com/lampepfl/dotty/pull/15646) +- Use GADT constraints in maximiseType [#15544](https://github.com/lampepfl/dotty/pull/15544) +- Add the expected type to Poly's desugaring [#15570](https://github.com/lampepfl/dotty/pull/15570) +- Allow refineUsingParent to infer GADT bounds [#15706](https://github.com/lampepfl/dotty/pull/15706) +- Avoid leaking internal types in GadtConstraint.approximation [#15558](https://github.com/lampepfl/dotty/pull/15558) +- Improve GADT usage tracing for MatchType reduction [#15872](https://github.com/lampepfl/dotty/pull/15872) +- Add `gadtAddBound` to ExplainingTypeComparer tracing [#15819](https://github.com/lampepfl/dotty/pull/15819) +- Avoid adding `NoSymbol` to gadt constraints in `TypeOps.instantiateToSubType` [#15965](https://github.com/lampepfl/dotty/pull/15965) + +## IDE Support + +- Recover from TypeErrors in isErroneous [#15442](https://github.com/lampepfl/dotty/pull/15442) +- Add a guard against empty ident [#15542](https://github.com/lampepfl/dotty/pull/15542) + +## Initialization + +- Fix #15465: Use resolveThis for outerSelect resolution [#15606](https://github.com/lampepfl/dotty/pull/15606) +- Fix #15459: Display uninitialized fields in promotion error [#15488](https://github.com/lampepfl/dotty/pull/15488) +- Fix #15363: Improve error messages for leaking of this [#15364](https://github.com/lampepfl/dotty/pull/15364) +- Make sure inner classes are checked first [#15527](https://github.com/lampepfl/dotty/pull/15527) +- Handle super accessors in initialization checker [#15703](https://github.com/lampepfl/dotty/pull/15703) + +## Inline + +- Check is inline unapply has leading implicits [#15583](https://github.com/lampepfl/dotty/pull/15583) +- Fix #15374: Make sure prefix of outer select has the correct class symbol [#15592](https://github.com/lampepfl/dotty/pull/15592) + +## Java Interoperability + +- Don't check import selectors for Java code [#15617](https://github.com/lampepfl/dotty/pull/15617) + +## JS Interoperability + +- Fix #15701: Implement js.dynamicImport for dynamic module loading. [#15720](https://github.com/lampepfl/dotty/pull/15720) +- Implement support for js.`new`.target. [#15734](https://github.com/lampepfl/dotty/pull/15734) +- Fix #14488: Scala.js: Add compiler support for scala.Enumeration. [#15770](https://github.com/lampepfl/dotty/pull/15770) + +## Match Types + +- Avoid null types when reducing match types [#15748](https://github.com/lampepfl/dotty/pull/15748) +- Avoid references to unbound parameters in applied type patterns [#15710](https://github.com/lampepfl/dotty/pull/15710) + +## Nullability + +- Fix checking ctx to carry correct modes [#15350](https://github.com/lampepfl/dotty/pull/15350) + +## Pattern Matching + +- Teach provablyDisjoint to handle FromJavaObject [#15769](https://github.com/lampepfl/dotty/pull/15769) +- Don't trust case class extractors with explicit type arguments [#15669](https://github.com/lampepfl/dotty/pull/15669) +- Space: Fix how sealed abstract classes decompose [#15553](https://github.com/lampepfl/dotty/pull/15553) +- Local classes are uncheckable (type tests) [#15134](https://github.com/lampepfl/dotty/pull/15134) +- Fix ValDef span assignment in PatternMatcher [#15783](https://github.com/lampepfl/dotty/pull/15783) +- Reject all explicitly written type references with bad bounds [#15577](https://github.com/lampepfl/dotty/pull/15577) + +## Pickling + +- Make simplify replace type parameters inside method types [#15430](https://github.com/lampepfl/dotty/pull/15430) + +## Quotes + +- Ignore types in macro runtime dependencies [#15529](https://github.com/lampepfl/dotty/pull/15529) + +## REPL + +- ReplDriver.run and :load take complete input [#15811](https://github.com/lampepfl/dotty/pull/15811) +- REPL goes through a phase [#15663](https://github.com/lampepfl/dotty/pull/15663) +- Avoid assertion failure for illegal trait inheritance [#15631](https://github.com/lampepfl/dotty/pull/15631) + +## Reporting + +- Underline assignment correctly in error message [#15584](https://github.com/lampepfl/dotty/pull/15584) +- Better error message for "implicit search must be more specific" [#15747](https://github.com/lampepfl/dotty/pull/15747) +- Provide better info on compiler crashes [#15890](https://github.com/lampepfl/dotty/pull/15890) + +## SemanticDB + +- Handle colons in file names when producing SemanticDB [#15863](https://github.com/lampepfl/dotty/pull/15863) + +## Standard Library + +- Fix `throwReturn` of `NonLocalReturns` to allow wider usage [#15495](https://github.com/lampepfl/dotty/pull/15495) +- Update Scala 2 library dependency to 2.13.10 [#16074](https://github.com/lampepfl/dotty/pull/16074) + +## Tooling + +- Fix scala runner exit codes [#15604](https://github.com/lampepfl/dotty/pull/15604) +- Command line parser respects outer escaped quote [#15497](https://github.com/lampepfl/dotty/pull/15497) +- Added quotes to Scala home paths in scala and scalac scripts [#15824](https://github.com/lampepfl/dotty/pull/15824) +- Retain partial type params typying information on error [#15825](https://github.com/lampepfl/dotty/pull/15825) + +## Transform + +- Implementation restriction: No partial functions with CFT results [#15744](https://github.com/lampepfl/dotty/pull/15744) +- Fix treatment of parameter selections via this in constructors. [#15737](https://github.com/lampepfl/dotty/pull/15737) +- Fix expansion and unexpansion of mixin qualified names [#15712](https://github.com/lampepfl/dotty/pull/15712) +- Fix #15514 in Parser [#15524](https://github.com/lampepfl/dotty/pull/15524) +- Check type arguments for bad bounds [#15571](https://github.com/lampepfl/dotty/pull/15571) + +## Typer + +- Fix swapKey [#15894](https://github.com/lampepfl/dotty/pull/15894) +- Insert GADT casts for needy match types [#15851](https://github.com/lampepfl/dotty/pull/15851) +- Add missing dealias in isContextFunctionRef [#15742](https://github.com/lampepfl/dotty/pull/15742) +- Look for synthetic applies also under type applications [#15572](https://github.com/lampepfl/dotty/pull/15572) +- Optimize isSameType for invariant applied types with the same structure [#15556](https://github.com/lampepfl/dotty/pull/15556) +- Fix cycle detection for type aliases with wildcard arguments [#15508](https://github.com/lampepfl/dotty/pull/15508) +- Handle recursions in isFullyDefined [#15443](https://github.com/lampepfl/dotty/pull/15443) +- Do level checking on instantiation [#15746](https://github.com/lampepfl/dotty/pull/15746) +- Use fullyDefinedType for mirror synthesis [#15814](https://github.com/lampepfl/dotty/pull/15814) +- Instantiate more type variables to hard unions [#15632](https://github.com/lampepfl/dotty/pull/15632) +- Simplify level fixing scheme [#15936](https://github.com/lampepfl/dotty/pull/15936) +- Don't normalize in `AppliedType#superType` [#15453](https://github.com/lampepfl/dotty/pull/15453) +- Try promotion while widening arguments [#15467](https://github.com/lampepfl/dotty/pull/15467) +- Check import selectors at Typer [#15477](https://github.com/lampepfl/dotty/pull/15477) +- Turn some calls to `underlying` into `superType`. [#15455](https://github.com/lampepfl/dotty/pull/15455) +- Find more looping implicits [#15481](https://github.com/lampepfl/dotty/pull/15481) +- Fix `findFunctionType` for `OrTypes` [#15478](https://github.com/lampepfl/dotty/pull/15478) +- Fix looping implicits check [#15655](https://github.com/lampepfl/dotty/pull/15655) +- Try to avoid static symbols if leaving them would make a leak [#15548](https://github.com/lampepfl/dotty/pull/15548) +- Do not fold `IsConst` applied to dependent parameters [#15759](https://github.com/lampepfl/dotty/pull/15759) +- Only look for synthetic applies under `TypeApply` with inferred arguments [#15970](https://github.com/lampepfl/dotty/pull/15970) +- Improvements for implicit searches with top-level type variables [#16001](https://github.com/lampepfl/dotty/pull/16001) +- Better types for class type parameters [#15951](https://github.com/lampepfl/dotty/pull/15951) +- Fix tuple casting [#16113](https://github.com/lampepfl/dotty/pull/16113) +- Be even more careful when combining argument and info in `computeAsSeenFrom` [#16070](https://github.com/lampepfl/dotty/pull/16070) +- Be still more careful when computing denotations of class parameters [#16112](https://github.com/lampepfl/dotty/pull/16112) + +# Contributors + +Thank you to all the contributors who made this release possible 🎉 + +According to `git shortlog -sn --no-merges 3.2.0..3.2.1` these are: + +``` + 215 Martin Odersky + 94 Filip Łukasik + 69 Fengyun Liu + 57 Filip Zybała + 31 Dale Wijnand + 16 Paweł Marks + 14 Sébastien Doeraene + 10 Guillaume Raffin + 9 rochala + 8 Chris Kipp + 8 Som Snytt + 7 Jędrzej Rochala + 7 Nicolas Stucki + 7 Yichen Xu + 6 Jamie Thompson + 6 Tom Grigg + 5 Kacper Korban + 5 noti0na1 + 2 Arman Bilge + 2 Matt Bovel + 2 Ondrej Lhotak + 2 Quentin Bernet + 2 Seth Tisue + 2 Tomasz Godzik + 1 Adrien Piquerez + 1 Florian3k + 1 Gagandeep Kalra + 1 Jentsch + 1 Kieren Davies + 1 Michał Pałka + 1 Naveen + 1 Oron Port + 1 Rubin Simons + 1 Wojciech Mazur + 1 esteban marin + 1 naveen + +``` From 529ddc5ff5d696841cfaaccc11a5bb3fb3af7d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Wed, 26 Oct 2022 15:44:27 +0200 Subject: [PATCH 25/34] Release 3.2.1 --- project/Build.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index daa72e8439e7..07255d729dbe 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -82,7 +82,7 @@ object Build { val referenceVersion = "3.2.0" - val baseVersion = "3.2.1-RC4" + val baseVersion = "3.2.1" // 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-RC3" + val previousDottyVersion = "3.2.0" object CompatMode { final val BinaryCompatible = 0 From 1391a8659c65c44ad57d0705b98140c01e95035c 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 26/34] 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 3d52efa384cb..6e121e45112d 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 23c8b2a2494135a2e4fe018609e864362d98ac6b Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Tue, 8 Nov 2022 15:24:13 +0100 Subject: [PATCH 27/34] backport quicklinks fix for reference --- project/Build.scala | 10 +++++----- project/scripts/cmdScaladocTests | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 6e121e45112d..10fecfa5c49c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1901,12 +1901,12 @@ object ScaladocConfigs { Groups(true), QuickLinks( List( - "Download::https://www.scala-lang.org/download/", - "Documentation::https://docs.scala-lang.org/", - "Libraries::https://index.scala-lang.org", - "Contribute::https://www.scala-lang.org/contribute/", + "Learn::https://docs.scala-lang.org/", + "Install::https://www.scala-lang.org/download/", + "Playground::https://scastie.scala-lang.org", + "Find\u00A0A\u00A0Library::https://index.scala-lang.org", + "Community::https://www.scala-lang.org/community/", "Blog::https://www.scala-lang.org/blog/", - "Community::https://www.scala-lang.org/community/" ) ) ) diff --git a/project/scripts/cmdScaladocTests b/project/scripts/cmdScaladocTests index 37ee0bd7727c..343be777cea7 100755 --- a/project/scripts/cmdScaladocTests +++ b/project/scripts/cmdScaladocTests @@ -40,6 +40,6 @@ dist/target/pack/bin/scaladoc \ -project-footer "Copyright (c) 2002-2022, LAMP/EPFL" \ -default-template static-site-main \ -author -groups -revision main -project-version "${DOTTY_BOOTSTRAPPED_VERSION}" \ - "-quick-links:Download::https://www.scala-lang.org/download/,Documentation::https://docs.scala-lang.org/,Libraries::https://index.scala-lang.org,Contribute::https://www.scala-lang.org/contribute/,Blog::https://www.scala-lang.org/blog/,Community::https://www.scala-lang.org/community/" \ + "-quick-links:Learn::https://docs.scala-lang.org/,Install::https://www.scala-lang.org/download/,Playground::https://scastie.scala-lang.org,Find A Library::https://index.scala-lang.org,Community::https://www.scala-lang.org/community/,Blog::https://www.scala-lang.org/blog/" \ out/bootstrap/scaladoc-testcases/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/classes > "$tmp" 2>&1 || echo "generated testcases project with scripts" diff -rq "$OUT1" "scaladoc/output/testcases" From ae0c926bf92d25296b419f70524eeb2b270748ad Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Thu, 25 Aug 2022 18:31:27 +0200 Subject: [PATCH 28/34] fix doc layout for new ui --- .../_layouts/static-site-main.html | 69 +++++++------------ 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/project/resources/referenceReplacements/_layouts/static-site-main.html b/project/resources/referenceReplacements/_layouts/static-site-main.html index a9114aa455ac..f72bfdcd3b7b 100644 --- a/project/resources/referenceReplacements/_layouts/static-site-main.html +++ b/project/resources/referenceReplacements/_layouts/static-site-main.html @@ -2,59 +2,36 @@ layout: main --- -
- +
+ {{ content }} -