File tree 3 files changed +14
-7
lines changed
compiler/src/dotty/tools/dotc/core
scala2-library-bootstrapped/src/scala
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -1436,11 +1436,14 @@ class Definitions {
1436
1436
)
1437
1437
1438
1438
if patchCls.exists then
1439
+ val patchedInSource = mutable.Set .empty[Symbol ] // example: symbol patched in scala2-library-bootstrapped/src/scala/Predef.scala
1439
1440
val patches = patchCls.info.decls.filter(patch =>
1440
1441
! patch.isConstructor && ! patch.isOneOf(PrivateOrSynthetic ))
1441
1442
for patch <- patches if ! recurse(patch) do
1442
1443
val e = scope.lookupEntry(patch.name)
1443
- if e != null then scope.unlink(e)
1444
+ if e != null then
1445
+ if e.sym.isInlineMethod then patchedInSource += patch
1446
+ else scope.unlink(e)
1444
1447
for patch <- patches do
1445
1448
patch.ensureCompleted()
1446
1449
if ! recurse(patch) then
@@ -1451,8 +1454,9 @@ class Definitions {
1451
1454
case _ =>
1452
1455
makeNonClassSymbol(patch)
1453
1456
end match
1454
- sym.annotations = patch.annotations
1455
- scope.enter(sym)
1457
+ if ! patchedInSource(sym) then
1458
+ sym.annotations = patch.annotations
1459
+ scope.enter(sym)
1456
1460
if patch.isClass then
1457
1461
patch2(scope.lookup(patch.name).asClass, patch)
1458
1462
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ object MiMaFilters {
22
22
val StdlibBootstrappedBackwards : Map [String , Seq [ProblemFilter ]] = Map (
23
23
Build .stdlibBootstrappedVersion -> {
24
24
Seq (
25
+ // Methods overwritten in `scala.Predef` instead of `scala.runtime.stdLibPatches`
26
+ ProblemFilters .exclude[DirectMissingMethodProblem ](" scala.Predef.assert" ), // `assert` is `inline` and therefore is not emitted in the bytecode
27
+
25
28
// Files that are not compiled in the bootstrapped library
26
29
ProblemFilters .exclude[MissingClassProblem ](" scala.AnyVal" ),
27
30
Original file line number Diff line number Diff line change @@ -259,9 +259,9 @@ object Predef extends LowPriorityImplicits {
259
259
* @group assertions
260
260
*/
261
261
@ elidable(ASSERTION )
262
- def assert (assertion : Boolean ): Unit = {
262
+ transparent inline def assert (inline assertion : Boolean ): Unit = {
263
263
if (! assertion)
264
- throw new java.lang. AssertionError ( " assertion failed " )
264
+ scala.runtime. Scala3RunTime .assertFailed( )
265
265
}
266
266
267
267
/** Tests an expression, throwing an `AssertionError` if false.
@@ -274,9 +274,9 @@ object Predef extends LowPriorityImplicits {
274
274
* @group assertions
275
275
*/
276
276
@ elidable(ASSERTION ) @ inline
277
- final def assert (assertion : Boolean , message : => Any ): Unit = {
277
+ transparent inline def assert (inline assertion : Boolean , inline message : => Any ): Unit = {
278
278
if (! assertion)
279
- throw new java.lang. AssertionError ( " assertion failed: " + message)
279
+ scala.runtime. Scala3RunTime .assertFailed( message)
280
280
}
281
281
282
282
/** Tests an expression, throwing an `AssertionError` if false.
You can’t perform that action at this time.
0 commit comments