Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.17
-
None
Description
The following code will fail with the message
[Static type checking] - No such property: x for class: java.lang.Object @ line 8, column 13. .map{ it.x } ^
@groovy.transform.CompileStatic class AssertJCollectionMappingTest { @org.junit.jupiter.api.Test void mapping() { def texts = somePojos() org.assertj.core.api.Assertions.assertThat(texts) .map{ it.x } .containsExactlyInAnyOrderElementsOf(['a', 'b']) } private static Collection<Pojo> somePojos() { return [new Pojo(x: 'a'), new Pojo(x: 'b')] } static class Pojo { String x } }
Changing the line to
.map({ it.x } as Function<Pojo, String>)
makes it compile but it is clumsy for more complicated types.
It would be nice if Groovy was able to resolve the types without hints.
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-10153 STC: cannot combine use-variance with bounded polymorphism
- Closed
-
GROOVY-10651 STC: closure parameter type inference for raw type that is iterable over type parameter
- Closed
-
GROOVY-10671 STC fails to compile AssertJ fluent API expression
- Closed
-
GROOVY-10756 STC: parameterized and bounded return value for java class property
- Closed
-
GROOVY-11204 Incorrect overload selection for subclasses
- Closed