Skip to content

Commit

Permalink
chore: stdlib will copy scala.util.Sorting from Scala 2
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Feb 5, 2025
1 parent 8a3868e commit a5f2c41
Show file tree
Hide file tree
Showing 6 changed files with 493 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
assert(isModifierTag(tag))
writeByte(tag)
}
assert(!flags.is(Scala2x))
//assert(!flags.is(Scala2x))
if (flags.is(Private)) writeModTag(PRIVATE)
if (flags.is(Protected)) writeModTag(PROTECTED)
if (flags.is(Final, butNot = Module)) writeModTag(FINAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class ExtensionMethods extends MiniPhase with DenotTransformer with FullParamete
// Create extension methods, except if the class comes from Scala 2
// because it adds extension methods before pickling.
if !valueClass.is(Scala2x, butNot = Scala2Tasty) then
for (decl <- valueClass.classInfo.decls)
if isMethodWithExtension(decl) then
enterInModuleClass(createExtensionMethod(decl, moduleClassSym.symbol))
for (decl <- valueClass.classInfo.decls)
if isMethodWithExtension(decl) then
enterInModuleClass(createExtensionMethod(decl, moduleClassSym.symbol))

// Create synthetic methods to cast values between the underlying type
// and the ErasedValueType. These methods are removed in ElimErasedValueType.
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ class Namer { typer: Typer =>

tree match {
case tree: TypeDef if tree.isClassDef =>
val flags = checkFlags(tree.mods.flags)
var flags = checkFlags(tree.mods.flags)
if ctx.settings.YcompileScala2Library.value then
flags |= Scala2x | Scala2Tasty
val name = checkNoConflict(tree.name, flags.is(Private), tree.span).asTypeName
val cls =
createOrRefine[ClassSymbol](tree, name, flags, ctx.owner,
Expand Down
19 changes: 9 additions & 10 deletions project/Scala2LibraryBootstrappedMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ object Scala2LibraryBootstrappedMiMaFilters {
// Need to be fixed
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*.$init$"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.*$extension"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.SortedMapOps.coll"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.TreeMap.empty"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.TreeMap.fromSpecific"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.ArrayBuilder#ofUnit.addAll"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.TreeMap.empty"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.TreeMap.fromSpecific"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.reflect.ManifestFactory#NothingManifest.newArray"),
ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.reflect.ManifestFactory#NullManifest.newArray"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.collection.immutable.SortedMapOps.coll"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.util.Sorting.scala$util$Sorting$$mergeSort$default$5")
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.SortedMapOps.coll"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.TreeMap.empty"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.immutable.TreeMap.fromSpecific"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.ArrayBuilder#ofUnit.addAll"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.TreeMap.empty"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.collection.mutable.TreeMap.fromSpecific"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.reflect.ManifestFactory#NothingManifest.newArray"),
//ProblemFilters.exclude[IncompatibleResultTypeProblem]("scala.reflect.ManifestFactory#NullManifest.newArray"),
//ProblemFilters.exclude[ReversedMissingMethodProblem]("scala.collection.immutable.SortedMapOps.coll"),
)
)

Expand Down
1 change: 1 addition & 0 deletions project/ScalaLibraryPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ object ScalaLibraryPlugin extends AutoPlugin {
"scala/jdk/FunctionWrappers$FromJavaLongUnaryOperator.class",
"scala/collection/ArrayOps$ReverseIterator.class",
"scala/runtime/NonLocalReturnControl.class",
"scala/util/Sorting.class", "scala/util/Sorting$.class", // Contains @specialized annotation
)

}
Loading

0 comments on commit a5f2c41

Please sign in to comment.