6127d6cb8f
Previously, code in a closure was compiled with the assumption that invocations known to be statically sound didn't need any runtime checks to guaranty soundness. Now, if the code is retained from an earlier compile and executed after a hot reload, any assumptions regarding soundness may be invalid. This change transforms what was an invocation expression into a larger expression that performs additional checks (similar to a dynamic call). All checks are skipped if the compile generation matches the current hot reload generation at runtime. The soundness checks are handled by a new runtime helper method `hotReloadCorrectnessChecks`. Any argument expressions are hoisted into let variables to preserve their evaluation order and to ensure they are only evaluated once. The helper checks for the existence of the invocation target, the shape of the method signature, and runtime type of the passed arguments. Mismatches result in an invocation of `NoSuchMethod`. Any returned value is cast to the expected static type of the original invocation. Change-Id: If925f1a9b475d5ac581b2526403ab7c95753ffef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421640 Reviewed-by: Jens Johansen <jensj@google.com> Reviewed-by: Nate Biggs <natebiggs@google.com> Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>