Skip to content

Commit d64c75d

Browse files
netdpbronshapiro
authored andcommitted
Fix incorrect raw return type for empty set factories.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132090272
1 parent 0322eb5 commit d64c75d

File tree

6 files changed

+92
-12
lines changed

6 files changed

+92
-12
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.multipackage;
18+
19+
import dagger.Component;
20+
import test.multipackage.a.AMultibindsModule;
21+
import test.multipackage.a.UsesInaccessible;
22+
23+
/**
24+
* A component that tests the interaction between multiple packages and {@code @Multibinding}s.
25+
* Specifically, we want:
26+
*
27+
* <ul>
28+
* <li>A {@code @Multibinding} for an empty set of a type not accessible from this package.
29+
* <li>A {@code @Multibinding} for an empty map of a type not accessible from this package.
30+
* <li>A public type that injects the empty set and map of inaccessible objects.
31+
* </ul>
32+
*/
33+
@Component(modules = {AMultibindsModule.class})
34+
interface MultibindsComponent {
35+
UsesInaccessible usesInaccessible();
36+
}

compiler/src/it/functional-tests/src/main/java/test/multipackage/a/AModule.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import dagger.multibindings.StringKey;
2626
import java.util.HashSet;
2727
import java.util.Set;
28-
import javax.inject.Inject;
2928

3029
@Module
3130
public abstract class AModule {
@@ -49,9 +48,4 @@ static Set<Inaccessible> provideSetOfInaccessibles() {
4948
@IntoMap
5049
@StringKey("inaccessible")
5150
abstract Inaccessible provideInaccessibleToMap(Inaccessible inaccessible);
52-
53-
static class Inaccessible {
54-
@Inject Inaccessible() {}
55-
}
56-
5751
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2015 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.multipackage.a;
18+
19+
import dagger.Module;
20+
import dagger.multibindings.Multibinds;
21+
import java.util.Map;
22+
import java.util.Set;
23+
24+
/** A module that {@code @Multibinds} a set and a map of {@link Inaccessible}. */
25+
@Module
26+
public abstract class AMultibindsModule {
27+
@Multibinds
28+
abstract Set<Inaccessible> inaccessibleSet();
29+
30+
@Multibinds
31+
abstract Map<String, Inaccessible> inaccessibleMap();
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.multipackage.a;
18+
19+
import javax.inject.Inject;
20+
21+
final class Inaccessible {
22+
@Inject Inaccessible() {}
23+
}

compiler/src/it/functional-tests/src/main/java/test/multipackage/a/UsesInaccessible.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Map;
2020
import java.util.Set;
2121
import javax.inject.Inject;
22-
import test.multipackage.a.AModule.Inaccessible;
2322

2423
@SuppressWarnings("unused")
2524
public class UsesInaccessible {

compiler/src/main/java/dagger/internal/codegen/MemberSelect.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static dagger.internal.codegen.TypeNames.MAP_PROVIDER_FACTORY;
2727
import static dagger.internal.codegen.TypeNames.MEMBERS_INJECTOR;
2828
import static dagger.internal.codegen.TypeNames.MEMBERS_INJECTORS;
29-
import static dagger.internal.codegen.TypeNames.SET;
3029

3130
import com.google.common.collect.ImmutableList;
3231
import com.squareup.javapoet.ClassName;
@@ -144,10 +143,7 @@ static MemberSelect emptyFrameworkMapFactory(
144143
*/
145144
static MemberSelect emptySetProvider(ClassName setFactoryType, SetType setType) {
146145
return new ParameterizedStaticMethod(
147-
setFactoryType,
148-
ImmutableList.of(setType.elementType()),
149-
CodeBlock.of("empty()"),
150-
SET);
146+
setFactoryType, ImmutableList.of(setType.elementType()), CodeBlock.of("empty()"), FACTORY);
151147
}
152148

153149
private static final class ParameterizedStaticMethod extends MemberSelect {

0 commit comments

Comments
 (0)