[^amakeev] backport matching from master (IDEA-107152)