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.

inferred type does not conform to upper bound(s)

See original GitHub issue

Following code does not compile in javac (however, in compiles in Eclipse):

final Table<Integer, Integer, Integer> destination = HashBasedTable.create();
final Map<Integer, Integer> source = new HashMap<>();

// compiles
final Table<Integer, Integer, Integer> broker = source.entrySet().stream().collect( Tables.toTable( e -> 0, e -> 0, e -> 0, ( e1, e2 ) -> 0, HashBasedTable::create ) );
destination.putAll( broker );

// doesn't compile
destination.putAll( source.entrySet().stream().collect( Tables.toTable( e -> 0, e -> 0, e -> 0, ( e1, e2 ) -> 0, HashBasedTable::create ) ) );

I guess the problem could be with Guava, because when I do the same on simple maps like that, everything works fine:

Map<Integer, Integer> destination = new HashMap<>();
Map<Integer, Integer> source = new HashMap<>();

Map<Integer, Integer> broker = source.entrySet().stream().collect(Collectors.toMap(e -> 0, e -> 0));
destination.putAll(broker);

destination.putAll(source.entrySet().stream().collect(Collectors.toMap(e -> 0, e -> 0)));

I reported this to Oracle, and they want me to provide a case with native JDK, which I am not able to do, so if you’ll say it’s Java compiler fault, it would be really great if you could help me with such example.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cpovirkcommented, Feb 20, 2019

You’re using the version of toTable that accepts a Supplier but not the version of toMap that accepts a Supplier. Here’s the equivalent JDK code, which fails to compile:

    destination.putAll(
        source.entrySet().stream()
            .collect(Collectors.toMap(e -> 0, e -> 0, (e1, e2) -> 0, HashMap::new)));

I do suspect that this is just a case in which type inference isn’t powerful enough for what we want, but if the outcome of the Oracle bug is “Oh, no, we should change the signature of Collectors.toMap,” then do let us know, as we should probably do the same for Tables.toTable.

0reactions
landawncommented, Mar 1, 2019

@noelo-cohelo try the latest Java 8 version. maybe the issue is fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inferred type does not conform to upper bound(s)
Correction : Your map function expects a method that returns some reference type, but neg has a void return type.
Read more >
inferred type does not conform to upper bound(s)"? (Example)
First, you need to clear the change you made to getHighestValueIndexHousingRecordDeclaratively() which was returning "Optional<HousingRecord>".
Read more >
error at compile time:inferred type does not conform to upper ...
A DESCRIPTION OF THE PROBLEM : Attached code does not compile. I use Guava 27.0-jre. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :...
Read more >
Inferred type does not conform to upper bound in ... - GitHub
When building the latest spring-framework from GitHub, the code is not building and failing at module spring-web. Just a brief for the issue....
Read more >
"inferred type arguments do not conform to method's type ...
I get the following error: inferred type arguments [Nothing,List[String]] do not conform to method nonEmpty's type parameter bounds [T,A ...
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