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

Regression "warning: [cast] redundant cast to Map" when updating from 2.49 to 2.50 #4201

Closed
TWiStErRob opened this issue Dec 31, 2023 · 1 comment · Fixed by #4218
Closed

Comments

@TWiStErRob
Copy link

Repro Steps

  1. Clone https://github.com/TWiStErRob/repros/tree/main/dagger/hilt-viewmodel-redundant-cast-Map
  2. gradlew build

Expected

BUILD SUCCESSFUL

Actual

> Task :hiltJavaCompileDebug FAILED
P:\projects\bugs\dagger\hilt-viewmodel-redundant-cast-Map\build\generated\hilt\component_sources\debug\com\example\DaggerApp_HiltComponents_SingletonC.java:402: warning: [cast] redundant cast to Map
      return (Map) Collections.<String, javax.inject.Provider<ViewModel>>singletonMap("com.example.MyViewModel", ((Provider) myViewModelProvider));
             ^
error: warnings found and -Werror specified
1 error
1 warning

Control

  1. rm -rf build .gradle (Hard clean necessary for some reason when changing version)
  2. Edit build.gradle.kts: s/2.50/2.49/g
  3. gradlew build -> success

Context

There's a project that slowly migrates from Java 1.7 to Kotlin. The sourceCompatibility is intentionally kept low, so that the existing codebase doesn't show full of warnings ("can use lambdas") on all anonymous inner class listeners and other places. Up until 2.49 there was no issue, but when I updated to 2.50, I started getting this issue. The 2.50 release notes doesn't show anything relevant.

TWiStErRob added a commit to TWiStErRob/repros that referenced this issue Dec 31, 2023
@Chang-Eric
Copy link
Member

Thanks for reporting this. This got introduced in the last release because the Map types now hold different Provider types due to the Jakarta changes, and now may not be easily made to match the types request. I'll send a fix to suppress this warning.

copybara-service bot pushed a commit that referenced this issue Jan 17, 2024
These were introduced in a previous change that introduced the `dagger.internal.Provider` type. They are difficult to avoid with Map Providers.

Fixes #4201.

RELNOTES=Fixes #4201.
PiperOrigin-RevId: 596063894
copybara-service bot pushed a commit that referenced this issue Jan 19, 2024
These were introduced in a previous change that introduced the `dagger.internal.Provider` type. They are difficult to avoid with Map Providers.

Fixes #4201.

RELNOTES=Fixes #4201.
PiperOrigin-RevId: 596063894
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants