Type checking

Most of the constraint checks for an object-oriented language such as SmallJava will deal with type checking ; that is, checking that expressions and statements are well-typed.

We have already seen how to perform a simple form of type checking in the Expressions DSL (Chapter 8, An Expression Language). In this chapter, we will see an advanced type checking mechanism which includes Subtyping or type conformance: an object of class C can be used in a context where an object of a superclass of C is expected.

We will follow the same strategy illustrated in Chapter 8, An Expression Language: we will separate the type computation from the actual type checking. We will be able to generate the error on the sub-expression or statement that ...

Get Implementing Domain-Specific Languages with Xtext and Xtend now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.