Skip to content
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

Please add design doc explaining constraint checking of well-known generics #24431

Open
gafter opened this issue Jan 24, 2018 · 0 comments
Open

Comments

@gafter
Copy link
Member

gafter commented Jan 24, 2018

Associated with #24322, the following new guidelines should be documented in https://github.com/dotnet/roslyn/tree/master/docs/compilers/Design

From: @cston
Sent: Friday, January 19, 2018 2:32 PM
Subject: RE: Lookup of custom AsyncMethodBuilder members should check type parameter constraints

After several hallway discussions, we’re converging on the following approach:

For well-known generic types and methods introduced in the compiler for C#7.0 or later, the compiler will check any and all constraints when substituting type arguments at each use-site. The compiler will not require any specific constraints for well-known types or methods though. There will be no change for well-known types and methods added to the compiler before C#7.0 – that is, the compiler will continue to ignore any constraints at the use-site for those types and methods.

Generic types and methods from C#7.0 or later:
Generic types:

  1. System.ValueTuple<T1, …>
  2. Custom Task method builder
  3. Span
  4. ReadOnlySpan

Generic methods:
5. Custom Task and Task method builders:
a. Start(ref TStateMachine)
b. AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter, ref TStateMachine)
c. AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter, ref TStateMachine)

For 15.6, I’ll look at checking constraints for #5 only since we have an existing bug (#21500). For the other cases, the generic types, I’ll open 15.7 bugs to check constraints. And for any well-known types or members added to future releases of the compiler, constraint checking should be added at the time the well-known member is added to the compiler.

@gafter gafter self-assigned this Aug 27, 2019
@gafter gafter added this to the 16.4 milestone Aug 27, 2019
@agocke agocke modified the milestones: 16.4, 16.5 Nov 1, 2019
@gafter gafter modified the milestones: 16.5, 16.6 Jan 16, 2020
@jaredpar jaredpar modified the milestones: 16.6, Backlog Apr 2, 2020
@gafter gafter removed their assignment Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants