coerceCallArguments
の中でRValueにしているようでした。 https://github.com/swiftlang/swift/blob/e22c09c05546bc638169da0dfc8c8996f160f168/lib/Sema/CSApply.cpp#L8399
(argument (declref_expr type="@lvalue Int" location=79078.swift:19:6
が (argument (load_expr implicit type="Int" location=79078.swift:19:6
に変わります。クロージャ(例えば、var a = {}
)も同じでした。 2. coerceToRValue
はっきりとこの場合だというのはわからなかったのですが、参照を実態化するために使われているようです。Exprを新しく生成(Rewrite)するときに必要なのかなあ?と思いました 3. withoutActuallyEscaping
The body closure receives a copy of the argument closure that is temporarily made @escaping.
とコピーが渡されていることを想定していることからも、RValueが期待されているのかなと思いました。 https://github.com/swiftlang/swift/blob/3787044e8349bf4933ae43f16cbbb44344785e04/lib/Sema/TypeOfReference.cpp#L2245 そうすると、LValueをRValueに変換し忘れていたということかと思うのですが、一個気になるのが、sending
とconsuming
は比較的新しいものの、 inout
でもクラッシュするのは、なんで今まで誰も気づかなかったのかという点ですね...w (あるいはユースケースがないから放置されていたのか...) func send( operation: inout () async -> Void ) async { _ = await withoutActuallyEscaping(operation) { escapingClosure in await escapingClosure() } }