In this chapter we presented type checking techniques that are typical for a DSL with object-oriented features. A small Java-like language was introduced to demonstrate how to parse features such as member access and inheritance and how to handle validation of type conformance.
There is however a crucial aspect that we still have to deal with: correct access to members (fields and methods). In fact, the selection expression
e.f
is well-typed only if the field f
is declared in the class of e
(similarly for methods) or in any superclass of the class of e
. If you perform some experiments, you will note that at the moment, you can access members which are not declared in the class of the receiver expression, and that you cannot access all the members of the hierarchy of the class of the receiver expression. Furthermore, local variable access does not work correctly in the current implementation: you can also refer to variables defined later and variables defined in inner blocks.
In order...