Skip to content

Define Predef.assert overwrite directly in Scala 2 library TASTy #19231

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1437,11 +1437,14 @@ class Definitions {
)

if patchCls.exists then
val patchedInSource = mutable.Set.empty[Symbol] // example: symbol patched in scala2-library-bootstrapped/src/scala/Predef.scala
val patches = patchCls.info.decls.filter(patch =>
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
for patch <- patches if !recurse(patch) do
val e = scope.lookupEntry(patch.name)
if e != null then scope.unlink(e)
if e != null then
if e.sym.isInlineMethod then patchedInSource += patch
else scope.unlink(e)
for patch <- patches do
patch.ensureCompleted()
if !recurse(patch) then
Expand All @@ -1452,8 +1455,9 @@ class Definitions {
case _ =>
makeNonClassSymbol(patch)
end match
sym.annotations = patch.annotations
scope.enter(sym)
if !patchedInSource(sym) then
sym.annotations = patch.annotations
scope.enter(sym)
if patch.isClass then
patch2(scope.lookup(patch.name).asClass, patch)

Expand Down
3 changes: 3 additions & 0 deletions project/Scala2LibraryBootstrappedMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ object Scala2LibraryBootstrappedMiMaFilters {
// Files that are not compiled in the bootstrapped library
ProblemFilters.exclude[MissingClassProblem]("scala.AnyVal"),

// Overwritten inline methods
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.Predef.assert"),

// Scala language features
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.language.<clinit>"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.language#experimental.<clinit>"),
Expand Down
19 changes: 10 additions & 9 deletions project/TastyMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import tastymima.intf._

object TastyMiMaFilters {
val StdlibBootstrapped: java.util.List[ProblemMatcher] = asList(

// FIXME: method overwritten in scala2-library-bootstrapped/src/scala/Predef.scala
ProblemMatcher.make(ProblemKind.IncompatibleTypeChange, "scala.Predef.nn"), // The symbol scala.Predef.nn has an incompatible type in current version: before: [T](x: T)(x.type & T); after: [T](x: scala.|[T, scala.Null])scala.&[x.type, T]
// FIXME: method NOT overwritten yet in scala2-library-bootstrapped/src/scala/Predef.scala
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.valueOf"), // The member scala.Predef.valueOf with signature (1):java.lang.Object does not have a correspondant in current version
// FIXME: method NOT overwritten yet in scala2-library-bootstrapped/src/scala/Predef.scala
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.ne"), // The member scala.Predef.ne with signature (java.lang.Object,java.lang.Object):scala.Boolean does not have a correspondant in current version
// FIXME: method NOT overwritten yet in scala2-library-bootstrapped/src/scala/Predef.scala
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.eq"), // The member scala.Predef.eq with signature (java.lang.Object,java.lang.Object):scala.Boolean does not have a correspondant in current version

// Probably OK
ProblemMatcher.make(ProblemKind.IncompatibleSelfTypeChange, "scala.*"),

Expand Down Expand Up @@ -54,11 +64,6 @@ object TastyMiMaFilters {
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.convert.impl.TableStepperBase.i0_="),
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.convert.impl.TableStepperBase.maxLength_="),

// Problem: ???
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.nn"), // The member scala.Predef.nn with signature (1,java.lang.Object):java.lang.Object does not have a correspondant in current version
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.ne"), // The member scala.Predef.ne with signature (java.lang.Object,java.lang.Object):scala.Boolean does not have a correspondant in current version
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.eq"), // The member scala.Predef.eq with signature (java.lang.Object,java.lang.Object):scala.Boolean does not have a correspondant in current version

// Probably OK: protected lazy val (processThread, (futureThread, futureValue), destroyer) = { ... }
// None of these can be accessed from user code.
// https://github.com/scala/scala/blob/cff8a9af4da67658d8e1e32f929e1aff03ffa384/src/library/scala/sys/process/ProcessImpl.scala#L99C5-L99C83
Expand All @@ -75,10 +80,6 @@ object TastyMiMaFilters {
// https://github.com/scala/scala/blob/2.13.x/src/library/scala/collection/mutable/ArrayBuilder.scala#L504C1-L504C87
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.collection.mutable.ArrayBuilder.ofUnit.addAll"), // The member scala.collection.mutable.ArrayBuilder.ofUnit.addAll with signature (java.lang.Object,scala.Int,scala.Int):scala.collection.mutable.ArrayBuilder$.ofUnit does not have a correspondant in current version

// Probably OK (TASTy MiMa bug): Patched Predef members
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.valueOf"), // The member scala.Predef.valueOf with signature (1):java.lang.Object does not have a correspondant in current version
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.Predef.summon"), // The member scala.Predef.summon with signature (1,java.lang.Object):java.lang.Object does not have a correspondant in current version

// TASTy-MiMa bugs
ProblemMatcher.make(ProblemKind.InternalError, "scala.collection.SeqView.appendedAll"),
ProblemMatcher.make(ProblemKind.InternalError, "scala.collection.SeqView.concat"),
Expand Down
Loading