diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-10 18:17:36 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | e93b7bfe770c8950a52d17bb0aebd3e0a5e93b3c (patch) | |
tree | 065ffb8c2b84ce2a6ec9f3ba050473c7af307c7d /src | |
parent | 8e66f5384837ba662eb6243e221e18e7364757ee (diff) | |
download | dotty-e93b7bfe770c8950a52d17bb0aebd3e0a5e93b3c.tar.gz dotty-e93b7bfe770c8950a52d17bb0aebd3e0a5e93b3c.tar.bz2 dotty-e93b7bfe770c8950a52d17bb0aebd3e0a5e93b3c.zip |
Don't add inline accessors twice
Make sure that inline accessors are not added twice. We got lucky so far
because the fact that annotations are lazy meant that attachments did not
persist. But if @inline was made into a strict annotation, inline accessors were indeed
added twice.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inliner.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala index e865c0596..cd042c476 100644 --- a/src/dotty/tools/dotc/typer/Inliner.scala +++ b/src/dotty/tools/dotc/typer/Inliner.scala @@ -192,9 +192,11 @@ object Inliner { /** The accessor defs to non-public members which need to be defined * together with the inline method */ - def accessors(implicit ctx: Context): List[MemberDef] = { + def removeAccessors(implicit ctx: Context): List[MemberDef] = { ensureEvaluated() - myAccessors.toList + val res = myAccessors.toList + myAccessors.clear() + res } } @@ -242,8 +244,8 @@ object Inliner { * @pre hasBodyToInline(sym) */ - def inlineAccessors(sym: SymDenotation)(implicit ctx: Context): List[MemberDef] = - inlineInfo(sym).get.accessors + def removeInlineAccessors(sym: SymDenotation)(implicit ctx: Context): List[MemberDef] = + inlineInfo(sym).get.removeAccessors /** Try to inline a call to a `@inline` method. Fail with error if the maximal * inline depth is exceeded. diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index d1a2ad5c2..dde2c866b 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1498,7 +1498,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val mdef1 = typed(mdef) buf += mdef1 if (Inliner.hasBodyToInline(mdef1.symbol)) - buf ++= Inliner.inlineAccessors(mdef1.symbol) + buf ++= Inliner.removeInlineAccessors(mdef1.symbol) traverse(rest) } case Thicket(stats) :: rest => |