[BZ-1039586] fix PatternBuilder for patterns referencing this as a declaration