Added patterns for initialization for Scala #2297 (forward-port)

(cherry-picked from e2aa3b5)