classage Y { mixer B { export void t0(Sub1 x) { return; } export void t1() { return; } export Sub2 t3() { return create Sub2(); } } connector N { } } classage X { plugger A { import void t0(Sub1 x) import void t1() export void t2() { } } plugger E { import void t4() } plugger F { import void t1(int x) } plugger G { import void t0(Sub2 x) } plugger H { import Sub1 t3() } plugger I { import void t0(Sub1 x) import Sub2 t3() } plugger J { 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(); } } singleton plugger U { import void t0(Sub1 x) export void t0(Sub2 x) {} import Sub2 t3() } plugger P { import A t1() } plugger Q { export void t1(A x) {return; } } connector N { } mixer K { } void t() { /***************************************************************** Followed is typechecking of plugin expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // M does not exist. // plugin M with A >> B; // N is not a classage although it does exist. // plugin N with A >> B; // M does not exist. // plugin Y with M >> B; // N is not a plugger although it does exist. // plugin Y with N >> B; // M does not exist // plugin Y with A >> M; // N is not a mixer although it does exist. // plugin Y with A >> N; // P as a plugger now pass values of the plug types upward // the plugging hierarchy, via return values of imports, // which violates "upward not OK". plugin Y with P >> B; // Q as a plugger now pass values of the plug types upward // the plugging hierarchy, via parameters of exports, // which violates "upward not OK". plugin Y with Q >> B; // some import in E is not satisfied by the other party. plugin Y with E >> B; // some import/export pair matched by name does not // have the same length of arguments. plugin Y with F >> B; // some import/export pair matched by name does not // conform to the subtyping constraints (contravariant violation) plugin Y with G >> B; // some import/export pair matched by name does not // conform to the subtyping constraints (covariant violation) plugin Y with H >> B; // this one typechecks I x1 = plugin Y 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 connector, and h can not be used with the .. expression forall(h::N) { h..t1(); } // type mismatch inside // I is a plugger, and h can not be used with the -> expression forall(h::I) { h->t0(); } /***************************************************************** Followed is typechecking of the unplug expression None of the expressions, unless noted otherwise, typecheck ******************************************************************/ // type mismatch, must be a plug handle type unplug 3; forall(h::N) { unplug 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); // for the following the test is to make the signature being used // is the import, to ensure soundness. // were it to use the export signature, the following would // typecheck, and the disaster would be when U is plugged in with // some export with the import signature, runtime error would ensue. 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() } }