classage Y { connector B { export void t0(Sub1 x) { return; } export void t1() { return; } export Sub2 t3() { return create Sub2(); } } plugger N { } } classage X { connector A { import void t0(Sub1 x) import void t1() export void t2() { } } connector E { import void t4() } connector F { import void t1(int x) } connector G { import void t0(Sub2 x) } connector H { import Sub1 t3() } connector I { import void t0(Sub1 x) import Sub2 t3() } connector J { state int fieldx = 0; import void t0(Sub1 x) import Sub2 t3() export void t5() { /***************************************************************** Followed is typechecking of passive invocation expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // t1 does not exist t1(); // type mismatch on the contravariants t0(); t0(3); // however the following works t0(create Sub1()); // type mismatch on assignment, a test on the covariant int x = t3(); Sub1 y = t3(); // however the following works Sub2 z = t3(); /***************************************************************** Followed is typechecking of per-connection state access expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // fieldc does not exist // fieldc = true; // Sub1 yyy = fieldc; // type mismatch fieldx = true; Sub1 yyy = fieldx; } } singleton connector U { import void t0(Sub1 x) import Sub2 t3() } connector P { import N t1(N x) } connector Q { export N t1(N x) {return x; } } connector R { import A t1(A x) } connector S { export A t1(A x) {return x; } } plugger N { } mixer K { } void t(N xh, Y yh) { /***************************************************************** Followed is typechecking of connect expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // xh is not of an objectage type connect xh with A >> B; // M does not exist. // connect yh with M >> B; // N is not a connector although it does exist. connect yh with N >> B; // M does not exist connect yh with A >> M; // N is not a plugger although it does exist. connect yh with A >> N; // P as a connector now pass values of the plug types // via return values or parameters of imports. // violation connect yh with P >> B; // Q as a connector now pass values of the plug types // via return values or parameters of exports, // violation connect yh with Q >> B; // R as a connector now pass values of the connection types // via return values or parameters of imports. // violation connect yh with R >> B; // S as a connector now pass values of the connection types // via parameters or parameters of exports, // violation connect yh with S >> B; // some import in E is not satisfied by the other party. connect yh with E >> B; // some import/export pair matched by name does not // have the same length of arguments. connect yh with F >> B; // some import/export pair matched by name does not // conform to the subtyping constraints (contravariant violation) connect yh with G >> B; // some import/export pair matched by name does not // conform to the subtyping constraints (covariant violation) connect yh with H >> B; // this one typechecks I x1 = connect yh with I >> B; /***************************************************************** Followed is typechecking of the e->m() expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // t2 does not exist x1->t2(); // type mismatch on the contravariants x1->t0(); x1->t0(3); x1->t0(create Sub2()); // however the following works x1->t0(create Sub1()); // type mismatch on assignment, a test on the covariant int x = x1->t3(); Sub1 y = x1->t3(); // however the following works Sub2 z = x1->t3(); /***************************************************************** Followed is typechecking of the forall expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // M does not exist // forall(h::M) { h->t1(); } // although K exists, it is neither a plugger nor a connector forall(h::K) { h->t1(); } // type mismatch inside // N is a plugger, and h can not be used with the -> expression forall(h::N) { h->t1(); } // type mismatch inside // I is a connector, and h can not be used with the .. expression forall(h::I) { h..t0(); } /***************************************************************** Followed is typechecking of the disconnect expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // type mismatch, must be a connection handle type disconnect 3; forall(h::N) { disconnect h; } /***************************************************************** Followed is typechecking of the X::m() expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // M does not exist // M::t0(create Sub2()); // although I exists, it is not an singleton I::t0(create Sub2()); // m does not exist U::m(create Sub2()); // type mismatch on the contravariants U::t0(); U::t0(3); // note: different from plugger case, connectors do not allow // overriding. So we do not need pay extra attention to t0's // type. It makes the following test no different from the // other two tests immediately above. Compare with the plugger // test case. U::t0(create Sub2()); // however the following works U::t0(create Sub1()); // type mismatch on assignment, a test on the covariant int xx = U::t3(); Sub1 yy = U::t3(); // however the following works Sub2 zz = U::t3(); return; } } classage Sub1 { connector E { export void a() { return; } } } classage Sub2 { connector E { export void a() { return; } import void c() } }