[google-guice] push by cgruber@google.com - Fix a == vs .equals() bug in MoreTypes.... on 2013-05-16 14:50 GMT

1 view
Skip to first unread message

google...@googlecode.com

unread,
May 16, 2013, 10:50:48 AM5/16/13
to google-g...@googlegroups.com
Revision: 978ed86a76b3
Author: Christian Edward Gruber <cgr...@google.com>
Date: Thu May 16 07:49:41 2013
Log: Fix a == vs .equals() bug in MoreTypes.

----------------
Manually Synced.
COMMIT=44410191

http://code.google.com/p/google-guice/source/detail?r=978ed86a76b3

Modified:
/core/src/com/google/inject/internal/MoreTypes.java
/core/test/com/google/inject/internal/MoreTypesTest.java

=======================================
--- /core/src/com/google/inject/internal/MoreTypes.java Thu Jul 7 17:34:16
2011
+++ /core/src/com/google/inject/internal/MoreTypes.java Thu May 16 07:49:41
2013
@@ -228,7 +228,7 @@
}
TypeVariable<?> va = (TypeVariable) a;
TypeVariable<?> vb = (TypeVariable) b;
- return va.getGenericDeclaration() == vb.getGenericDeclaration()
+ return va.getGenericDeclaration().equals(vb.getGenericDeclaration())
&& va.getName().equals(vb.getName());

} else {
=======================================
--- /core/test/com/google/inject/internal/MoreTypesTest.java Thu Jul 7
17:34:16 2011
+++ /core/test/com/google/inject/internal/MoreTypesTest.java Thu May 16
07:49:41 2013
@@ -20,6 +20,7 @@

import junit.framework.TestCase;

+import java.lang.reflect.Type;
import java.util.Map;
import java.util.Set;

@@ -43,6 +44,11 @@

+ "java.util.Set<com.google.inject.internal.MoreTypesTest$Inner<java.lang.Long>>>",
MoreTypes.typeToString(mapInnerLongToSetInnerLong.getType()));
}
+
+ public <T> void testEquals_typeVariable() throws Exception {
+ Type type =
getClass().getMethod("testEquals_typeVariable").getTypeParameters()[0];
+ assertTrue(MoreTypes.equals(new TypeLiteral<T>() {}.getType(), type));
+ }

public static class Inner<T> {}
}
Reply all
Reply to author
Forward
0 new messages