From 97ee5c0f308381826818bc07b0ad6e64f16861ff Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 29 Mar 2021 13:36:06 +0200 Subject: [PATCH] Fix #11731: Remove symbols with targetName correctly The symbol might have original name in scope other than its current target name (after erasure). --- compiler/src/dotty/tools/dotc/core/SymDenotations.scala | 4 +++- tests/pos/i11731.scala | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i11731.scala diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index a7dec8281d89..f170304d20d4 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1899,7 +1899,9 @@ object SymDenotations { * someone does a findMember on a subclass. */ def delete(sym: Symbol)(using Context): Unit = { - info.decls.openForMutations.unlink(sym) + val scope = info.decls.openForMutations + scope.unlink(sym, sym.name) + if sym.name != sym.originalName then scope.unlink(sym, sym.originalName) if (myMemberCache != null) myMemberCache.remove(sym.name) if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache() } diff --git a/tests/pos/i11731.scala b/tests/pos/i11731.scala new file mode 100644 index 000000000000..bef8fdef00f4 --- /dev/null +++ b/tests/pos/i11731.scala @@ -0,0 +1,5 @@ +import scala.annotation.targetName + +trait Example: + @targetName("funfun") + inline def fun: Unit = ???