Skip to content

Commit 384eccb

Browse files
committed
Macro translation. Track scala/docs.scala-lang@0914616 scala#197
"untyped macros enable textual abstraction in pattern matching" "oops forgot to link to an example"
1 parent a7c94fb commit 384eccb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ja/overviews/macros/untypedmacros.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ title: 型指定の無いマクロ
4949
マクロ以外や複合型の一部としてのアンダースコアの使用は期待通り動作しない。
5050
前者はコンパイルエラーに、後者、例えば `List[_]` は通常通り存在型を返すだろう。
5151

52+
型指定の無いマクロは抽出子マクロを可能とすることに注意してほしい: [SI-5903](https://issues.scala-lang.org/browse/SI-5903)
53+
Scala 2.10.x においても `unapply``unaoolySeq` をマクロとして宣言することは可能だが、リンクした JIRA ケースに記述されているとおり、使い勝手は非常に制限されたものとなっている。パターンマッチング内におけるテキスト抽象化の全力は型指定の無いマクロによって発揮できるようになる。
54+
詳細は単体テストの [test/files/run/macro-expand-unapply-c](https://github.com/scalamacros/kepler/tree/paradise/macros/test/files/run/macro-expand-unapply-c) を参照。
55+
5256
もしマクロに型指定の無いパラメータがあった場合、マクロ展開を型付けする際にタイプチェッカーは引数に関しては何もせずに型指定の無いままマクロに渡す。もしいくつかのパラメータが型アノテーションを持っていたとしても、現行では無視される。これは将来改善される予定だ: [SI-6971](https://issues.scala-lang.org/browse/SI-6971)。引数が型検査されていないため、implicit の解決や型引数の推論は実行されない (しかし、両者ともそれぞれ `c.typeCheck``c.inferImplicitValue` として実行できる)。
5357

5458
明示的に渡された型引数はそのままマクロに渡される。もし型引数が渡されなかった場合は、値引数を型検査しない範囲で可能な限り型引数を推論してマクロに渡す。つまり、型引数は型検査されるということだが、この制約は将来無くなるかもしれない: [SI-6972](https://issues.scala-lang.org/browse/SI-6972)

0 commit comments

Comments
 (0)