summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/StdAttachments.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-11-30 17:45:59 -0800
committerGitHub <noreply@github.com>2016-11-30 17:45:59 -0800
commitc2eb299b0e1ed2f321a81d4afbdb36762e2c0e7b (patch)
treeb184b8e08dc9077a39b4f48e86e5e4959ffb3c01 /src/reflect/scala/reflect/internal/StdAttachments.scala
parent038c15e405b9498863a2236707686a7933748c60 (diff)
parentdde13b56f421a6f956abebc58f041acec8744149 (diff)
downloadscala-c2eb299b0e1ed2f321a81d4afbdb36762e2c0e7b.tar.gz
scala-c2eb299b0e1ed2f321a81d4afbdb36762e2c0e7b.tar.bz2
scala-c2eb299b0e1ed2f321a81d4afbdb36762e2c0e7b.zip
Merge pull request #5284 from milessabin/topic/si-7046
SI-7046 reflection doesn't see all knownDirectSubclasses This appears to do the right thing in the most typical scenarios in which `knownDirectSubclasses` would be used. The missing 5% is that subclasses defined in local scopes might not be seen by `knownDirectSubclasses` (see `Local` and `Riddle` in the test below). In mitigation, though, it is almost certain that a local subclass would represent an error in any scenario where `knownDirectSubclasses` might be used. Errors for such situations are reported by recording (via a symbol attachment) that `knownDirectSubclasses` has been called and reporting an error if any additional children are added subsequently. Despite these limitations and caveats, I believe that this represents a huge improvement over the status quo, and would eliminate 100% of the failures that I've seen in practice with people using shapeless for type class derivation.
Diffstat (limited to 'src/reflect/scala/reflect/internal/StdAttachments.scala')
-rw-r--r--src/reflect/scala/reflect/internal/StdAttachments.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala
index fd8f51cfb1..fc49de1cf6 100644
--- a/src/reflect/scala/reflect/internal/StdAttachments.scala
+++ b/src/reflect/scala/reflect/internal/StdAttachments.scala
@@ -81,4 +81,10 @@ trait StdAttachments {
/** An attachment carrying information between uncurry and erasure */
case class TypeParamVarargsAttachment(val typeParamRef: Type)
+
+ /** Attached to a class symbol to indicate that its children have been observed
+ * via knownDirectSubclasses. Children added subsequently will trigger an
+ * error to indicate that the earlier observation was incomplete.
+ */
+ case object KnownDirectSubclassesCalled extends PlainAttachment
}