-
-
Notifications
You must be signed in to change notification settings - Fork 196
Closed
Description
Consider this:
package test70
import groovy.transform.CompileStatic
@CompileStatic
class Test70 {
void foo() {
Object v1 = 'a'
Object v2 = 'b'
[v1, v2].each {
v ->
if(v instanceof Map) {
v.entrySet().each { e ->
def s = e.value
if(s instanceof String)
e.value = s.toUpperCase()
}
}
}
}
}An error is given on both occurrences of e.value, because e is evaluated as Object instead of Map.Entry.
This used to work until some version of the Greclipse plugin (now I'm on 4.3.0.v202107132103-e2009).
If I compile this with Gradle/Groovy, the JAR is built successfully.
If I remove @CompileStatic, I get underlining for v.entrySet() and again on both occurrences of e.value.
If I try to give e a type in the closure:
v.entrySet().each { Entry e ->
def s = e.value
if(s instanceof String)
e.value = s.toUpperCase()
}I see this:
- with
@CompileStatican additional error is given onEntry, saying it's expectingObject. - without
@CompileStatic, instead, the underlining fore.valueis fixed, so the situation improves.
Reactions are currently unavailable
