문제

I've dynamically defined a Scala class, but in order to use it "properly" it needs to have a ScalaSig.

So, how might I generate a ScalaSig outside of normal compilation? Perhaps from a tree? Maybe like:

val tb = runtimeMirror(getClass.getClassLoader).mkToolBox()
val classDef = """class MyRecord(x: String)"""
val tree = showRaw(tb.parse(classDef))

But where does the pickler come in?

Thanks for any advice -Julian

도움이 되었습니까?

해결책

Artisanal-Pickle-Maker will reproduce a Scala pickled signature byte-for-byte (see restrictions).

Tapping into the compiler's pickler phase, as well as reuse of the Pickler's code, proved too challenging, so instead I used PickleBuffer, ShowPickled and a whole lotta diff -y to figure out how to generate arbitrary pickled Scala sigs.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top