Skip to content

Commit

Permalink
Avoid infinite generics recursion in SynchronizationContextScheduler
Browse files Browse the repository at this point in the history
The infinitive generics recursion interacts poorly with AOT. The AOT compilers have hard figuring
out where the stop generating the code for generics with infinite recursion. They either fail or
produce large images by giving up once the generics get too complex.

This change reverts a small part of dotnet#500 that introduced infinite generic recusion and adds comment.

Fixes dotnet/corert#7920
  • Loading branch information
jkotas committed Dec 24, 2019
1 parent c7c3b59 commit 4af03fb
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -93,7 +93,8 @@ public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Fun
return Schedule(state, action);
}

return DefaultScheduler.Instance.Schedule((scheduler: this, action, state), dt, (_, tuple) => tuple.scheduler.Schedule(tuple.state, tuple.action));
// Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument
return DefaultScheduler.Instance.Schedule(state, dt, (_, state1) => Schedule(state1, action));
}
}
}

0 comments on commit 4af03fb

Please sign in to comment.