Skip to content

[stdlib] embed the history of the scala 2 stdlib into dotty's history #23522

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
merged 8,430 commits into from
Jul 15, 2025

Conversation

hamzaremmal
Copy link
Member

In this PR, we embed the history of the scala 2 stdlib to Dotty's history.
This is the first real step into producing a fully dotty-compiled stdlib.

som-snytt and others added 30 commits December 22, 2022 11:46
Minor refactor in ListSet to foreground guards and add test
in the usual places. based on c4ca300, and verified with
`git grep -w 2022`
…gbuilder-doc

Tweak class doc for StringBuilder
…n-deprecation

Honor more deprecations under separate compilation
…r-slice

Improve check for empty vector slice
SethTisue and others added 21 commits March 5, 2025 18:39
collections Scaladoc: fix an awkward wording
The `ScalaRunTime.wrap*Array` methods are exclusively used by the
codegen for varargs. They are always called with fresh (hence
non-null) arrays that are non-empty. Therefore, the various code
paths handling `null`s and empty arrays were dead code.

This commit removes those code paths to simplify those methods and
streamline varargs call sites.
…rapping

Simplify the run-time wrappers of arrays for use in varargs.
Since 2.13, case class `hashCode` mixes in the hash code of the
`productPrefix` string. This is inconsistent with the `equals` method,
subclasses of case classes that override `productPrefix` compare
equal but have a different `hashCode`.

This commit changes `hashCode` to mix in the `productPrefix.hashCode`
statically instead of invoking `productPrefix` at runtime.

For case classes without primitive fields, the synthetic `hashCode`
invokes `ScalaRunTime._hashCode`, which mixes in the result of
`productPrefix`. To fix that, the synthetic hashCode is changed
to invoke `MurmurHash3.productHash` directly and mix in the name
to the seed statically. This works out with keeping `productHash`
forwards and backwards compatible.

The `MurmurHash3.productHash` method is deprecated / renamed to
`caseClassHash`. This method computes the same hash as the synthetic
`hashCode`, except for the corner case where a case class
(or a subclass) override the `productPrefix`. In this case, the
case class name needs to be passed manually to `caseClassHash`.
Change `scala.util.Using` to have
`scala.util.control.ControlThrowable` be suppressed by non-fatal
exceptions (`scala.util.control.NonFatal`).
Mix in the `productPrefix` hash statically in case class `hashCode`
The default implementation of `Iterable.sliding` via `Iterator.sliding`
is rather inefficient and can benefit greatly from `IndexedSeq`-specific
optimizations. The new `IndexedSeqSlidingIterator` provides a
`slice`-based implementation of the basic functionality without any of
the additional features of `GroupedIterator` (which is only exposed as a
return type in `Iterator` but not in `Iterable`).

Co-authored-by: Som Snytt <som.snytt@gmail.com>
Update Option examples to more modern style
…-doc

Find more doc vars and distinguish C from CC [ci: last-only]
Allow selector aliasing

Drill thru this selections

Reduce obsolete use of NoWarnAttachment

Use the attachment to avoid warning when the user wrote underscore;
the position will be opaque, although the fresh name is longer than
the span. For good measure, also avoid warning about fresh names.

PatVarDef members warn under -Wunused:patvars

Drop local from patvar names

No warn if patvar has public accessor

Ignore annotation params

No warn unit-valued params

No warn this is trivial

util.WeakHashSet respects load factor
Collect nowarn symbols instead of skipping them
@hamzaremmal
Copy link
Member Author

The CI currently fails because of the way we test the stdlib.
Each file is compiled separately and we rely on the classpath to contain the dependencies.
The problem is that a very specific file (scala/runtime/ScalaRunTime.scala) has some changes and dependencies to new additions that will land in scala 2.13.17.
For now, I will just filter out that file until 3.8.0 (see #23527) and undo the changes later.

Also, we will have to disable the tasty/lib test until we make sure the compiler ignores compiling AnyVal.scala

hamzaremmal added a commit that referenced this pull request Jul 15, 2025
To be able to merge #23522, we need to make some adjustments to the
tests and undo them later when the stdlib will be fully independent of
scala 2.

[skip ci]
@hamzaremmal hamzaremmal merged commit 13fd5af into main Jul 15, 2025
103 of 152 checks passed
@hamzaremmal hamzaremmal deleted the embed-stdlib branch July 15, 2025 10:02
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.