Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: pkg/compiler/lib/src/resolution/signatures.dart

Issue 895583006: Update yield warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/typechecker.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 * [SignatureResolver] resolves function signatures. 8 * [SignatureResolver] resolves function signatures.
9 */ 9 */
10 class SignatureResolver extends MappingVisitor<FormalElementX> { 10 class SignatureResolver extends MappingVisitor<FormalElementX> {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 /** 256 /**
257 * Resolves formal parameters and return type of a [FunctionExpression] 257 * Resolves formal parameters and return type of a [FunctionExpression]
258 * to a [FunctionSignature]. 258 * to a [FunctionSignature].
259 * 259 *
260 * If [createRealParameters] is `true`, the parameters will be 260 * If [createRealParameters] is `true`, the parameters will be
261 * real parameters implementing the [ParameterElement] interface. Otherwise, 261 * real parameters implementing the [ParameterElement] interface. Otherwise,
262 * the parameters will only implement [FormalElement]. 262 * the parameters will only implement [FormalElement].
263 */ 263 */
264 static FunctionSignature analyze(Compiler compiler, 264 static FunctionSignature analyze(
265 NodeList formalParameters, 265 Compiler compiler,
266 Node returnNode, 266 NodeList formalParameters,
267 FunctionTypedElement element, 267 Node returnNode,
268 ResolutionRegistry registry, 268 FunctionTypedElement element,
269 {MessageKind defaultValuesError, 269 ResolutionRegistry registry,
270 bool createRealParameters: false}) { 270 {MessageKind defaultValuesError,
271 bool createRealParameters: false,
272 bool isFunctionExpression: false}) {
273
271 SignatureResolver visitor = new SignatureResolver(compiler, element, 274 SignatureResolver visitor = new SignatureResolver(compiler, element,
272 registry, defaultValuesError: defaultValuesError, 275 registry, defaultValuesError: defaultValuesError,
273 createRealParameters: createRealParameters); 276 createRealParameters: createRealParameters);
274 Link<Element> parameters = const Link<Element>(); 277 Link<Element> parameters = const Link<Element>();
275 int requiredParameterCount = 0; 278 int requiredParameterCount = 0;
276 if (formalParameters == null) { 279 if (formalParameters == null) {
277 if (!element.isGetter) { 280 if (!element.isGetter) {
278 if (element.isErroneous) { 281 if (element.isErroneous) {
279 // If the element is erroneous, an error should already have been 282 // If the element is erroneous, an error should already have been
280 // reported. In the case of parse errors, it is possible that there 283 // reported. In the case of parse errors, it is possible that there
(...skipping 20 matching lines...) Expand all
301 } 304 }
302 DartType returnType; 305 DartType returnType;
303 if (element.isFactoryConstructor) { 306 if (element.isFactoryConstructor) {
304 returnType = element.enclosingClass.thisType; 307 returnType = element.enclosingClass.thisType;
305 // Because there is no type annotation for the return type of 308 // Because there is no type annotation for the return type of
306 // this element, we explicitly add one. 309 // this element, we explicitly add one.
307 if (compiler.enableTypeAssertions) { 310 if (compiler.enableTypeAssertions) {
308 registry.registerIsCheck(returnType); 311 registry.registerIsCheck(returnType);
309 } 312 }
310 } else { 313 } else {
311 returnType = visitor.resolveReturnType(returnNode); 314 AsyncMarker asyncMarker = AsyncMarker.SYNC;
315 if (isFunctionExpression) {
316 // Use async marker to determine the return type of function
317 // expressions.
318 FunctionElement function = element;
319 asyncMarker = function.asyncMarker;
320 }
321 switch (asyncMarker) {
322 case AsyncMarker.SYNC:
323 returnType = visitor.resolveReturnType(returnNode);
324 break;
325 case AsyncMarker.SYNC_STAR:
326 returnType = compiler.coreTypes.iterableType();
327 break;
328 case AsyncMarker.ASYNC:
329 returnType = compiler.coreTypes.futureType();
330 break;
331 case AsyncMarker.ASYNC_STAR:
332 returnType = compiler.coreTypes.streamType();
333 break;
334 }
312 } 335 }
313 336
314 if (element.isSetter && (requiredParameterCount != 1 || 337 if (element.isSetter && (requiredParameterCount != 1 ||
315 visitor.optionalParameterCount != 0)) { 338 visitor.optionalParameterCount != 0)) {
316 // If there are no formal parameters, we already reported an error above. 339 // If there are no formal parameters, we already reported an error above.
317 if (formalParameters != null) { 340 if (formalParameters != null) {
318 compiler.reportError(formalParameters, 341 compiler.reportError(formalParameters,
319 MessageKind.ILLEGAL_SETTER_FORMALS); 342 MessageKind.ILLEGAL_SETTER_FORMALS);
320 } 343 }
321 } 344 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 403
381 DartType resolveReturnType(TypeAnnotation annotation) { 404 DartType resolveReturnType(TypeAnnotation annotation) {
382 if (annotation == null) return const DynamicType(); 405 if (annotation == null) return const DynamicType();
383 DartType result = resolver.resolveTypeAnnotation(annotation); 406 DartType result = resolver.resolveTypeAnnotation(annotation);
384 if (result == null) { 407 if (result == null) {
385 return const DynamicType(); 408 return const DynamicType();
386 } 409 }
387 return result; 410 return result;
388 } 411 }
389 } 412 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698