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.

Inject: Kotlin support for sets and map

See original GitHub issue

Hi,

Currently we have to explicity specify java.util.Set and java.util.Map for kotlin bindings when using @ProvidesIntoSet or bindIntoSet

It would be great if we could support Kotlin Sets and Maps or at least this limitation is documented:

Works:

class Test @Inject constructor(val set: java.util.Set<Hej>)

Breaks:

class Test @Inject constructor(val set: Set<Hej>)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
eduard-vasinskyicommented, Oct 22, 2021

@richarddd Thank you for providing a test!

The problem was with Kotlin’s declaration-site variance Set in Kotlin is declared as Set<out E>, which leads to Set<Container> dependency result in Set<? extends Container>

We have fixed a type resolution in the master branch. You can try it out by installing the latest version of ActiveJ from the master branch locally (using ./install.sh script from project root) and then changing the ActiveJ dependency version in pom.xml to 5.0-SNAPSHOT.

This will be part of a final ActiveJ v5.0 release

0reactions
eduard-vasinskyicommented, Feb 17, 2022

@richarddd Feel free to reopen this if the issue still persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Map-specific operations - Kotlin
To perform operations on all keys or all values of a map, you can retrieve them from the properties keys and values accordingly....
Read more >
Working With Maps in Kotlin - Baeldung
Maps are a powerful tool for programmers because they support fast read and write access, even with large sets of data.
Read more >
Implicitly map to set in Kotlin - Stack Overflow
Looking at the library code, the only other way to do this would be to call mapTo which takes a destination collection: oldSet....
Read more >
Add a map to your Android app (Kotlin) - Google Developers
1. Before You Begin · 2. Get set up · 3. Quick start · 4. Add Google Maps · 5. Cloud-based map styling...
Read more >
Use collections in Kotlin - Android Developers
What you'll learn · How to create and modify arrays. · How to use List and MutableList . · How to use Set...
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