iheartradio / ficus

Scala-friendly companion to Typesafe config
MIT License
327 stars 55 forks source link

Make the source compile with SIP-56 match types, for Scala 3.4. #286

Open sjrd opened 1 year ago

sjrd commented 1 year ago

Refine the definition of EnumerationUtil.Aux to make it comply with the legal match types of SIP-56. Although weird, it is the "standard" trick for extracting enumeration Value's uner SIP-56.

Refine the result type of EnumerationReader.findEnumValue to be path-dependent instead of using the match type. It is strictly more precise.

Ref https://github.com/scala/improvement-proposals/pull/65, https://github.com/lampepfl/dotty/pull/18262

soronpo commented 1 year ago

OMG, I didn't even know this syntax was possible

sjrd commented 1 year ago

{ type Value } is implicitly AnyRef { type Value}. It's a valid type. Then we create another refinement of that type, so { type Value } { type Value = A } is (AnyRef { type Value }) { type Value = A }. There's nothing surprising if you follow the grammar.