-
Notifications
You must be signed in to change notification settings - Fork 24
Fix injecting generic types extending generic types #765
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f8f7d30
fix injecting generic types extending generic types
SentryMan 0b924ce
provider test
SentryMan 85f8728
Update TypeAppender.java
SentryMan de421c2
Update TypeAppender.java
SentryMan a308b4a
Add test with assertions, use original format (so that diff is clearer)
rbygrave 57dc986
Test only - Add to generic provider BProv test
rbygrave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
blackbox-test-inject/src/main/java/org/example/myapp/generic/Aldrich.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.example.myapp.generic; | ||
|
||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
public interface Aldrich<T, T2> extends BiConsumer<T, T2>, Consumer<BiConsumer<T, T2>> {} |
4 changes: 4 additions & 0 deletions
4
blackbox-test-inject/src/main/java/org/example/myapp/generic/MyA.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.example.myapp.generic; | ||
|
||
public interface MyA { | ||
} |
4 changes: 4 additions & 0 deletions
4
blackbox-test-inject/src/main/java/org/example/myapp/generic/MyB.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.example.myapp.generic; | ||
|
||
public interface MyB { | ||
} |
9 changes: 9 additions & 0 deletions
9
blackbox-test-inject/src/main/java/org/example/myapp/generic/MyConsumer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.example.myapp.generic; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class MyConsumer implements BiConsumer<MyA, MyB> { | ||
|
||
@Override | ||
public void accept(MyA t, MyB u) {} | ||
} |
37 changes: 37 additions & 0 deletions
37
blackbox-test-inject/src/main/java/org/example/myapp/generic/MyConsumerFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.example.myapp.generic; | ||
|
||
import io.avaje.inject.Bean; | ||
import io.avaje.inject.Factory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.BiConsumer; | ||
|
||
@Factory | ||
class MyConsumerFactory { | ||
|
||
@Bean | ||
MyConsumer createTest() { | ||
return new MyConsumer(); | ||
} | ||
|
||
@Bean | ||
Map<String, MyConsumer> genericMap(BiConsumer<MyA, MyB> consumer) { | ||
return new HashMap<>(); | ||
} | ||
|
||
@Bean | ||
Aldrich<String, String> bean() { | ||
return new Aldrich<>() { | ||
@Override | ||
public void accept(String s, String s2) { | ||
|
||
} | ||
|
||
@Override | ||
public void accept(BiConsumer<String, String> stringStringBiConsumer) { | ||
|
||
} | ||
}; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
blackbox-test-inject/src/main/java/org/example/myapp/generic/MyUseGenericDependencies.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.example.myapp.generic; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import java.util.Map; | ||
import java.util.function.BiConsumer; | ||
|
||
@Singleton | ||
class MyUseGenericDependencies { | ||
|
||
private final Aldrich<String, String> aldrich; | ||
private final Map<String, MyConsumer> genericMap; | ||
private final BiConsumer<MyA, MyB> biConsumer; | ||
|
||
MyUseGenericDependencies(Aldrich<String, String> aldrich, | ||
Map<String, MyConsumer> genericMap, | ||
BiConsumer<MyA, MyB> biConsumer) { | ||
this.aldrich = aldrich; | ||
this.genericMap = genericMap; | ||
this.biConsumer = biConsumer; | ||
} | ||
|
||
Aldrich<String, String> getAldrich() { | ||
return aldrich; | ||
} | ||
|
||
Map<String, MyConsumer> getGenericMap() { | ||
return genericMap; | ||
} | ||
|
||
BiConsumer<MyA, MyB> getBiConsumer() { | ||
return biConsumer; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...ct-generator/src/test/java/io/avaje/inject/generator/models/valid/generic/MyConsumer.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...rator/src/test/java/io/avaje/inject/generator/models/valid/generic/MyConsumerFactory.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
inject-generator/src/test/java/io/avaje/inject/generator/models/valid/provider/BProv.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.avaje.inject.generator.models.valid.provider; | ||
|
||
public class BProv<T> { | ||
|
||
final T value; | ||
|
||
public BProv(T value) { | ||
this.value = value; | ||
} | ||
|
||
public T get() { | ||
return value; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...enerator/src/test/java/io/avaje/inject/generator/models/valid/provider/BProvProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.avaje.inject.generator.models.valid.provider; | ||
|
||
import io.avaje.inject.Component; | ||
import jakarta.inject.Provider; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
@Component | ||
public class BProvProvider implements Provider<BProv<String>> { | ||
|
||
AtomicInteger counter = new AtomicInteger(); | ||
|
||
@Override | ||
public BProv<String> get() { | ||
return new BProv<>("Hello BProv" + counter.incrementAndGet()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
inject-test/src/test/java/org/example/coffee/provider/BProvUser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.example.coffee.provider; | ||
|
||
import io.avaje.inject.Component; | ||
import jakarta.inject.Provider; | ||
|
||
@Component | ||
class BProvUser { | ||
|
||
private final Provider<BProv<String>> provider; | ||
|
||
BProvUser(Provider<BProv<String>> provider){ | ||
this.provider = provider; | ||
} | ||
|
||
Provider<BProv<String>> getProvider() { | ||
return provider; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that this is effectively the fix here.