eed3si9n / treehugger

treehugger.scala is a library to code Scala programmatically.
http://eed3si9n.com/treehugger
Other
133 stars 20 forks source link

Flags are being ignored on TYPEVAR(Symbol).withFlags(Long*) #54

Open derabbink opened 5 years ago

derabbink commented 5 years ago

When you are attempting to generate a type variable using .withFlags(Long*), depending on how the Symbol parameter to TYPEVAR was generated, the flags are being ignored entirely.

I found this to be the case for the the TypeSymbol subtype of Symbol, which is returned by the following creation methods:

Actual

val tree1 = TYPEVAR(RootClass.newAliasType("T")).withFlags(Flags.OVERRIDE, Flags.PROTECTED).tree
tree1: treehugger.forest.TypeDef = TypeDef(Modifiers(protected override, , Map()),T,List(),EmptyTree)

val tree2 = TYPEVAR(RootClass.newTypeParameter("T")).withFlags(Flags.OVERRIDE, Flags.PROTECTED).tree
tree2: treehugger.forest.TypeDef = TypeDef(Modifiers(protected override, , Map()),T,List(),EmptyTree)

treeToString(tree1)
res0: String = type T

treeToString(tree2)
res1: String = type T

Expected I expect the flags to be rendered in the output, no matter how the symbol was created. In the documentation, I cannot see a reason as to why treehugger is behaving like this either. If I use merely a Name (instead of a Symbol), I get the expected output:

val tree3 = TYPEVAR("T").withFlags(Flags.OVERRIDE, Flags.PROTECTED).tree
tree3: treehugger.forest.TypeDef = TypeDef(Modifiers(protected override, , Map()),T,List(),EmptyTree)

treeToString(tree3)
res2: String = protected override type T