Skip to content

Commit 471fca9

Browse files
committed
Don't overwrite language.experimental
Patch its members recursively instead.
1 parent e98bdf8 commit 471fca9

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ class Definitions {
256256
*/
257257
@tu lazy val ScalaShadowingPackage: TermSymbol = requiredPackage(nme.scalaShadowing)
258258

259-
260259
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
261260
* because after erasure the Any and AnyVal references get remapped to the Object methods
262261
* which would result in a double binding assertion failure.
@@ -1133,19 +1132,28 @@ class Definitions {
11331132
*/
11341133
def patchStdLibClass(denot: ClassDenotation)(using Context): Unit =
11351134

1136-
def patchWith(patchCls: Symbol) =
1137-
denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted
1135+
def recurse(patch: Symbol) =
1136+
patch.name.toString.startsWith("experimental")
1137+
1138+
def patch2(denot: ClassDenotation, patchCls: Symbol): Unit =
11381139
val scope = denot.info.decls.openForMutations
11391140
if patchCls.exists then
11401141
val patches = patchCls.info.decls.filter(patch =>
11411142
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
1142-
for patch <- patches do
1143+
for patch <- patches if !recurse(patch) do
11431144
val e = scope.lookupEntry(patch.name)
11441145
if e != null then scope.unlink(e)
11451146
for patch <- patches do
11461147
patch.ensureCompleted()
1147-
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1148-
scope.enter(patch)
1148+
if !recurse(patch) then
1149+
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1150+
scope.enter(patch)
1151+
else if patch.isClass then
1152+
patch2(scope.lookup(patch.name).asClass, patch)
1153+
1154+
def patchWith(patchCls: Symbol) =
1155+
denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted
1156+
patch2(denot, patchCls)
11491157

11501158
if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then
11511159
patchWith(ScalaPredefModuleClassPatch)

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ class TreePickler(pickler: TastyPickler) {
765765

766766
def pickle(trees: List[Tree])(using Context): Unit = {
767767
trees.foreach(tree => if (!tree.isEmpty) pickleTree(tree))
768-
def missing = forwardSymRefs.keysIterator.map(sym => sym.showLocated + "(line " + sym.srcPos.line + ")").toList
768+
def missing = forwardSymRefs.keysIterator
769+
.map(sym => i"${sym.showLocated} (line ${sym.srcPos.line}) #${sym.id}")
770+
.toList
769771
assert(forwardSymRefs.isEmpty, i"unresolved symbols: $missing%, % when pickling ${ctx.source}")
770772
}
771773

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@ object language:
1818
*/
1919
object experimental:
2020

21-
/** Where enabled, Scala 2 macro definitions are allowed. Scala 2 macro implementations and
22-
* macro applications are unaffected; they can be used anywhere. A Scala 2 macro definition
23-
* must be accompanied by a Scala 3 macro definition with the same signature.
24-
*
25-
* '''Why introduce the feature?''' Scala 2 macros promise to make the language more regular,
26-
* replacing ad-hoc language constructs with a general powerful abstraction
27-
* capability that can express them. Macros are also a more disciplined and
28-
* powerful replacement for compiler plugins.
29-
*
30-
* '''Why control it?''' For their very power, macros can lead to code that is hard
31-
* to debug and understand.
32-
*
33-
* This is not required by Scala 3 macros as `inline` controls the basic generative macros.
34-
* More add-hoc macros must contain the import of reflection in thier code, making this import redundant.
35-
*/
36-
implicit lazy val macros: languageFeature.experimental.macros = languageFeature.experimental.macros
37-
3821
/** Experimental support for richer dependent types */
3922
object dependent
4023

0 commit comments

Comments
 (0)