| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Core implementation of resolution. | 8 * Core implementation of resolution. |
| 9 * | 9 * |
| 10 * Do not subclass or instantiate this class outside this library | 10 * Do not subclass or instantiate this class outside this library |
| (...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 // with the same arguments. | 1990 // with the same arguments. |
| 1991 Selector call = new Selector.callClosureFrom(selector); | 1991 Selector call = new Selector.callClosureFrom(selector); |
| 1992 registry.registerDynamicInvocation(call); | 1992 registry.registerDynamicInvocation(call); |
| 1993 } else if (target.impliesType) { | 1993 } else if (target.impliesType) { |
| 1994 // We call 'call()' on a Type instance returned from the reference to a | 1994 // We call 'call()' on a Type instance returned from the reference to a |
| 1995 // class or typedef literal. We do not need to register this call as a | 1995 // class or typedef literal. We do not need to register this call as a |
| 1996 // dynamic invocation, because we statically know what the target is. | 1996 // dynamic invocation, because we statically know what the target is. |
| 1997 } else { | 1997 } else { |
| 1998 if (target is FunctionElement) { | 1998 if (target is FunctionElement) { |
| 1999 FunctionElement function = target; | 1999 FunctionElement function = target; |
| 2000 function.computeSignature(compiler); | 2000 function.computeType(compiler); |
| 2001 } | 2001 } |
| 2002 if (!selector.applies(target, compiler.world)) { | 2002 if (!selector.applies(target, compiler.world)) { |
| 2003 registry.registerThrowNoSuchMethod(); | 2003 registry.registerThrowNoSuchMethod(); |
| 2004 if (node.isSuperCall) { | 2004 if (node.isSuperCall) { |
| 2005 internalError(node, "Unexpected super call $node"); | 2005 internalError(node, "Unexpected super call $node"); |
| 2006 } | 2006 } |
| 2007 } | 2007 } |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 handleForeignCall(node, target, selector); | 2010 handleForeignCall(node, target, selector); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 InterfaceType type = registry.getType(node); | 2353 InterfaceType type = registry.getType(node); |
| 2354 FunctionType targetType = redirectionTarget.computeType(compiler) | 2354 FunctionType targetType = redirectionTarget.computeType(compiler) |
| 2355 .subst(type.typeArguments, targetClass.typeVariables); | 2355 .subst(type.typeArguments, targetClass.typeVariables); |
| 2356 FunctionType constructorType = constructor.computeType(compiler); | 2356 FunctionType constructorType = constructor.computeType(compiler); |
| 2357 bool isSubtype = compiler.types.isSubtype(targetType, constructorType); | 2357 bool isSubtype = compiler.types.isSubtype(targetType, constructorType); |
| 2358 if (!isSubtype) { | 2358 if (!isSubtype) { |
| 2359 warning(node, MessageKind.NOT_ASSIGNABLE, | 2359 warning(node, MessageKind.NOT_ASSIGNABLE, |
| 2360 {'fromType': targetType, 'toType': constructorType}); | 2360 {'fromType': targetType, 'toType': constructorType}); |
| 2361 } | 2361 } |
| 2362 | 2362 |
| 2363 FunctionSignature targetSignature = | 2363 redirectionTarget.computeType(compiler); |
| 2364 redirectionTarget.computeSignature(compiler); | 2364 FunctionSignature targetSignature = redirectionTarget.functionSignature; |
| 2365 FunctionSignature constructorSignature = | 2365 constructor.computeType(compiler); |
| 2366 constructor.computeSignature(compiler); | 2366 FunctionSignature constructorSignature = constructor.functionSignature; |
| 2367 if (!targetSignature.isCompatibleWith(constructorSignature)) { | 2367 if (!targetSignature.isCompatibleWith(constructorSignature)) { |
| 2368 assert(!isSubtype); | 2368 assert(!isSubtype); |
| 2369 registry.registerThrowNoSuchMethod(); | 2369 registry.registerThrowNoSuchMethod(); |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 // Register a post process to check for cycles in the redirection chain and | 2372 // Register a post process to check for cycles in the redirection chain and |
| 2373 // set the actual generative constructor at the end of the chain. | 2373 // set the actual generative constructor at the end of the chain. |
| 2374 addDeferredAction(constructor, () { | 2374 addDeferredAction(constructor, () { |
| 2375 compiler.resolver.resolveRedirectionChain(constructor, node); | 2375 compiler.resolver.resolveRedirectionChain(constructor, node); |
| 2376 }); | 2376 }); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 FunctionElement constructor = resolveConstructor(node); | 2471 FunctionElement constructor = resolveConstructor(node); |
| 2472 final bool isSymbolConstructor = constructor == compiler.symbolConstructor; | 2472 final bool isSymbolConstructor = constructor == compiler.symbolConstructor; |
| 2473 final bool isMirrorsUsedConstant = | 2473 final bool isMirrorsUsedConstant = |
| 2474 node.isConst && (constructor == compiler.mirrorsUsedConstructor); | 2474 node.isConst && (constructor == compiler.mirrorsUsedConstructor); |
| 2475 Selector callSelector = resolveSelector(node.send, constructor); | 2475 Selector callSelector = resolveSelector(node.send, constructor); |
| 2476 resolveArguments(node.send.argumentsNode); | 2476 resolveArguments(node.send.argumentsNode); |
| 2477 registry.useElement(node.send, constructor); | 2477 registry.useElement(node.send, constructor); |
| 2478 if (Elements.isUnresolved(constructor)) { | 2478 if (Elements.isUnresolved(constructor)) { |
| 2479 return new ResolutionResult.forElement(constructor); | 2479 return new ResolutionResult.forElement(constructor); |
| 2480 } | 2480 } |
| 2481 constructor.computeSignature(compiler); | 2481 constructor.computeType(compiler); |
| 2482 if (!callSelector.applies(constructor, compiler.world)) { | 2482 if (!callSelector.applies(constructor, compiler.world)) { |
| 2483 registry.registerThrowNoSuchMethod(); | 2483 registry.registerThrowNoSuchMethod(); |
| 2484 } | 2484 } |
| 2485 | 2485 |
| 2486 // [constructor] might be the implementation element | 2486 // [constructor] might be the implementation element |
| 2487 // and only declaration elements may be registered. | 2487 // and only declaration elements may be registered. |
| 2488 registry.registerStaticUse(constructor.declaration); | 2488 registry.registerStaticUse(constructor.declaration); |
| 2489 ClassElement cls = constructor.enclosingClass; | 2489 ClassElement cls = constructor.enclosingClass; |
| 2490 if (cls.isEnumClass && currentClass != cls) { | 2490 if (cls.isEnumClass && currentClass != cls) { |
| 2491 compiler.reportError(node, | 2491 compiler.reportError(node, |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 } | 3265 } |
| 3266 return const NoneResult(); | 3266 return const NoneResult(); |
| 3267 } | 3267 } |
| 3268 } | 3268 } |
| 3269 | 3269 |
| 3270 /// Looks up [name] in [scope] and unwraps the result. | 3270 /// Looks up [name] in [scope] and unwraps the result. |
| 3271 Element lookupInScope(Compiler compiler, Node node, | 3271 Element lookupInScope(Compiler compiler, Node node, |
| 3272 Scope scope, String name) { | 3272 Scope scope, String name) { |
| 3273 return Elements.unwrap(scope.lookup(name), compiler, node); | 3273 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 3274 } | 3274 } |
| OLD | NEW |