-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Labels
Area-IDEConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code qualityFeature - CheckedUserDefinedOperatorsIDE-NavigationNavigation and searchNavigation and searchNavigation-FARFind all referencesFind all references
Milestone
Description
class Program
{
static void Main()
{
var x = new C();
var y = new C();
var z1 = -x;
var z2 = x + y;
string z3 = (string)x;
;
checked
{
z1 = -y;
z2 = y + x;
z3 = (string)x;
;
}
System.Action a1 = D;
System.Action a2 = D;
var b = ReferenceEquals(a1, a2);
}
static void D() { }
}
class C
{
/// <summary>
/// <see cref="operator +(C, C)"/>
/// <see cref="operator -(C)"/>
/// <see cref="explicit operator string(C)"/>
/// <see cref="operator checked +(C, C)"/>
/// <see cref="operator checked -(C)"/>
/// <see cref="explicit operator checked string(C)"/>
/// </summary>
public string F;
public static C operator checked -(C x) => new C { F = "checked -" };
public static C operator -(C x) => new C { F = "regular -" };
public static C operator checked +(C x, C y) => new C { F = "checked +" };
public static C operator +(C x, C y) => new C { F = "regular +" };
public static explicit operator checked string(C x) => "checked string";
public static explicit operator string(C y) => "regular string";
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-IDEConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code qualityFeature - CheckedUserDefinedOperatorsIDE-NavigationNavigation and searchNavigation and searchNavigation-FARFind all referencesFind all references