OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 package com.google.dart.compiler.type; | 5 package com.google.dart.compiler.type; |
6 | 6 |
7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
8 import com.google.common.base.Joiner; | 8 import com.google.common.base.Joiner; |
9 import com.google.common.base.Objects; | 9 import com.google.common.base.Objects; |
10 import com.google.common.collect.ArrayListMultimap; | 10 import com.google.common.collect.ArrayListMultimap; |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 case METHOD: | 2156 case METHOD: |
2157 type = typeAsMemberOf(element, currentClass); | 2157 type = typeAsMemberOf(element, currentClass); |
2158 break; | 2158 break; |
2159 case NONE: | 2159 case NONE: |
2160 if (!target.isResolutionAlreadyReportedThatTheMethodCouldNotBeFound())
{ | 2160 if (!target.isResolutionAlreadyReportedThatTheMethodCouldNotBeFound())
{ |
2161 onError(target, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, current
Class, target); | 2161 onError(target, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, current
Class, target); |
2162 } | 2162 } |
2163 return dynamicType; | 2163 return dynamicType; |
2164 default: | 2164 default: |
2165 type = element.getType(); | 2165 type = element.getType(); |
| 2166 // attempt to resolve to "call()" method invocation |
| 2167 if (type instanceof InterfaceType) { |
| 2168 InterfaceType interfaceType = (InterfaceType) type; |
| 2169 Element callElement = interfaceType.getElement().lookupLocalElement(
"call"); |
| 2170 if (ElementKind.of(callElement) == ElementKind.METHOD) { |
| 2171 node.setElement(callElement); |
| 2172 type = typeAsMemberOf(callElement, interfaceType); |
| 2173 } |
| 2174 } |
2166 break; | 2175 break; |
2167 } | 2176 } |
2168 return checkInvocation(node, target, name, type); | 2177 return checkInvocation(node, target, name, type); |
2169 } | 2178 } |
2170 | 2179 |
2171 private Type checkInvocation(DartInvocation node, DartNode diagnosticNode, S
tring name, | 2180 private Type checkInvocation(DartInvocation node, DartNode diagnosticNode, S
tring name, |
2172 Type type) { | 2181 Type type) { |
2173 List<DartExpression> argumentNodes = node.getArguments(); | 2182 List<DartExpression> argumentNodes = node.getArguments(); |
2174 List<Type> argumentTypes = Lists.newArrayListWithCapacity(argumentNodes.si
ze()); | 2183 List<Type> argumentTypes = Lists.newArrayListWithCapacity(argumentNodes.si
ze()); |
2175 for (DartExpression argumentNode : argumentNodes) { | 2184 for (DartExpression argumentNode : argumentNodes) { |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 for (VariableElement v : parameters) { | 2727 for (VariableElement v : parameters) { |
2719 if (v.isNamed()) { | 2728 if (v.isNamed()) { |
2720 named.add(v); | 2729 named.add(v); |
2721 } | 2730 } |
2722 } | 2731 } |
2723 return named; | 2732 return named; |
2724 } | 2733 } |
2725 } | 2734 } |
2726 } | 2735 } |
2727 } | 2736 } |
OLD | NEW |