4

I've been using Lombok extensively for my projects. I love it and wish it were supported officially so that the maintainers did not have to use internal APIs to continue developing, but that is a topic for another time.

Every so often, I'll run into the following issue during compilation when using val (which I also use extensively as it saves a lot of typing):

Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved

The last time this happened in two spots:

  • As a return value to a function that returns a Map<UUID, List<SomeObject>>
  • As a return value to a function that returns a List<UUID>

I've used val for the latter type before, as well as for much more complex objects than the former. However, inexplicably val did not work here. The final solution was just to omit val in these spots (though it is used extensively throughout the rest of the class with no problems).

So, the question is: how can I debug val (and potentially, var) in Lombok? How can I debug what it goes through to generate the type, to find out whether this is a bug in Lombok (that I might try to fix), or if for some reason my code base was misbehaving?

filpa
  • 3,651
  • 8
  • 52
  • 91

1 Answers1

0

Probably, there is some bug with the val annotation processing. There is the issue.
Also, there is another bug with val. There is no warning about changing the value of val variable. It gives error only at run time. Be careful, it is easy to do a mistake.

Sergey Nemchinov
  • 1,348
  • 15
  • 21