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 dart2js; | 5 part of dart2js; |
6 | 6 |
7 class TypeCheckerTask extends CompilerTask { | 7 class TypeCheckerTask extends CompilerTask { |
8 TypeCheckerTask(Compiler compiler) : super(compiler); | 8 TypeCheckerTask(Compiler compiler) : super(compiler); |
9 String get name => "Type checker"; | 9 String get name => "Type checker"; |
10 | 10 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 } | 1327 } |
1328 | 1328 |
1329 DartType visitLiteralSymbol(LiteralSymbol node) { | 1329 DartType visitLiteralSymbol(LiteralSymbol node) { |
1330 return compiler.symbolClass.computeType(compiler); | 1330 return compiler.symbolClass.computeType(compiler); |
1331 } | 1331 } |
1332 | 1332 |
1333 DartType computeConstructorType(Element constructor, DartType type) { | 1333 DartType computeConstructorType(Element constructor, DartType type) { |
1334 if (Elements.isUnresolved(constructor)) return types.dynamicType; | 1334 if (Elements.isUnresolved(constructor)) return types.dynamicType; |
1335 DartType constructorType = constructor.computeType(compiler); | 1335 DartType constructorType = constructor.computeType(compiler); |
1336 if (identical(type.kind, TypeKind.INTERFACE)) { | 1336 if (identical(type.kind, TypeKind.INTERFACE)) { |
1337 InterfaceType interfaceType = type; | 1337 if (constructor.isSynthesized) { |
1338 constructorType = constructorType.subst( | 1338 // TODO(johnniwinther): Remove this when synthesized constructors handle |
1339 interfaceType.typeArguments, | 1339 // type variables correctly. |
1340 interfaceType.element.typeVariables); | 1340 InterfaceType interfaceType = type; |
| 1341 ClassElement receiverElement = interfaceType.element; |
| 1342 while (receiverElement.isMixinApplication) { |
| 1343 receiverElement = receiverElement.supertype.element; |
| 1344 } |
| 1345 constructorType = constructorType.substByContext( |
| 1346 interfaceType.asInstanceOf(receiverElement)); |
| 1347 } else { |
| 1348 constructorType = constructorType.substByContext(type); |
| 1349 } |
1341 } | 1350 } |
1342 return constructorType; | 1351 return constructorType; |
1343 } | 1352 } |
1344 | 1353 |
1345 DartType visitNewExpression(NewExpression node) { | 1354 DartType visitNewExpression(NewExpression node) { |
1346 Element element = elements[node.send]; | 1355 Element element = elements[node.send]; |
1347 if (Elements.isUnresolved(element)) return types.dynamicType; | 1356 if (Elements.isUnresolved(element)) return types.dynamicType; |
1348 | 1357 |
1349 checkPrivateAccess(node, element, element.name); | 1358 checkPrivateAccess(node, element, element.name); |
1350 | 1359 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 visitTypedef(Typedef node) { | 1659 visitTypedef(Typedef node) { |
1651 // Do not typecheck [Typedef] nodes. | 1660 // Do not typecheck [Typedef] nodes. |
1652 } | 1661 } |
1653 | 1662 |
1654 visitNode(Node node) { | 1663 visitNode(Node node) { |
1655 compiler.internalError( | 1664 compiler.internalError( |
1656 'Unexpected node ${node.getObjectDescription()} in the type checker.', | 1665 'Unexpected node ${node.getObjectDescription()} in the type checker.', |
1657 node: node); | 1666 node: node); |
1658 } | 1667 } |
1659 } | 1668 } |
OLD | NEW |