stanford-ppl / spatial

Spatial: "Specify Parameterized Accelerators Through Inordinately Abstract Language"
https://spatial.stanford.edu
MIT License
274 stars 32 forks source link

Argon gotcha: Subclassing metadata types has weird behavior #79

Open dkoeplin opened 6 years ago

dkoeplin commented 6 years ago
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.