Skip to content

Commit

Permalink
More feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed May 16, 2022
1 parent bf7bdc8 commit 06df1b7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9997,19 +9997,19 @@ public static void M6(uint{{s2Nullable}} x) { }
public static void M7(nint{{s1Nullable}} x) { Write("M7 "); }
public static void M7(ulong{{s2Nullable}} x) { }

public static void M8(nint{{s1Nullable}} x) { Write("M8"); }
public static void M8(nint{{s1Nullable}} x) { Write("M8 "); }
public static void M8(nuint{{s2Nullable}} x) { }

public static void M9(nint{{s1Nullable}} x) { Write("M9"); }
public static void M9(byte{{s2Nullable}} x) { }
public static void M9(nint{{s1Nullable}} x) { Write("M9(nint)"); }
public static void M9(byte{{s2Nullable}} x) { Write("M9(byte)"); }
}
""";
var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols });

// Note: conversions ushort->nint, ushort?->nint?, ushort->nint? are implicit (so rule 1 kicks in), but ushort?->nint is explicit (so rule 3 kicks in)
var expected = (nullable1, nullable2) is (false, true)
? "M1 M2 M3 M4 M5(nint) M6 M7 M8 M9"
: "M1 M2 M3 M4 M5(ushort) M6 M7 M8 M9";
? "M1 M2 M3 M4 M5(nint) M6 M7 M8 M9(nint)"
: "M1 M2 M3 M4 M5(ushort) M6 M7 M8 M9(byte)";
CompileAndVerify(comp, expectedOutput: expected);
}

Expand Down Expand Up @@ -10037,6 +10037,7 @@ public void BetterConversionTarget_IntPtr(bool nullable1, bool nullable2)
C.M7(0);
C.M8(0);
C.M9(0);
C.M10(0);

public class C
{
Expand Down Expand Up @@ -10064,16 +10065,19 @@ public static void M7(uint{{s2Nullable}} x) { }
public static void M8(IntPtr{{s1Nullable}} x) { Write("M8 "); }
public static void M8(ulong{{s2Nullable}} x) { }

public static void M9(IntPtr{{s1Nullable}} x) { Write("M9"); }
public static void M9(IntPtr{{s1Nullable}} x) { Write("M9 "); }
public static void M9(nuint{{s2Nullable}} x) { }

public static void M10(IntPtr{{s1Nullable}} x) { Write("M10(IntPtr)"); }
public static void M10(byte{{s2Nullable}} x) { Write("M10(byte)"); }
}
""";
var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols });

// Note: conversions ushort->nint, ushort?->nint?, ushort->nint? are implicit (so rule 1 kicks in), but ushort?->nint is explicit (so rule 3 kicks in)
var expected = (nullable1, nullable2) is (false, true)
? "M1 M2 M3 M4 M5 M6(IntPtr) M7 M8 M9"
: "M1 M2 M3 M4 M5 M6(ushort) M7 M8 M9";
? "M1 M2 M3 M4 M5 M6(IntPtr) M7 M8 M9 M10(IntPtr)"
: "M1 M2 M3 M4 M5 M6(ushort) M7 M8 M9 M10(byte)";
CompileAndVerify(comp, expectedOutput: expected);
}

Expand Down

0 comments on commit 06df1b7

Please sign in to comment.