question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Lombok 1.18.0

Works:

Stream.of(DocumentCapability.DOCUMENT_TO_PDF, DocumentCapability.DOCUMENT_TO_TEXT)
            .map(
                c -> {
                  CapabilityStatusRecord s = new CapabilityStatusRecord();
                  s.setCapability(c);
                  return s;
                })
            .collect(Collectors.toList());

Doesn’t work:

Stream.of(DocumentCapability.DOCUMENT_TO_PDF, DocumentCapability.DOCUMENT_TO_TEXT)
            .map(
                c -> {
                  val s = new CapabilityStatusRecord();
                  s.setCapability(c);
                  return s;
                })
            .collect(Collectors.toList());

Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
bjconlan-fccommented, Dec 3, 2018

I’m seeing the aformentioned behavior in 1.18.4. (using gradle/intellij (with latest plugin circa 2018-12-01))

-Surprisingly its happening within a ‘try’ as opposed to a lamda-

Looks like this might be a red herring. The root of the issue was:

val future = CompletableFuture.supplyAsync(() -> CompletableFuture.completedFuture(1));
try {
  val result = future.get();
...

explicitly defining the generic type solved the problem: val future = CompletableFuture.<Integer>supplyAsync(() -> CompletableFuture.completedFuture(1));

0reactions
kakalote1commented, Sep 16, 2022

With 1.18.6, I still faced this issue. Is there a solution now? @mplushnikov

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I debug lombok val? - Stack Overflow
Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved.
Read more >
Cannot use 'val' here because initializer expression does not ...
Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved.
Read more >
Declaring Val and Var Variables in Lombok - Baeldung
Learn how to use Lombok's val and var to define local variables without specifying the type.
Read more >
Lomboker Eclipse Plugin (Day 3)
java:[648,7] error: Cannot use 'var' here because initializer expression does not have a representable type: Type cannot be resolved [ERROR] src ...
Read more >
val - Project Lombok
You can use val as the type of a local variable declaration instead of actually writing the type. When you do this, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found