[
https://issues.apache.org/jira/browse/GROOVY-11305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-11305:
---------------------------------
Description:
Consider the following:
{code:groovy}
class C { // implicitly Iterable<String>
Iterator<String> iterator() {} // sometimes supplied via DGM
}
@TypeChecked
void test(C c) {
for (string in c) {
string.toUpperCase()
}
}
{code}
If "@TypeChecked" is removed, this works. STC cannot determine the loop
element type -- see {{StaticTypeCheckingVisitor#inferLoopElementType}} and
compare with {{inferComponentType}} which runs for spread.
was:
Consider the following:
{code:groovy}
class C { // implicitly Iterable<String>
Iterator<String> iterator() {}
}
@TypeChecked
void test(C c) {
for (string in c) {
string.toUpperCase()
}
}
{code}
If "@TypeChecked" is removed, this works. STC cannot determine the loop
element type -- see {{StaticTypeCheckingVisitor#inferLoopElementType}} and
compare with {{inferComponentType}} which runs for spread.
> STC: support for-each or for-in loop for implicitly-Iterable type
> -----------------------------------------------------------------
>
> Key: GROOVY-11305
> URL: https://issues.apache.org/jira/browse/GROOVY-11305
> Project: Groovy
> Issue Type: Improvement
> Components: Static Type Checker
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
>
> Consider the following:
> {code:groovy}
> class C { // implicitly Iterable<String>
> Iterator<String> iterator() {} // sometimes supplied via DGM
> }
> @TypeChecked
> void test(C c) {
> for (string in c) {
> string.toUpperCase()
> }
> }
> {code}
> If "@TypeChecked" is removed, this works. STC cannot determine the loop
> element type -- see {{StaticTypeCheckingVisitor#inferLoopElementType}} and
> compare with {{inferComponentType}} which runs for spread.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)