• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1interface I1 {
2	IM1():void[];
3}
4
5class C1 implements I1 {
6	IM1():void[] {return null;}
7	C1M1():C1[] {return null;}
8 }
9class C2 extends C1 {
10    C2M1():C2[] { return null;}
11}
12
13class C3 {
14    CM3M1() { return 3;}
15}
16
17
18/*
19
20This behaves unexpectedly with the following types:
21
22Type 1 of any[]:
23
24* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].
25
26* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.
27
28*/
29var a1 : any = null;
30var c1 : C1 = new C1();
31var i1 : I1 = c1;
32var c2 : C2 = new C2();
33var c3 : C3 = new C3();
34var o1 = {one : 1};
35var f1 = function () { return new C1();}
36
37var arr_any: any[] = [];
38var arr_i1: I1[] = [];
39var arr_c1: C1[] = [];
40var arr_c2: C2[] = [];
41var arr_i1_2: I1[] = [];
42var arr_c1_2: C1[] = [];
43var arr_c2_2: C2[] = [];
44var arr_c3: C3[] = [];
45
46var i1_error: I1 = []; // should be an error - is
47var c1_error: C1 = []; // should be an error - is
48var c2_error: C2 = []; // should be an error - is
49var c3_error: C3 = []; // should be an error - is
50
51
52arr_any = arr_i1; // should be ok - is
53arr_any = arr_c1; // should be ok - is
54arr_any = arr_c2; // should be ok - is
55arr_any = arr_c3; // should be ok - is
56
57arr_i1 = arr_i1; // should be ok - subtype relationship - is
58arr_i1 = arr_c1; // should be ok - subtype relationship - is
59arr_i1 = arr_c2; // should be ok - subtype relationship - is
60arr_i1 = arr_c3; // should be an error - is
61
62arr_c1 = arr_c1; // should be ok - subtype relationship - is
63arr_c1 = arr_c2; // should be ok - subtype relationship - is
64arr_c1 = arr_i1; // should be an error - is
65arr_c1 = arr_c3; // should be an error - is
66
67arr_c2 = arr_c2; // should be ok - subtype relationship - is
68arr_c2 = arr_c1; // should be an error - subtype relationship - is
69arr_c2 = arr_i1; // should be an error - subtype relationship - is
70arr_c2 = arr_c3; // should be an error - is
71
72// "clean up bug" occurs at this point
73// if you move these three expressions to another file, they raise an error
74// something to do with state from the above propagating forward?
75arr_c3 = arr_c2_2; // should be an error - is
76arr_c3 = arr_c1_2; // should be an error - is
77arr_c3 = arr_i1_2; // should be an error - is
78
79arr_any = f1; // should be an error - is
80arr_any = o1; // should be an error - is
81arr_any = a1; // should be ok - is
82arr_any = c1; // should be an error - is
83arr_any = c2; // should be an error - is
84arr_any = c3; // should be an error - is
85arr_any = i1; // should be an error - is