[
https://issues.apache.org/jira/browse/GROOVY-12837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153540#comment-18153540
]
ASF GitHub Bot commented on GROOVY-12837:
-----------------------------------------
blackdrag commented on PR #3366:
URL: https://github.com/apache/groovy/pull/3366#issuecomment-7317225407
```
class Test{}
// write0
Map hints = [x: new Test()]
// read0
Test initial = hints.x
// write1
hints.single = true
// read1
Test value = hints.x
// read2
boolean bvalue = hints.sgingle
```
The proposal is to write the Boolean to the map, as it seems to be in Groovy
6.0.0, which 6.0.1 changed. The question though what will happen to the read.
If we treat hints as a Map<Object,Object>, which is what this PR does for the
write, then read1 and read2 must fail, because of the missing value type. but
why should it then work for read0 even?
For me it makes sense for hints to have the flow type <String,Integer>
initially, which means read0 works and write1 fails. I think writing a value to
the map should not change its flow type really. write0 is ok because it sets
the value for the variable.
> STC: a value written to a raw or def map started from a map literal is
> converted to the literal's inferred value type
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12837
> URL: https://issues.apache.org/jira/browse/GROOVY-12837
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 7.0.0-alpha-1, 6.0.1
> Reporter: Scott Murphy Heiberg
> Priority: Critical
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)