@@ -2,35 +2,35 @@ public class A
22{
33 public void M1 ( )
44 {
5- var c = new C ( ) ;
5+ var c = Source < C > ( 1 ) ;
66 var b = B . Make ( c ) ;
7- Sink ( b . c ) ; // flow
7+ Sink ( b . c ) ; // $ hasValueFlow=1
88 }
99
1010 public void M2 ( )
1111 {
1212 var b = new B ( ) ;
13- b . Set ( new C1 ( ) ) ;
14- Sink ( b . Get ( ) ) ; // flow
15- Sink ( ( new B ( new C ( ) ) ) . Get ( ) ) ; // flow
13+ b . Set ( Source < C1 > ( 2.1 ) ) ;
14+ Sink ( b . Get ( ) ) ; // $ hasValueFlow=2.1
15+ Sink ( ( new B ( Source < C > ( 2.2 ) ) ) . Get ( ) ) ; // $ hasValueFlow=2.2
1616 }
1717
1818 public void M3 ( )
1919 {
2020 var b1 = new B ( ) ;
2121 B b2 ;
22- b2 = SetOnB ( b1 , new C2 ( ) ) ;
23- Sink ( b1 . c ) ; // no flow
24- Sink ( b2 . c ) ; // flow
22+ b2 = SetOnB ( b1 , Source < C2 > ( 3 ) ) ;
23+ Sink ( b1 . c ) ;
24+ Sink ( b2 . c ) ; // $ hasValueFlow=3
2525 }
2626
2727 public void M4 ( )
2828 {
2929 var b1 = new B ( ) ;
3030 B b2 ;
31- b2 = SetOnBWrap ( b1 , new C2 ( ) ) ;
32- Sink ( b1 . c ) ; // no flow
33- Sink ( b2 . c ) ; // flow
31+ b2 = SetOnBWrap ( b1 , Source < C2 > ( 4 ) ) ;
32+ Sink ( b1 . c ) ;
33+ Sink ( b2 . c ) ; // $ hasValueFlow=4
3434 }
3535
3636 public B SetOnBWrap ( B b1 , C c )
@@ -52,7 +52,7 @@ public B SetOnB(B b1, C c)
5252
5353 public void M5 ( )
5454 {
55- var a = new A ( ) ;
55+ var a = Source < A > ( 5 ) ;
5656 C1 c1 = new C1 ( ) ;
5757 c1 . a = a ;
5858 M6 ( c1 ) ;
@@ -61,7 +61,7 @@ public void M6(C c)
6161 {
6262 if ( c is C1 )
6363 {
64- Sink ( ( ( C1 ) c ) . a ) ; // flow
64+ Sink ( ( ( C1 ) c ) . a ) ; // $ hasValueFlow=5
6565 }
6666 C cc ;
6767 if ( c is C2 )
@@ -80,47 +80,47 @@ public void M6(C c)
8080
8181 public void M7 ( B b )
8282 {
83- b . Set ( new C ( ) ) ;
83+ b . Set ( Source < C > ( 7 ) ) ;
8484 }
8585 public void M8 ( )
8686 {
8787 var b = new B ( ) ;
8888 M7 ( b ) ;
89- Sink ( b . c ) ; // flow
89+ Sink ( b . c ) ; // $ hasValueFlow=7
9090 }
9191
9292 public class D
9393 {
9494 public B b ;
9595 public D ( B b , bool x )
9696 {
97- b . c = new C ( ) ;
98- this . b = x ? b : new B ( ) ;
97+ b . c = Source < C > ( 9.1 ) ;
98+ this . b = x ? b : Source < B > ( 9.2 ) ;
9999 }
100100 }
101101
102102 public void M9 ( )
103103 {
104- var b = new B ( ) ;
104+ var b = Source < B > ( 9.3 ) ;
105105 var d = new D ( b , R ( ) ) ;
106- Sink ( d . b ) ; // flow x2
107- Sink ( d . b . c ) ; // flow
108- Sink ( b . c ) ; // flow
106+ Sink ( d . b ) ; // $ hasValueFlow=9.2 $ hasValueFlow=9.3
107+ Sink ( d . b . c ) ; // $ hasValueFlow=9.1
108+ Sink ( b . c ) ; // $ hasValueFlow=9.1
109109 }
110110
111111 public void M10 ( )
112112 {
113- var b = new B ( ) ;
113+ var b = Source < B > ( 10 ) ;
114114 var l1 = new MyList ( b , new MyList ( null , null ) ) ;
115115 var l2 = new MyList ( null , l1 ) ;
116116 var l3 = new MyList ( null , l2 ) ;
117117 Sink ( l3 . head ) ; // no flow, b is nested beneath at least one .next
118118 Sink ( l3 . next . head ) ; // flow, the precise nesting depth isn't tracked
119- Sink ( l3 . next . next . head ) ; // flow
119+ Sink ( l3 . next . next . head ) ; // $ hasValueFlow=10
120120 Sink ( l3 . next . next . next . head ) ; // no flow
121121 for ( var l = l3 ; l != null ; l = l . next )
122122 {
123- Sink ( l . head ) ; // flow
123+ Sink ( l . head ) ; // $ hasValueFlow=10
124124 }
125125 }
126126
@@ -160,4 +160,6 @@ public MyList(B head, MyList next)
160160 this . next = next ;
161161 }
162162 }
163+
164+ static T Source < T > ( object source ) => throw null ;
163165}
0 commit comments