0

How can one obtain the code of all automatically generated methods of a case class, to cleanly preserve any of them when refactoring to a regular (non-case) class? is there some compilation flag that reveals the case class's auto-generated methods, or some other way, that ultimately reduce this to a cut & paste?

I have been under the impression that there are compilation flags to reveal automatically expanded definitions....

4

2 に答える 2

1

フラグを使用して、コンパイラがソース コードを何に脱糖するかを確認できます-Xprint:<phase>。例 (ケース クラスに対して生成されるコードを確認する) では、次を実行します。

scalac -Xprint:typer YourScala.sca

フラグを使用-Xshow-phasesすると、使用可能なすべてのフェーズが表示されます。

しかし、表示される出力はコンパイル可能な scala ソース コードではなく、何らかの中間表現です。

于 2015-04-28T16:16:53.127 に答える