Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.36k stars 76 forks source link

Using Java 8 to compile the library causes strange things regarding type inference #199

Closed Zhuinden closed 3 years ago

Zhuinden commented 4 years ago

So the library is exposed as a Java 1.7 library, and it's a good thing that it is.

That way, the tests compile, and the library works correctly. 👍

However, if the library is compiled with Java 1.8, then you can get stupid things like History.of(root) being resolved to be expected to be Object[] instead of Object, which it is not, and an explicit <Object> would be needed (the problem happened when jumpToRoot() was called, copying the project source code into a Java 8 project directly).

This might require more investigation, although it does work correctly. Thanks Java 8 for cryptic problems, though - never expected to see that kind of thing around here. 🤔

Zhuinden commented 4 years ago

Apparently the tests don't compile at all and you need to type a bunch of <Object>s in the assertions, because it claims that type inference is ambiguous.

Rather interesting. Either way, thankfully Java 7 is the most reliable thing to use for Android anyways, may as well stick to it while able.

Using the library as a library is not affected, only if the source is directly added to the project.

iNoles commented 4 years ago

By reading https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.1, T... is really is T[].

Zhuinden commented 4 years ago

There's a good chance that if this becomes a problem, I'll just convert the whole thing to Kotlin 🤔