Fixed contextual type resolution and type checking for tagged template expressions.

Fixes #1472.