CS153/hw6/hw5programs/tc_subtyping7.oat
jmug cfe502c598 Add all the assignment code.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
2025-01-24 18:59:28 -08:00

20 lines
No EOL
330 B
Text

struct A { int x }
struct B { int x ; int y }
struct C { int x ; int y ; int z }
/* C <: B B <: B */
/* ---------------------- */
/* (B) -> B <: (C) -> B */
B f(B b) {
return b;
}
B g((C) -> B f) {
var c = new C {x = 1; y = 2; z = 3};
return f(c);
}
int program(string[] args) {
var b = g(f);
return b.y;
}