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:
RootClass.newAliasType("T")
RootClass.newTypeParameter("T")
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
When you are attempting to generate a type variable using
.withFlags(Long*)
, depending on how theSymbol
parameter toTYPEVAR
was generated, the flags are being ignored entirely.I found this to be the case for the the
TypeSymbol
subtype ofSymbol
, which is returned by the following creation methods:RootClass.newAliasType("T")
RootClass.newTypeParameter("T")
Actual
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 aSymbol
), I get the expected output: