There was a time when I used to say that the children of the Muslims would be with the Muslims and the children of the polytheists would be with the polytheists, until so-and-so reported to me from so-and-so that the Messenger of Allah ﷺ was asked about them and replied, "Allah knows best what they would have done."He said, "I then met the man, and he confirmed it to me, so I stopped saying what I had been saying."
أتى علي زمان، وأنا أقول: أولاد المسلمين مع المسلمين، وأولاد المشركين مع المشركين، حتى حدثني فلان، عن فلان، أن رسول الله ﷺ سئل عنهم فقال: الله أعلم بما كانوا عاملين. قال: فلقيت الرجل، فأخبرني فأمسكت عن قولي.
Imam Ahmad narrated it (20697, 23484) through two routes from Ammar bin Abu Ammar, from Ibn Abbas, and he mentioned it. Its chain of transmission is sahih. Ibn Abu Asim also narrated it through this route in Sunnah (214).