This situation came up in code review and I was sure the old version should have caused a compile fail:
List<Child__c> children = new List<Child__c>();
for (Parent__c parent : parents)
{
children.add(parent.Children__r); // old version
children.addAll(parent.Children__r); // new version
}
Obviously, this code blew up as soon as it was run against a parent having multiple children (or none). Now, I understand why it is allowed, since you can assign a query result to a single record or to a collection. It just seems like this behavior should not be allowed for a related list. My question is, should this code have failed to compile? Is it a compiler bug, odd quirk of the language, or something else entirely?
Account a = [select Name from Account]
will compile but will throw a runtime exception if there are more than 1 or no record. So something similar to this construct, adding it to the list would still compile but fail only in the scenario you have mentioned.