]> git.buserror.net Git - polintos/scott/priv.git/blob - idlcomp/tests/namespace-precedence.idl
Initial checkin from Perforce.
[polintos/scott/priv.git] / idlcomp / tests / namespace-precedence.idl
1 interface Object {
2         guid: "4E9538F2-03E0-11DA-A88E-000A95BB581A";
3 };
4
5 namespace A {
6    struct D {
7    };
8    
9    struct F {
10    };
11
12    // A.G is declared as a namespace; no attempt is made to look for
13    // a global G.
14    struct G.Q {
15    };
16 }
17
18 struct B {
19    struct C {
20       struct X {
21       };
22    };
23    
24    struct G {
25    };
26    
27    struct H {
28    };
29
30         struct I {
31         };
32 };
33
34 struct D {
35         // Imports B and B.C, not B and C.  If it were "using C.*, B.*",
36         // then it would import C and C.B.
37
38    using B.*, C.*;
39    using System.B.I;
40    
41    struct E {
42 //      B b;    // Error, Uses C.B, rule #2 once D is reached.  Only the
43                         // contents of namespaces are imported, not the
44                         // names themselves.
45 //      C.D cd; // Error.  For the same reason as above, C refers
46               // to B.C, not C.  There is no D in B.C.
47       C.X cx; // Uses B.C.X.
48       D d;    // Uses C.D, rule #2 when D is reached.  D itself
49               // is declared in the global namespace, which doesn't
50               // get reached because a match is found sooner.
51       E e;    // Uses D.E, rule #1 once D is reached.  C.E would 
52               // have been matched by rule #2 if D.E did not exist.
53       F f;    // Uses C.F, rule #2 once D is reached.  A.F is not
54               // matched, as importation is not transitive.
55       G g;    // Uses B.G, rule #2
56 //      H h;    // Error, both B.H and C.H match on rule #2 once
57               // D is reached.  B does not get precedence for
58               // coming first, or because the C importation
59               // comes after this lookup.
60                 I i;    // Uses B.I, as specific-symbol imports are treated
61                         // as symbols declared in this namespace, rather than
62                         // imports (and thus B.I has precedence over C.I).
63    };
64    
65 //   int I;     // Error; this conflicts with the specific-symbol
66                    // importation of B.I.
67
68    // Now C is imported.  This importation is valid through the
69    // entire namespace (except for prior using statements), not just
70    // after this point.
71    
72    using System.C.*;
73 };
74
75 namespace C {
76    using A.*;
77    
78    struct D {
79    };
80    
81    struct E {
82    };
83    
84    struct F {
85    };
86    
87    struct H {
88    };
89
90         struct I {
91         };
92    
93    struct B.E {
94       struct F {
95       };
96       
97       struct E {
98       };
99       
100 //      B b;    // Error: Uses C.B, rule #1 once C is reached, 
101               // but C.B is not a type
102       D d;    // Uses C.D, rule #1 once C is reached
103       B.E be; // Uses C.B.E, rule #1 once C is reached
104       E e;    // Uses C.B.E.E, rule #1 in current namespace
105 //      E.E ee; // Error, as the first E matches C.B.E.E, and
106               // there is no C.B.E.E.E.  The extra .E is
107               // not used for disambiguation.
108       F f;    // Uses C.B.E.F, rule #1 in current namespace
109 //      G g;    // Error: Uses A.G, rule #2 once namespace C is reached.
110       H h;    // Uses C.H, rule #1 once namespace C is reached.
111    };
112 }