Skip to content

Commit 07cff24

Browse files
liufengyunmichelou
authored andcommitted
Refactor code
1 parent 5613483 commit 07cff24

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,23 @@ class Definitions {
11391139
assocFile = denot.symbol.associatedFile
11401140
)
11411141

1142+
def makeNonClassSymbol(patch: Symbol) =
1143+
if patch.is(Inline) then
1144+
// Inline symbols contain trees in annotations, which is coupled
1145+
// with the underlying symbol.
1146+
// Changing owner for inline symbols is a simple workaround.
1147+
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1148+
patch
1149+
else
1150+
// change `info` which might contain reference to the patch
1151+
patch.copy(
1152+
owner = denot.symbol,
1153+
info =
1154+
if patch.is(Module)
1155+
then TypeRef(denot.symbol.thisType, patch.name.moduleClassName)
1156+
else patch.info // assume non-object info does not refer to symbols in the patch
1157+
)
1158+
11421159
if patchCls.exists then
11431160
val patches = patchCls.info.decls.filter(patch =>
11441161
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
@@ -1153,21 +1170,7 @@ class Definitions {
11531170
case ClassInfo(_, _, parents, _, selfInfo) =>
11541171
makeClassSymbol(patch, parents, selfInfo)
11551172
case _ =>
1156-
if patch.is(Inline) then
1157-
// Inline symbols contain trees in definitions, which is coupled
1158-
// with the underlying symbol.
1159-
// Changing owner for inline symbols is a simple workaround.
1160-
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1161-
patch
1162-
else
1163-
// change `info` which might contain reference to the patch
1164-
patch.copy(
1165-
owner = denot.symbol,
1166-
info =
1167-
if patch.is(Module)
1168-
then TypeRef(denot.symbol.thisType, patch.name.moduleClassName)
1169-
else patch.info // assume non-object info does not refer to symbols in the patch
1170-
)
1173+
makeNonClassSymbol(patch)
11711174
end match
11721175
sym.annotations = patch.annotations
11731176
scope.enter(sym)

0 commit comments

Comments
 (0)