Solution (source code)

= Solution

Construct the mixed object with a concrete document implementation beneath the plugin:

``
val doc: DocImp with CharCountPlugin = new DocImp with CharCountPlugin
``

\b[Its type combines `DocImp` and `CharCountPlugin`], so document operations and `count` are available. For example, inserting two `'a'` characters and then deleting one leaves `doc.count('a') == 1`. The plugin is on the right of the concrete superclass in Scala's composition, so its edit methods extend the underlying implementations.