OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
9 | 9 |
10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
11 | 11 |
12 import 'package:kernel/clone.dart' show CloneVisitor; | 12 import 'package:kernel/clone.dart' show CloneVisitor; |
13 | 13 |
14 import 'package:kernel/core_types.dart' show CoreTypes; | 14 import 'package:kernel/core_types.dart' show CoreTypes; |
15 | 15 |
16 import 'package:kernel/transformations/flags.dart' show TransformerFlag; | 16 import 'package:kernel/transformations/flags.dart' show TransformerFlag; |
17 | 17 |
18 import 'package:kernel/type_algebra.dart' show Substitution; | |
19 | |
18 import '../fasta_codes.dart' as fasta; | 20 import '../fasta_codes.dart' as fasta; |
19 | 21 |
20 import '../fasta_codes.dart' show LocatedMessage, Message; | 22 import '../fasta_codes.dart' show LocatedMessage, Message; |
21 | 23 |
22 import '../messages.dart' as messages show getLocationFromUri; | 24 import '../messages.dart' as messages show getLocationFromUri; |
23 | 25 |
24 import '../modifier.dart' show Modifier, constMask, finalMask; | 26 import '../modifier.dart' show Modifier, constMask, finalMask; |
25 | 27 |
26 import '../parser/native_support.dart' show skipNativeClause; | 28 import '../parser/native_support.dart' show skipNativeClause; |
27 | 29 |
(...skipping 29 matching lines...) Expand all Loading... | |
57 | 59 |
58 import '../source/scope_listener.dart' | 60 import '../source/scope_listener.dart' |
59 show JumpTargetKind, NullValue, ScopeListener; | 61 show JumpTargetKind, NullValue, ScopeListener; |
60 | 62 |
61 import '../type_inference/type_inferrer.dart' show TypeInferrer; | 63 import '../type_inference/type_inferrer.dart' show TypeInferrer; |
62 | 64 |
63 import '../type_inference/type_promotion.dart' show TypePromoter; | 65 import '../type_inference/type_promotion.dart' show TypePromoter; |
64 | 66 |
65 import 'frontend_accessors.dart' show buildIsNull, makeBinary; | 67 import 'frontend_accessors.dart' show buildIsNull, makeBinary; |
66 | 68 |
67 import 'redirecting_factory_body.dart' | 69 import 'redirecting_factory_body.dart' show RedirectingFactoryBody; |
68 show | |
69 RedirectingFactoryBody, | |
70 getRedirectingFactoryBody, | |
71 getRedirectionTarget; | |
72 | 70 |
73 import 'utils.dart' show offsetForToken; | 71 import 'utils.dart' show offsetForToken; |
74 | 72 |
75 import '../names.dart'; | 73 import '../names.dart'; |
76 | 74 |
77 import 'fasta_accessors.dart'; | 75 import 'fasta_accessors.dart'; |
78 | 76 |
79 import 'kernel_builder.dart'; | 77 import 'kernel_builder.dart'; |
80 | 78 |
81 import 'kernel_shadow_ast.dart'; | 79 import 'kernel_shadow_ast.dart'; |
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2320 push(new KernelSyntheticExpression(evaluateArgumentsBefore( | 2318 push(new KernelSyntheticExpression(evaluateArgumentsBefore( |
2321 arguments, | 2319 arguments, |
2322 buildAbstractClassInstantiationError( | 2320 buildAbstractClassInstantiationError( |
2323 type.name, nameToken.charOffset)))); | 2321 type.name, nameToken.charOffset)))); |
2324 return; | 2322 return; |
2325 } else { | 2323 } else { |
2326 target = initialTarget; | 2324 target = initialTarget; |
2327 } | 2325 } |
2328 } else if (b.isFactory) { | 2326 } else if (b.isFactory) { |
2329 initialTarget = b.target; | 2327 initialTarget = b.target; |
2330 target = getRedirectionTarget(initialTarget); | 2328 RedirectingFactoryBody body = |
2331 if (target == null) { | 2329 RedirectingFactoryBody.getRedirectingFactoryBody(initialTarget); |
2332 push(deprecated_buildCompileTimeError( | |
2333 "Cyclic definition of factory '${name}'.", | |
2334 nameToken.charOffset)); | |
2335 return; | |
2336 } | |
2337 RedirectingFactoryBody body = getRedirectingFactoryBody(target); | |
2338 if (body != null) { | 2330 if (body != null) { |
2339 // If the redirection target is itself a redirecting factory, it | 2331 target = body.target; |
2340 // means that it is unresolved. So we set target to null so we | 2332 if (target == null) { |
2341 // can generate a no-such-method error below. | 2333 push(deprecated_buildCompileTimeError( |
2342 assert(body.isUnresolved); | 2334 "Cyclic definition of factory '${debugName(type.name, name)}'. ", |
Johnni Winther
2017/08/30 12:18:46
Long line.
ahe
2017/08/30 15:07:22
Done.
| |
2343 target = null; | 2335 nameToken.charOffset)); |
2344 errorName = body.unresolvedName; | 2336 return; |
2337 } | |
2338 DartType targetType = body.returnType; | |
2339 if (arguments.types.isNotEmpty) { | |
2340 if (initialTarget.function.typeParameters.length != | |
2341 arguments.types.length) { | |
2342 arguments.types.clear(); | |
Johnni Winther
2017/08/30 12:18:46
Has the type argument mismatch been reported?
ahe
2017/08/30 15:07:22
No. I've added a TODO for that. I would like this
ahe
2017/08/30 15:13:09
And filed this bug: https://github.com/dart-lang/s
| |
2343 } else { | |
2344 Substitution substitution = Substitution.fromPairs( | |
2345 initialTarget.function.typeParameters, arguments.types); | |
2346 targetType = substitution.substituteType(targetType); | |
2347 if (targetType is InterfaceType) { | |
2348 arguments = new KernelArguments(arguments.positional, | |
2349 types: targetType.typeArguments, named: arguments.named) | |
2350 ..fileOffset = arguments.fileOffset; | |
2351 } else { | |
2352 arguments.types.clear(); | |
2353 } | |
2354 } | |
2355 } | |
2356 body = RedirectingFactoryBody.getRedirectingFactoryBody(target); | |
2357 if (body != null) { | |
2358 // If the redirection target is itself a redirecting factory, it | |
2359 // means that it is unresolved. So we set target to null so we | |
2360 // can generate a no-such-method error below. | |
2361 assert(body.isUnresolved); | |
2362 target = null; | |
2363 errorName = body.unresolvedName; | |
2364 } | |
2365 } else { | |
2366 target = initialTarget; | |
2345 } | 2367 } |
2346 } | 2368 } |
2347 if (target is Constructor || | 2369 if (target is Constructor || |
2348 (target is Procedure && target.kind == ProcedureKind.Factory)) { | 2370 (target is Procedure && target.kind == ProcedureKind.Factory)) { |
2349 push(buildStaticInvocation(target, arguments, | 2371 push(buildStaticInvocation(target, arguments, |
2350 isConst: optional("const", token) || optional("@", token), | 2372 isConst: optional("const", token) || optional("@", token), |
2351 charOffset: nameToken.charOffset, | 2373 charOffset: nameToken.charOffset, |
2352 initialTarget: initialTarget)); | 2374 initialTarget: initialTarget)); |
2353 return; | 2375 return; |
2354 } else { | 2376 } else { |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3827 return AsyncMarker.Async; | 3849 return AsyncMarker.Async; |
3828 } else { | 3850 } else { |
3829 assert(identical(starToken.stringValue, "*")); | 3851 assert(identical(starToken.stringValue, "*")); |
3830 return AsyncMarker.AsyncStar; | 3852 return AsyncMarker.AsyncStar; |
3831 } | 3853 } |
3832 } else { | 3854 } else { |
3833 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3855 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3834 asyncToken.charOffset, null); | 3856 asyncToken.charOffset, null); |
3835 } | 3857 } |
3836 } | 3858 } |
OLD | NEW |