inferred type does not conform to upper bound(s)
See original GitHub issueFollowing 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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re using the version of
toTable
that accepts aSupplier
but not the version oftoMap
that accepts aSupplier
. Here’s the equivalent JDK code, which fails to compile: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 forTables.toTable
.@noelo-cohelo try the latest Java 8 version. maybe the issue is fixed