Skip to content

Commit 4d42982

Browse files
committed
Generalize condition for recursive patches
1 parent 471fca9 commit 4d42982

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,16 +1127,17 @@ class Definitions {
11271127
* any definitions of `denot` that have the same name as one of the copied
11281128
* definitions.
11291129
*
1130+
* If an object is present in both the original class and the patch class,
1131+
* it is not overwritten. Instead its members are copied recursively.
1132+
*
11301133
* To avpid running into cycles on bootstrap, patching happens only if `patchCls`
11311134
* is read from a classfile.
11321135
*/
11331136
def patchStdLibClass(denot: ClassDenotation)(using Context): Unit =
11341137

1135-
def recurse(patch: Symbol) =
1136-
patch.name.toString.startsWith("experimental")
1137-
11381138
def patch2(denot: ClassDenotation, patchCls: Symbol): Unit =
11391139
val scope = denot.info.decls.openForMutations
1140+
def recurse(patch: Symbol) = patch.is(Module) && scope.lookup(patch.name).exists
11401141
if patchCls.exists then
11411142
val patches = patchCls.info.decls.filter(patch =>
11421143
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))

0 commit comments

Comments
 (0)