-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Merge 'features/StaticAbstractMembersInInterfaces' into 'main' #54142
Merged
jaredpar
merged 62 commits into
dotnet:main
from
AlekseyTs:StaticAbstractMembersInInterfaces_32
Jun 16, 2021
Merged
Merge 'features/StaticAbstractMembersInInterfaces' into 'main' #54142
jaredpar
merged 62 commits into
dotnet:main
from
AlekseyTs:StaticAbstractMembersInInterfaces_32
Jun 16, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merge 'main' into 'features/StaticAbstractMembersInInterfaces'
…events in interfaces. (dotnet#52228) Spec: https://github.com/dotnet/csharplang/blob/9a0dddbf0643993db0da8f48436f2aac60bc20b1/proposals/statics-in-interfaces.md Related to dotnet#52202. Relevant quotes from the spec: #### Abstract virtual members Static interface members other than fields are allowed to also have the `abstract` modifier. Abstract static members are not allowed to have a body (or in the case of properties, the accessors are not allowed to have a body). ``` c# interface I<T> where T : I<T> { static abstract void M(); static abstract T P { get; set; } static abstract event Action E; static abstract T operator +(T l, T r); } ``` #### Explicitly non-virtual static members For symmetry with non-virtual instance members, static members should be allowed an optional `sealed` modifier, even though they are non-virtual by default: ``` c# interface I0 { static sealed void M() => Console.WriteLine("Default behavior"); static sealed int f = 0; static sealed int P1 { get; set; } static sealed int P2 { get => f; set => f = value; } static sealed event Action E1; static sealed event Action E2 { add => E1 += value; remove => E1 -= value; } static sealed I0 operator +(I0 l, I0 r) => l; } ```
…feature. (dotnet#52366) Spec: https://github.com/dotnet/csharplang/blob/3e6e0d77504b6d05eaec4232303d58b1fd806b51/proposals/statics-in-interfaces.md - Added tests to verify metadata produced for abstract static memebers in interfaces. - Added a temporary stub for the runtime support check. - Adjusted variance safety checks for signatures of abstract static members. - Adjusted generic constraints checks to disallow interfaces as type arguments for type parameters that are constrained to an interface with static abstract members. - Relaxed signature requirements for abstract user-defined operators. Relevant quotes from the spec: ## Operator restrictions Today all unary and binary operator declarations have some requirement involving at least one of their operands to be of type `T` or `T?`, where `T` is the instance type of the enclosing type. These requirements need to be relaxed so that a restricted operand is allowed to be of a type parameter that is constrained to `T`. ## Interface constraints with static abstract members Today, when an interface `I` is used as a generic constraint, any type `T` with an implicit reference or boxing conversion to `I` is considered to satisfy that constraint. When `I` has static abstract members this needs to be further restricted so that `T` cannot itself be an interface. ## Variance safety https://github.com/dotnet/csharplang/blob/main/spec/interfaces.md#variance-safety Variance safety rules should apply to signatures of static abstract members. The addition proposed in https://github.com/dotnet/csharplang/blob/main/proposals/variance-safety-for-static-interface-members.md#variance-safety should be adjusted from *These restrictions do not apply to occurrences of types within declarations of static members.* to *These restrictions do not apply to occurrences of types within declarations of **non-virtual, non-abstract** static members.* * Adjust an error message
…nInterfaces_05 Merge 'dotnet/main' into `StaticAbstractMembersInInterfaces`
…act static members. (dotnet#52659)
…in classes and structures (dotnet#52969) In metadata an implementation should be a static, not newslot, not final, not virtual, not abstract method. Type should have a MethodImpl entry pointing to the ”body” method with a MethodDef index. The “body” must be a method declared within the type. There is no concept of an implicit interface implementation for static methods in metadata. I.e., if there is no corresponding MethodImpl entry, the method isn’t an implementation from runtime point of view. Language supports both implicit and explicit interface implementation. Relevant ECMA-335 changes PR - dotnet/runtime#49558
…ourceUserDefinedOperatorSymbolBase to prepare for explicit implementations of operators (dotnet#53058) Shared code is pulled from derived types to the new base. This is just a refactoring, no behavior changes intended. However, there is a change in behavior that addresses dotnet#53069.
…in operators. (dotnet#53142) Also adding a bunch of parsing tests for scenarios without modifiers.
…s in classes and structures (dotnet#53130) This includes support for implicit and explicit implementations.
…es/events in classes and structures (dotnet#53265)
…inedo conversions in classes and structures (dotnet#53529)
…nterfaces. (dotnet#53619) Related to dotnet/csharplang#4773.
…MembersInInterfaceFix Fix GoToBase/GoToImplementation/FAR/InheritanceMargin for static abstract member
…AbstractMembersInInterfaces_29
Add Quick Info tests for static abstract inheritdoc
…ethods. (dotnet#54118) * Pack error codes. * Disallow UnmanagedCallersOnly for abstract static methods.
@dotnet/roslyn-compiler Need a sign-off on a merge PR. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.