manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.39k stars 125 forks source link

Use method reference operator (::) throws ClassCastException #166

Open johnnychow1 opened 4 years ago

johnnychow1 commented 4 years ago

Describe the bug Use method reference operator (::) throws ClassCastException

To Reproduce This code works fine:

MyQuery query = MyQuery.builder().build(); MyQuery.Result result = query.request(ENDPOINT).post(); List resultList = result.getGeneratedObjects().stream() .map(obj->MyDomainObjectMapper.map(obj)) .collect(Collectors.toList());

However code below fails and throws java.lang.ClassCastException: manifold.api.json.DataBindings cannot be cast to queries$MyQuery$Result$generatedObject

MyQuery query = MyQuery.builder().build(); MyQuery.Result result = query.request(ENDPOINT).post(); List resultList = result.getGeneratedObjects().stream() .map(MyDomainObjectMapper::map) .collect(Collectors.toList());

rsmckinney commented 4 years ago

As you've discovered method refs are not yet supported with extension methods, instead please use lambda expressions for this use-case. Thanks.

similar: https://github.com/manifold-systems/manifold/issues/64

johnnychow1 commented 4 years ago

Thanks for the quick responses. Looking forward to see it supported soon :)