Although Optional<Integer> is sybtype Optional<? extends Number> Optional<? extends Number> , Optional<Optional<Integer>> not a subtype of Optional<Optional<? extends Number>> Optional<Optional<? extends Number>> . You would get the same compilation error if you tried to assign Optional<Integer> to Optional<Number> , even if Integer extends Number .
To understand this better, replace Optional<Integer> whith X and Optional<? extends Number> Optional<? extends Number> to Y You'll get:
Optional<X> a = Optional.of(...); Optional<Y> b = a;
X is a subtype of Y , but Optional<X> not a subtype of Optional<Y> , it is a subtype of Optional<? extends Y> Optional<? extends Y>
It turns out that Optional<Optional<Integer>> is a subtype of Optional<? extends Optional<? extends Number>> Optional<? extends Optional<? extends Number>> Optional<? extends Optional<? extends Number>> .
Now consider the second case:
Optional<Optional<Integer>> a = Optional.of(Optional.of(1)); Optional<Optional<? extends Number>> c = a.map(x->x);
Here the compiler sees that the map result should be Optional<Optional<? extends Number>> Optional<Optional<? extends Number>> and tries to infer this type in the map method. So the display function
Function<? super T, ? extends U> mapper
becomes
Function<? super Optional<Integer>, ? extends Optional<? extends Number>>
because map returns Optional<U> and U in our case is displayed as Optional<? extends Number> Optional<? extends Number>
And map returns exactly what we need:
Optional<? extends Optional<? extends Number>>
So, in response to your comment
What new information .map(x -> x) provide?
.map(x -> x) helps the compiler infer the correct type
Useful resources: