@@ -4,12 +4,22 @@ public class Operators
44 static void Sink ( object o ) { }
55 static T Source < T > ( object source ) => throw null ;
66
7- public class C
7+ public interface I < T > where T : I < T >
8+ {
9+ static virtual T operator * ( T x , T y ) => x ;
10+ static abstract T operator / ( T x , T y ) ;
11+ static abstract T operator checked / ( T x , T y ) ;
12+ }
13+
14+ public class C : I < C >
815 {
916 public static C operator + ( C x , C y ) => x ;
1017
1118 public static C operator checked - ( C x , C y ) => y ;
1219 public static C operator - ( C x , C y ) => x ;
20+
21+ public static C operator / ( C x , C y ) => y ;
22+ public static C operator checked / ( C x , C y ) => y ;
1323 }
1424
1525 public void M1 ( )
@@ -35,4 +45,43 @@ public void M3()
3545 var z = checked ( x - y ) ;
3646 Sink ( z ) ; // $ hasValueFlow=6
3747 }
48+
49+ public void M4Aux < T > ( T x , T y ) where T : I < T >
50+ {
51+ var z = x * y ;
52+ Sink ( z ) ; // $ hasValueFlow=7
53+ }
54+
55+ public void M4 ( )
56+ {
57+ var x = Source < C > ( 7 ) ;
58+ var y = Source < C > ( 8 ) ;
59+ M4Aux ( x , y ) ;
60+ }
61+
62+ public void M5Aux < T > ( T x , T y ) where T : I < T >
63+ {
64+ var z = x / y ;
65+ Sink ( z ) ; // $ hasValueFlow=10
66+ }
67+
68+ public void M5 ( )
69+ {
70+ var x = Source < C > ( 9 ) ;
71+ var y = Source < C > ( 10 ) ;
72+ M5Aux ( x , y ) ;
73+ }
74+
75+ public void M6Aux < T > ( T x , T y ) where T : I < T >
76+ {
77+ var z = checked ( x / y ) ;
78+ Sink ( z ) ; // $ hasValueFlow=12
79+ }
80+
81+ public void M6 ( )
82+ {
83+ var x = Source < C > ( 11 ) ;
84+ var y = Source < C > ( 12 ) ;
85+ M6Aux ( x , y ) ;
86+ }
3887}
0 commit comments