| 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 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element get currentElement; | 8 Element get currentElement; |
| 9 Set<Node> get superUses; | 9 Set<Node> get superUses; |
| 10 | 10 |
| (...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3181 Link<Node> link = superMixin.mixins.nodes; | 3181 Link<Node> link = superMixin.mixins.nodes; |
| 3182 while (!link.isEmpty) { | 3182 while (!link.isEmpty) { |
| 3183 supertype = applyMixin(supertype, resolveType(link.head)); | 3183 supertype = applyMixin(supertype, resolveType(link.head)); |
| 3184 link = link.tail; | 3184 link = link.tail; |
| 3185 } | 3185 } |
| 3186 element.supertype = supertype; | 3186 element.supertype = supertype; |
| 3187 } else { | 3187 } else { |
| 3188 element.supertype = resolveSupertype(element, node.superclass); | 3188 element.supertype = resolveSupertype(element, node.superclass); |
| 3189 } | 3189 } |
| 3190 } | 3190 } |
| 3191 | 3191 // If the super type isn't specified, we provide a default. The language |
| 3192 // If the super type isn't specified, we make it Object. | 3192 // specifies [Object] but the backend can pick a specific 'implementation' |
| 3193 final objectElement = compiler.objectClass; | 3193 // of Object - the JavaScript backend chooses between Object and |
| 3194 if (!identical(element, objectElement) && element.supertype == null) { | 3194 // Interceptor. |
| 3195 if (objectElement == null) { | 3195 if (element.supertype == null) { |
| 3196 compiler.internalError("Internal error: cannot resolve Object", | 3196 ClassElement superElement = compiler.backend.defaultSuperclass(element); |
| 3197 node: node); | 3197 // Avoid making the superclass (usually Object) extend itself. |
| 3198 } else { | 3198 if (element != superElement) { |
| 3199 objectElement.ensureResolved(compiler); | 3199 if (superElement == null) { |
| 3200 compiler.internalError("Internal error: cannot resolve Object", |
| 3201 node: node); |
| 3202 } else { |
| 3203 superElement.ensureResolved(compiler); |
| 3204 } |
| 3205 element.supertype = superElement.computeType(compiler); |
| 3200 } | 3206 } |
| 3201 element.supertype = objectElement.computeType(compiler); | |
| 3202 } | 3207 } |
| 3203 | 3208 |
| 3204 assert(element.interfaces == null); | 3209 assert(element.interfaces == null); |
| 3205 element.interfaces = resolveInterfaces(node.interfaces, node.superclass); | 3210 element.interfaces = resolveInterfaces(node.interfaces, node.superclass); |
| 3206 calculateAllSupertypes(element); | 3211 calculateAllSupertypes(element); |
| 3207 | 3212 |
| 3208 if (node.defaultClause != null) { | 3213 if (node.defaultClause != null) { |
| 3209 element.defaultClass = visit(node.defaultClause); | 3214 element.defaultClass = visit(node.defaultClause); |
| 3210 } | 3215 } |
| 3211 element.addDefaultConstructorIfNeeded(compiler); | 3216 element.addDefaultConstructorIfNeeded(compiler); |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 return e; | 3965 return e; |
| 3961 } | 3966 } |
| 3962 | 3967 |
| 3963 /// Assumed to be called by [resolveRedirectingFactory]. | 3968 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3964 Element visitReturn(Return node) { | 3969 Element visitReturn(Return node) { |
| 3965 Node expression = node.expression; | 3970 Node expression = node.expression; |
| 3966 return finishConstructorReference(visit(expression), | 3971 return finishConstructorReference(visit(expression), |
| 3967 expression, expression); | 3972 expression, expression); |
| 3968 } | 3973 } |
| 3969 } | 3974 } |
| OLD | NEW |