Skip to content

Add support for nonnull constraints #830

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

Closed

Conversation

RexJaeschke
Copy link
Contributor

No description provided.

@RexJaeschke RexJaeschke added this to the C# 8.0 milestone Jun 30, 2023
@RexJaeschke RexJaeschke marked this pull request as draft June 30, 2023 20:04
@RexJaeschke RexJaeschke added the type: feature This issue describes a new feature label Jul 22, 2023
@BillWagner BillWagner force-pushed the Rex-nonnull-constraint branch from b37ce98 to 1ece5c4 Compare September 25, 2023 15:50
@BillWagner
Copy link
Member

Rebased on latest draft-v8 on 09/25/2023

@RexJaeschke RexJaeschke added the Review: pending Proposal is available for review label Oct 13, 2023
@RexJaeschke RexJaeschke marked this pull request as ready for review January 11, 2024 14:04
@RexJaeschke
Copy link
Contributor Author

@BillWagner On yesterday’s TG2 call, you wondered if you had resolved this PR as part of your other nullable-related work, and I offered to take a look.

Looking at the Files changed and the current version of classes.md, I see the following:

  1. The grammar addition at line 419 has been applied.
  2. A corrected version of the text proposed for line 438 has been applied.
  3. The proposed normative text and large example starting at line 494 has not been applied.

So the remaining question is, "Did we decide to reject Item 3, or do we still need to look at that?" I'm guessing the latter.

@BillWagner
Copy link
Member

@BillWagner On yesterday’s TG2 call, you wondered if you had resolved this PR as part of your other nullable-related work, and I offered to take a look.

Looking at the Files changed and the current version of classes.md, I see the following:

  1. The grammar addition at line 419 has been applied.
  2. A corrected version of the text proposed for line 438 has been applied.
  3. The proposed normative text and large example starting at line 494 has not been applied.

So the remaining question is, "Did we decide to reject Item 3, or do we still need to look at that?" I'm guessing the latter.

See #1246

@@ -490,7 +491,49 @@ Any constraints shall be consistent among dependent type parameters. If type par

It is valid for `S` to have the value type constraint and `T` to have the reference type constraint. Effectively this limits `T` to the types `System.Object`, `System.ValueType`, `System.Enum`, and any interface type.

If the `where` clause for a type parameter includes a constructor constraint (which has the form `new()`), it is possible to use the `new` operator to create instances of the type ([§12.8.17.2](expressions.md#128172-object-creation-expressions)). Any type argument used for a type parameter with a constructor constraint shall be a value type, a non-abstract class having a public parameterless constructor, or a type parameter having the value type constraint or constructor constraint.
The token `notnull` is neither a keyword nor a contextual keyword. When it is encountered, it will either:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per #1246, we believe it is a contextual keyword.

If the `where` clause for a type parameter includes a constructor constraint (which has the form `new()`), it is possible to use the `new` operator to create instances of the type ([§12.8.17.2](expressions.md#128172-object-creation-expressions)). Any type argument used for a type parameter with a constructor constraint shall be a value type, a non-abstract class having a public parameterless constructor, or a type parameter having the value type constraint or constructor constraint.
The token `notnull` is neither a keyword nor a contextual keyword. When it is encountered, it will either:

- Bind to a type named `notnull`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gafter pointed out it could be an alias - we can just strike "named notnull", or see @Nigel-Ecma's wording in #1246.

@jskeet
Copy link
Contributor

jskeet commented Jan 22, 2025

Closing as #1256 involves creating a replacement for this.

@jskeet jskeet closed this Jan 22, 2025
@jskeet
Copy link
Contributor

jskeet commented Jan 22, 2025

@RexJaeschke - please don't delete the branch for this PR, as I'll want to copy from it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review: pending Proposal is available for review type: feature This issue describes a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants