Skip to content

Commit

Permalink
Fix incorrect raw return type for empty set factories.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132090272
  • Loading branch information
netdpb authored and ronshapiro committed Sep 6, 2016
1 parent 0322eb5 commit d64c75d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2016 The Dagger Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package test.multipackage;

import dagger.Component;
import test.multipackage.a.AMultibindsModule;
import test.multipackage.a.UsesInaccessible;

/**
* A component that tests the interaction between multiple packages and {@code @Multibinding}s.
* Specifically, we want:
*
* <ul>
* <li>A {@code @Multibinding} for an empty set of a type not accessible from this package.
* <li>A {@code @Multibinding} for an empty map of a type not accessible from this package.
* <li>A public type that injects the empty set and map of inaccessible objects.
* </ul>
*/
@Component(modules = {AMultibindsModule.class})
interface MultibindsComponent {
UsesInaccessible usesInaccessible();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import dagger.multibindings.StringKey;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;

@Module
public abstract class AModule {
Expand All @@ -49,9 +48,4 @@ static Set<Inaccessible> provideSetOfInaccessibles() {
@IntoMap
@StringKey("inaccessible")
abstract Inaccessible provideInaccessibleToMap(Inaccessible inaccessible);

static class Inaccessible {
@Inject Inaccessible() {}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2015 The Dagger Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package test.multipackage.a;

import dagger.Module;
import dagger.multibindings.Multibinds;
import java.util.Map;
import java.util.Set;

/** A module that {@code @Multibinds} a set and a map of {@link Inaccessible}. */
@Module
public abstract class AMultibindsModule {
@Multibinds
abstract Set<Inaccessible> inaccessibleSet();

@Multibinds
abstract Map<String, Inaccessible> inaccessibleMap();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2016 The Dagger Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package test.multipackage.a;

import javax.inject.Inject;

final class Inaccessible {
@Inject Inaccessible() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import test.multipackage.a.AModule.Inaccessible;

@SuppressWarnings("unused")
public class UsesInaccessible {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static dagger.internal.codegen.TypeNames.MAP_PROVIDER_FACTORY;
import static dagger.internal.codegen.TypeNames.MEMBERS_INJECTOR;
import static dagger.internal.codegen.TypeNames.MEMBERS_INJECTORS;
import static dagger.internal.codegen.TypeNames.SET;

import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.ClassName;
Expand Down Expand Up @@ -144,10 +143,7 @@ static MemberSelect emptyFrameworkMapFactory(
*/
static MemberSelect emptySetProvider(ClassName setFactoryType, SetType setType) {
return new ParameterizedStaticMethod(
setFactoryType,
ImmutableList.of(setType.elementType()),
CodeBlock.of("empty()"),
SET);
setFactoryType, ImmutableList.of(setType.elementType()), CodeBlock.of("empty()"), FACTORY);
}

private static final class ParameterizedStaticMethod extends MemberSelect {
Expand Down

0 comments on commit d64c75d

Please sign in to comment.