spatial icon indicating copy to clipboard operation
spatial copied to clipboard

Argon gotcha: Subclassing metadata types has weird behavior

Open dkoeplin opened this issue 6 years ago • 0 comments

abstract class A extends Data[A](...)

case object B extends A
case object C extends A

def setA(x: Sym[_], a: A): Unit = metadata.add(x, a)
def readA(x: Sym[_]): Option[A] = metadata[A](x)

x.setA(x, B)
readA(x)

In the current metadata implementation, the above will return None after readA, even though we've set metadata of B on x. This is because B has type of B.type, whereas we're looking for Class[A] when we try to read. For now should allow overriding the key on subclasses, but should have a more elegant solution here.

dkoeplin avatar Aug 01 '18 02:08 dkoeplin