Skip to content

Commit 3a7940a

Browse files
committed
Refactor code
1 parent d567fe0 commit 3a7940a

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
@@ -1137,6 +1137,23 @@ class Definitions {
11371137
assocFile = denot.symbol.associatedFile
11381138
)
11391139

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

0 commit comments

Comments
 (0)