Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/type/InferredType.java |
| diff --git a/compiler/java/com/google/dart/compiler/type/InferredType.java b/compiler/java/com/google/dart/compiler/type/InferredType.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5ea3516fe59db9f9880692cab6c71368008b95a |
| --- /dev/null |
| +++ b/compiler/java/com/google/dart/compiler/type/InferredType.java |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +package com.google.dart.compiler.type; |
| + |
| +import java.lang.reflect.InvocationHandler; |
| +import java.lang.reflect.Method; |
| +import java.lang.reflect.Proxy; |
| + |
| +/** |
| + * Marker interface for {@link Type} which means that this {@link Type} was not specified by user, |
| + * but instead inferred from context. |
| + */ |
| +public interface InferredType { |
| + public static class Helper { |
| + /** |
| + * @return the mix of the given {@link Type} interface and {@link InferredType}. |
| + */ |
| + public static Type make(final Type type) { |
| + if (type instanceof InterfaceType) { |
| + return (Type) Proxy.newProxyInstance(type.getClass().getClassLoader(), new Class<?>[] { |
|
Brian Wilkerson
2012/05/29 20:25:46
Long term, I'm fairly certain that we don't want t
|
| + InterfaceType.class, |
| + InferredType.class}, new InvocationHandler() { |
| + @Override |
| + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
| + return method.invoke(type, args); |
| + } |
| + }); |
| + } |
| + return type; |
| + } |
| + } |
| +} |