Skip to content

Update language reference documentation. Change shown version to 3.1.2 #15038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

pikinier20
Copy link
Contributor

I've updated the branch since I wanted to port 97493c7 there.

nicolasstucki and others added 30 commits March 22, 2022 16:54
As it was our string interpolators were taking Any values and then
trying to pattern match back their classes to try to show them nicely.
This inevitably fails for things like the opaque type FlagSet, which
interpolates as an indecipherable long number.

Now, instead, they take "Shown" arguments, for which there is an
implicit conversion in scope, given there is a Show instance for value.
I captured some desired results in some new unit test cases.

In the process a small handful of bugs were discovered, the only
particularly bad one was consuming a Iterator when the "transforms"
printer was enabled (accessorDefs), followed by an unintentional
eta-expansion of a method with a defaulted argument (showSummary).

I also lifted out the Showable and exception fallback function as an
extension method, so I could use it more broadly.

The use of WrappedResult and its `result` in `showing` was also
impacted, because the new expected Shown type was driving `result`'s
context lookup.  Fortunately I was able to continue to use WrappedResult
and `result` as defined by handling this API change inside `showing`
alone.

I wasn't, however, able to find a solution to the impact the new Shown
expected type was having on the `stripModuleClassSuffix` extension
method, sadly.

JSExportsGen is interpolating a private type, so rather than open its
access or giving it a Show instance I changed the string interpolation.

SyntaxFormatter was no longer used, since the "hl" interpolator was
dropped.
This removes the need for some of the default instances.

More importantly, this reduces the burden and boilerplate that would be
needed when introducing a new case class, without defining a Show
instance for it or extending Showable.
I added this at the last minute as a fallback, but I can't remember the
use case exactly, and it muddies the waters by mixing concerns.

Also other typo fixes and a code tweak.
It was also being used over TypeComparer.ApproxState's show extension
method (for unclear reasons), so let's avoid name confusion too.
Another win for Show/Shown over Any.
Fixes scala#2576

As the discussion in scala#2576 shows, we still have some problems with the implicitly
inserted empty parameter lists for class constructors. We do need that empty list
to support syntax like `C()` and `new C()`. But it gets in the way if a class has
using clauses. Example from the issue:
```scala
class Bar(using x: Int)(y: String)
given Int = ???
def test = new Bar("")
```
Here, an implicitly inserted `()` in front makes the last line fail. We'd need
`new Bar()("")`.

If a class has only using clauses as parameters we now insert a `()` at the end
instead of at the start. That makes the example compile.

For old-style implicit parameters we don't have a choice. We still need the `()` at
the start since otherwise we'd change the meaning of calls with explicit arguments
for the implicit parameters.
This is needed to ensure backwards Tasty compatibility
This currently fail with:

MethodType(List(y), List(TypeRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Predef),String)), TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class Bar)) (of class dotty.tools.dotc.core.Types$CachedMethodType)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1154)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1313)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1137)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1313)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$24(TreeUnpickler.scala:1138)
        at dotty.tools.tasty.TastyReader.until(TastyReader.scala:125)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1138)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1313)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:998)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats$$anonfun$1(TreeUnpickler.scala:1036)
        at dotty.tools.tasty.TastyReader.until(TastyReader.scala:125)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:1036)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:1040)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1166)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1313)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1158)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1313)
        at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.createMemberSymbol$$anonfun$1(TreeUnpickler.scala:614)
        at dotty.tools.dotc.core.Annotations$.dotty$tools$dotc$core$Annotations$$anon$2$$_$$lessinit$greater$$anonfun$1(Annotations.scala:162)
        at dotty.tools.dotc.core.Annotations$LazyBodyAnnotation.tree(Annotations.scala:150)
        at dotty.tools.dotc.typer.Inliner$.bodyToInline(Inliner.scala:53)
        at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:157)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:70)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1494)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1494)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1388)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:73)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:78)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1211)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1193)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1206)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1211)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1402)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:49)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:66)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:56)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:64)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1206)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1206)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1208)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:64)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:64)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1465)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:73)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:64)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1206)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1206)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1208)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1476)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:73)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:78)
        at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:56)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:18)
        at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:28)
TreeUnpickler assumed that a type was an abstract type if its RHS was a TypeBounds tree.
But TypeBounds trees also encode alias types, so this needs to be refined.

Fixes scala#14858
Clarify and test rules for when to suppress a newline insertion
based on indentation.

Fixes scala#12554
Now that we're not running this on every `typed` invocation, the
compilation unit tree isn't going to be a top-level TypeTree.
I'm not sure what I had hit that lead me to this exclusion, but I'm not
hitting now..
actions-user and others added 26 commits April 21, 2022 08:49
More aggressive reduction of type selection (fixes parboiled2)
We should pick the one which is better, but we mistakenly chose the
worst one instead, since I misinterpreted the ordering.
It seems like TopLevelCantBeImplicit is no longer the case as of scala#5754
And it is actually confirmed in https://github.com/lampepfl/dotty/blob/93fc41fcb624df73cc12d52b79d518a30a778a7c/tests/run/toplevel-implicits/a.b.scala#L19-L21

This commit replace the unnecessary check in from Checking.scala to
assertion and deleted the `ErrorMessage` definition for `TopLevelCantBeImplicit`.

I'm leaving the `TopLevelCantBeImplicitID` in `ErrorMessageID.scala` so
we don't screw up the error number.
refactor: TopLevel implicit is now allowed, remove unnecessary checking for toplevel implicits
Fix Scala Wart about implicit () class parameters
As Jekyll (and in extension GitHub pages) makes starting a file/folder
name with a couple characters illegal, an additional check is added for
those and problematic paths are reported.
To avoid always having "_docs" if not using -Yapi_subdirectory in url by
default in the static site, we also replace that with "docs".
Some tests concerning links were adjusted to accomodate the changes.
Example testcase for illegal jekyll chars in Scaladoc was also added.
Scaladoc: Warn about special characters in filenames according to the default Jekyll rules
Authored by Aleksander Boruch-Gruszecki.

The intent here is to start to have some more detailed information on
the implementation, even in an initially rough form that can be refined
over time.
Revert "Highlight all EBNF snippets. Add missing semicolons."
Backport changes from stable documentation branch
@pikinier20 pikinier20 requested a review from julienrf April 26, 2022 13:55
@pikinier20 pikinier20 merged commit 9370bdf into scala:language-reference-stable Apr 26, 2022
@pikinier20 pikinier20 deleted the language-reference-fix branch April 26, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.