Skip to content

Commit cfe2a76

Browse files
committed
C#: Add viable callable test cases for statics in interfaces.
1 parent ab58d4c commit cfe2a76

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

csharp/ql/test/library-tests/dispatch/ViableCallable.cs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,75 @@ void Run(C19 c)
503503
// Viable callables: C19.op_CheckedExplicit()
504504
var n2 = checked((int)c);
505505
}
506-
}
506+
}
507+
508+
public interface I3<T> where T : I3<T>
509+
{
510+
static abstract T operator +(T x, T y);
511+
static abstract T operator checked +(T x, T y);
512+
513+
static abstract T operator -(T x, T y);
514+
static virtual T operator checked -(T x, T y) => throw null;
515+
516+
static virtual T operator *(T x, T y) => throw null;
517+
static virtual T operator checked *(T x, T y) => throw null;
518+
519+
static virtual T operator /(T x, T y) => throw null;
520+
static virtual T operator checked /(T x, T y) => throw null;
521+
522+
void M11();
523+
524+
virtual void M12() => throw null;
525+
526+
virtual void M13() => throw null;
527+
}
528+
529+
public class C20 : I3<C20>
530+
{
531+
public static C20 operator +(C20 x, C20 y) => throw null;
532+
public static C20 operator checked +(C20 x, C20 y) => throw null;
533+
534+
public static C20 operator -(C20 x, C20 y) => throw null;
535+
536+
public static C20 operator /(C20 x, C20 y) => throw null;
537+
public static C20 operator checked /(C20 x, C20 y) => throw null;
538+
539+
public void M11() { }
540+
public void M12() { }
541+
542+
void Run<T>(T c) where T : I3<T>
543+
{
544+
// Viable callables: C20.op_Addition(). MISSING: C20.op_Addition()
545+
var c1 = c + c;
546+
547+
// Viable callables: C20.op_CheckedAddition(). MISSING: C20.op_CheckedAddition()
548+
var c2 = checked(c + c);
549+
550+
// Viable callables: C20.op_Subtraction(). Missing: C20.op_Subtraction()
551+
var c3 = c - c;
552+
553+
// Viable callables: I3<C20>.op_CheckedSubtraction().
554+
var c4 = checked(c - c);
555+
556+
// Viable callables: I3<C20>.op_Multiply().
557+
var c5 = c * c;
558+
559+
// Viable callables: I3<C20>.op_CheckedMultiply().
560+
var c6 = checked(c * c);
561+
562+
// Viable callables: {C20,I3<C20>}.op_Division(). MISSING: C20.op_Division()
563+
var c7 = c / c;
564+
565+
// Viable callables: {C20,I3<C20>}.op_CheckedDivision(). MISSING: C20.op_CheckedDivision()
566+
var c8 = checked(c / c);
567+
568+
// Viable callables: C20.M11. MISSING: C20.M11()
569+
c.M11();
570+
571+
// Viable callables: {C20,I3<C20>}.M12(). MISSING: C20.M12()
572+
c.M12();
573+
574+
// Viable callables: I3<C20>.M13()
575+
c.M13();
576+
}
577+
}

0 commit comments

Comments
 (0)