diff options
author | Christian Edward Gruber <cgruber@google.com> | 2014-01-07 13:28:44 -0800 |
---|---|---|
committer | Christian Edward Gruber <cgruber@google.com> | 2014-01-07 13:52:51 -0800 |
commit | cadb638d89266f5d5a3f6cd60928e74fce1acb8c (patch) | |
tree | 3200fd3148aca43d8ea295aef8f4a4c18d7ddad4 /factory/src/test | |
parent | f92960f9dd542f77192c5e0182b01a3b934764d2 (diff) | |
download | auto-cadb638d89266f5d5a3f6cd60928e74fce1acb8c.tar.gz |
Fix AutoFactory to work correctly when implementing an interface that is an extension of a generic interface.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=57662999
Diffstat (limited to 'factory/src/test')
3 files changed, 82 insertions, 0 deletions
diff --git a/factory/src/test/java/com/google/auto/factory/processor/AutoFactoryProcessorTest.java b/factory/src/test/java/com/google/auto/factory/processor/AutoFactoryProcessorTest.java index 20cd8a87..19571edc 100644 --- a/factory/src/test/java/com/google/auto/factory/processor/AutoFactoryProcessorTest.java +++ b/factory/src/test/java/com/google/auto/factory/processor/AutoFactoryProcessorTest.java @@ -232,4 +232,15 @@ public class AutoFactoryProcessorTest { + "Supertypes must be non-final classes.") .in(file).onLine(20); } + + @Test public void factoryImplementingGenericInterfaceExtension() { + JavaFileObject file = + JavaFileObjects.forResource("good/FactoryImplementingGenericInterfaceExtension.java"); + ASSERT.about(javaSource()) + .that(file) + .processedWith(new AutoFactoryProcessor()) + .compilesWithoutError() + .and().generatesSources(JavaFileObjects.forResource( + "expected/FactoryImplementingGenericInterfaceExtension.java")); + } } diff --git a/factory/src/test/resources/expected/FactoryImplementingGenericInterfaceExtension.java b/factory/src/test/resources/expected/FactoryImplementingGenericInterfaceExtension.java new file mode 100644 index 00000000..3c4d5572 --- /dev/null +++ b/factory/src/test/resources/expected/FactoryImplementingGenericInterfaceExtension.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 Google, Inc. + * + * 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 tests; + +import javax.annotation.Generated; +import javax.inject.Inject; +import javax.inject.Provider; + +import tests.FactoryImplementingGenericInterfaceExtension.MyFactory; + +@Generated("com.google.auto.factory.processor.AutoFactoryProcessor") +final class FactoryImplementingGenericInterfaceExtensionFactory + implements MyFactory { + private final Provider<String> sProvider; + @Inject + FactoryImplementingGenericInterfaceExtensionFactory(Provider<String> sProvider) { + this.sProvider = sProvider; + } + FactoryImplementingGenericInterfaceExtension create(Integer i) { + return new FactoryImplementingGenericInterfaceExtension(sProvider.get(), i); + } + @Override + public FactoryImplementingGenericInterfaceExtension make(Integer arg) { + return create(arg); + } +} diff --git a/factory/src/test/resources/good/FactoryImplementingGenericInterfaceExtension.java b/factory/src/test/resources/good/FactoryImplementingGenericInterfaceExtension.java new file mode 100644 index 00000000..43e294c0 --- /dev/null +++ b/factory/src/test/resources/good/FactoryImplementingGenericInterfaceExtension.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2013 Google, Inc. + * + * 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 tests; + +import com.google.auto.factory.AutoFactory; +import com.google.auto.factory.Provided; + +class FactoryImplementingGenericInterfaceExtension { + + @AutoFactory(implementing = MyFactory.class) + FactoryImplementingGenericInterfaceExtension(@Provided String s, Integer i) {} + + interface MyFactory + extends GenericFactory<FactoryImplementingGenericInterfaceExtension, Integer> {} + + interface GenericFactory<T, S> { + T make(S arg); + } +} |