Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type mismatch: cannot convert from Object to Map<String,IndexType> #1971

Closed
AlJohri opened this issue Dec 10, 2021 · 2 comments · Fixed by #2004
Closed

Type mismatch: cannot convert from Object to Map<String,IndexType> #1971

AlJohri opened this issue Dec 10, 2021 · 2 comments · Fixed by #2004
Assignees
Labels

Comments

@AlJohri
Copy link

AlJohri commented Dec 10, 2021

Apologies if this issue is opened in the wrong place, but I'm running into a strange error where out of two equivalent lines in Java, both of which compile just fine, one gives me an error in my VSCode IDE.

This line gives me an error:

private static final Map<String, IndexType> INDEX_TYPE_MAP = Arrays.stream(IndexType.values())
    .collect(collectingAndThen(toMap(Enum::toString, Function.identity()), ImmutableMap::copyOf));

While this entirely equivalent line does not:

private static final Map<String, IndexType> INDEX_TYPE_MAP = ImmutableMap.copyOf(
    Arrays.stream(IndexType.values())
          .collect(toMap(Enum::toString, Function.identity())));

This line is defined in an enum using the common pattern of converting an enum to a key value pair map.

The error is: Type mismatch: cannot convert from Object to Map<String,IndexType> Java(16777233) from VSCode.

Java imports here
import java.util.Arrays;
import com.google.common.collect.ImmutableMap;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toMap;
import java.util.function.Function;
@snjeza snjeza added the upstream label Feb 1, 2022
@snjeza snjeza self-assigned this Feb 1, 2022
@snjeza
Copy link
Contributor

snjeza commented Feb 1, 2022

snjeza added a commit to snjeza/eclipse.jdt.ls that referenced this issue Feb 3, 2022
@snjeza
Copy link
Contributor

snjeza commented Feb 3, 2022

This issue is an eclipse upstream issue. It has been fixed in the latest Eclipse build.

@rgrunber rgrunber added this to the End February 2022 milestone Feb 3, 2022
snjeza added a commit that referenced this issue Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants