On 28.08.23 02:25, Saravanan Palanichamy wrote: [...] I think I understand a bit better now...
[...]
The problem I run into however is when I use lists of mutable with immutables. For example, This entire code should be valid void fn(@ReadOnly Person me) { List<Person> myList = [] myList << me Map<String, Person> myMap = [:] myMap << me } This gets converted into void fn(Person.Immutable me) { List<Person.Mutable> myList = [] myList << me // Fails with me cannot be assigned to mutable list Map<String, Person.Mutable> myMap = [:] myMap["ME"] = me // Also fails because types dont match } How do I solve this? Are there other issues I am not foreseeing?
I think the substitution for List<Person> should then be List<Person.Mutable | Person Immutable>. While this cannot be expressed in source we have UnionTypeClassNode for this in the AST. Though that node is mainly for a different context and could cause compiler problems. bye Jochen