-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VM not instantiating closure tear off type parameters to bounds #54426
Comments
It looks like we're not instantiating default type arguments during dynamic closure calls. /cc @sstrickl |
@sstrickl I assume you are going to pick this up. |
from the isolate stress test list as it is failing (see #54426) Change-Id: I7f5df7faa2cdc633901e54829ff9a7ccd824f5a9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344461 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
So looking at the code, when we instantiate default type arguments inside a closure function, we use the same code as other types of functions. That means we use the instantiator and function type arguments passed to the function to instantiate the default type arguments, instead of using the instantiator type arguments and parent function type arguments stored in the closure if this is a closure function. (We do properly use them to instantiate the default type arguments during the type checking that happens within the invoke field dispatcher that handles the dynamic closure call, but that's only used for type checking within the dispatcher and the original function type arguments, if any, are passed through unchanged.) So the fix is relatively straightforward. However, I'm taking a deeper look at it because the simplest fix would cause us to recompute this every time the closure is called. Instead, we should probably instead precompute and cache the instantiation of the default type arguments at closure creation time, trading off a bit of space in the closure object to avoid repeated TAV instantiation within the closure function and also removing the instantiation done within the invoke field dispatcher with a simple field load instead. |
In this test
A.foo.Q1
is instantiated tonum
andA.foo.bar.T1
is instantiated toint
. So whenbar2
gets torn-off and invoked dynamically,A.foo.bar.bar2.T2
should be instantiated to its bounds which isMap<A.foo.Q1, A.foo.bar.T1>
or in this contextMap<num, int>
.Failing test
Test introduced in this CL
The text was updated successfully, but these errors were encountered: