File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/dotty/tools/dotc/transform Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import ast.Trees._
1313import NameOps ._
1414import typer .Mode
1515import TreeTransforms .TransformerInfo
16+ import StdNames ._
1617
1718/** The preceding lambda lift and flatten phases move symbols to different scopes
1819 * and rename them. This miniphase cleans up afterwards and makes sure that all
@@ -33,6 +34,19 @@ class RestoreScopes extends MiniPhaseTransform with IdentityDenotTransformer { t
3334 // For top-level classes this does nothing.
3435 val cls = tree.symbol.asClass
3536 val pkg = cls.owner.asClass
37+
38+ // Bring back companion links
39+ val companionClass = cls.info.decls.lookup(nme.COMPANION_CLASS_METHOD )
40+ val companionModule = cls.info.decls.lookup(nme.COMPANION_MODULE_METHOD )
41+
42+ if (companionClass.exists) {
43+ restoredDecls.enter(companionClass)
44+ }
45+
46+ if (companionModule.exists) {
47+ restoredDecls.enter(companionModule)
48+ }
49+
3650 pkg.enter(cls)
3751 val cinfo = cls.classInfo
3852 tree.symbol.copySymDenotation(
You can’t perform that action at this time.
0 commit comments