diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-13 21:41:40 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-03-13 21:43:39 +0100 |
commit | 163b16014331ab909aa719b035dbc9491630edae (patch) | |
tree | 9cc6c4622a92a2a7547af6ac730a7dbee57facf7 /src/dotty/tools/dotc/util/Attachment.scala | |
parent | db950e5e168f6fd71a367da343e352139e8d653e (diff) | |
download | dotty-163b16014331ab909aa719b035dbc9491630edae.tar.gz dotty-163b16014331ab909aa719b035dbc9491630edae.tar.bz2 dotty-163b16014331ab909aa719b035dbc9491630edae.zip |
Bullet-proofing companion objects
Companion class/module computations now also work for local classes and modules. For this to work,
either one of two conditions must be met: (1) some enclosing context refers to a scope that
contains the companions. (2) the context's compilation unit has a typed tree that contains the
companions. (1) is usually true when type-checking, (2) when transforming trees.
Local companions are searched as follows: If (2) holds, we locate the statement sequence containing
the companions by searching down from the root stored in the compilation unit. Otherwise, we search
outwards in the enclosing contexts for a scope containing the
companions.
Diffstat (limited to 'src/dotty/tools/dotc/util/Attachment.scala')
-rw-r--r-- | src/dotty/tools/dotc/util/Attachment.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/util/Attachment.scala b/src/dotty/tools/dotc/util/Attachment.scala index d9e88a135..ec3019bab 100644 --- a/src/dotty/tools/dotc/util/Attachment.scala +++ b/src/dotty/tools/dotc/util/Attachment.scala @@ -74,10 +74,10 @@ object Attachment { else nx.removeAttachment(key) } - /** The list of all values attached to this container. */ - final def allAttachments: List[Any] = { + /** The list of all keys and values attached to this container. */ + final def allAttachments: List[(Key[_], Any)] = { val nx = next - if (nx == null) Nil else nx.value :: nx.allAttachments + if (nx == null) Nil else (nx.key, nx.value) :: nx.allAttachments } } |