| Index: compiler/java/com/google/dart/compiler/type/Types.java
|
| diff --git a/compiler/java/com/google/dart/compiler/type/Types.java b/compiler/java/com/google/dart/compiler/type/Types.java
|
| index 241bc48d1a19f0c0a1ea2218c8c412ecf77bd831..04b9c992a904732223ba9b92a3e1e47f01a5e3bc 100644
|
| --- a/compiler/java/com/google/dart/compiler/type/Types.java
|
| +++ b/compiler/java/com/google/dart/compiler/type/Types.java
|
| @@ -7,6 +7,7 @@ package com.google.dart.compiler.type;
|
| import com.google.common.annotations.VisibleForTesting;
|
| import com.google.common.collect.Lists;
|
| import com.google.common.collect.MapMaker;
|
| +import com.google.common.collect.Sets;
|
| import com.google.dart.compiler.ast.DartNewExpression;
|
| import com.google.dart.compiler.ast.DartNode;
|
| import com.google.dart.compiler.ast.DartPropertyAccess;
|
| @@ -505,20 +506,21 @@ public class Types {
|
| * {@link Type#isInferred()}.
|
| */
|
| public static Type makeInferred(Type type) {
|
| - if (type instanceof DynamicType) {
|
| - return makeInferred(type, DynamicType.class);
|
| - }
|
| - if (type instanceof InterfaceType) {
|
| - return makeInferred(type, InterfaceType.class);
|
| + if (type != null) {
|
| + Set<Class<?>> interfaceSet = getAllImplementedInterfaces(type.getClass());
|
| + if (!interfaceSet.isEmpty()) {
|
| + Class<?>[] interfaces = (Class[]) interfaceSet.toArray(new Class[interfaceSet.size()]);
|
| + type = makeInferred(type, interfaces);
|
| + }
|
| }
|
| return type;
|
| }
|
|
|
| - private static Type makeInferred(final Type type, Class<?> typeInterface) {
|
| + private static Type makeInferred(final Type type, Class<?>[] interfaces) {
|
| Type inferred = inferredTypes.get(type);
|
| if (inferred == null) {
|
| inferred = (Type) Proxy.newProxyInstance(type.getClass().getClassLoader(),
|
| - new Class<?>[] {typeInterface}, new InvocationHandler() {
|
| + interfaces, new InvocationHandler() {
|
| @Override
|
| public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
| if (args == null && method.getName().equals("isInferred")) {
|
| @@ -531,4 +533,16 @@ public class Types {
|
| }
|
| return inferred;
|
| }
|
| +
|
| + /**
|
| + * @return all interfaces implemented by given {@link Class}.
|
| + */
|
| + private static Set<Class<?>> getAllImplementedInterfaces(Class<?> c) {
|
| + Set<Class<?>> result = Sets.newHashSet();
|
| + for (Class<?> intf : c.getInterfaces()) {
|
| + result.add(intf);
|
| + result.addAll(getAllImplementedInterfaces(intf));
|
| + }
|
| + return result;
|
| + }
|
| }
|
|
|