-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer user operators over predefined operators for binary enum opera…
…tions too. Fixes #13202
- Loading branch information
1 parent
035214b
commit 479cfc6
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
|
||
public class C | ||
{ | ||
public static readonly C Token = new C (); | ||
|
||
public static C operator & (C set, E value) | ||
{ | ||
return Token; | ||
} | ||
|
||
public static implicit operator E (C c) | ||
{ | ||
throw new ApplicationException (); | ||
} | ||
} | ||
|
||
public enum E | ||
{ | ||
Item = 2 | ||
} | ||
|
||
class FooClass | ||
{ | ||
public static int Main () | ||
{ | ||
C m = new C (); | ||
var x = E.Item; | ||
var res = m & x; | ||
if (res != C.Token) | ||
return 1; | ||
|
||
res = m & E.Item; | ||
if (res != C.Token) | ||
return 2; | ||
|
||
return 0; | ||
} | ||
} |
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