OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 class TypeDefinitionVisitor extends MappingVisitor<DartType> { | 7 class TypeDefinitionVisitor extends MappingVisitor<DartType> { |
8 Scope scope; | 8 Scope scope; |
9 final TypeDeclarationElement enclosingElement; | 9 final TypeDeclarationElement enclosingElement; |
10 TypeDeclarationElement get element => enclosingElement; | 10 TypeDeclarationElement get element => enclosingElement; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 DartType visitClassNode(ClassNode node) { | 96 DartType visitClassNode(ClassNode node) { |
97 if (element == null) { | 97 if (element == null) { |
98 throw compiler.internalError(node, 'element is null'); | 98 throw compiler.internalError(node, 'element is null'); |
99 } | 99 } |
100 if (element.resolutionState != STATE_STARTED) { | 100 if (element.resolutionState != STATE_STARTED) { |
101 throw compiler.internalError(element, | 101 throw compiler.internalError(element, |
102 'cyclic resolution of class $element'); | 102 'cyclic resolution of class $element'); |
103 } | 103 } |
104 | 104 |
105 InterfaceType type = element.computeType(compiler); | 105 element.computeType(compiler); |
106 scope = new TypeDeclarationScope(scope, element); | 106 scope = new TypeDeclarationScope(scope, element); |
107 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet. | 107 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet. |
108 // As a side-effect, this may get us back here trying to | 108 // As a side-effect, this may get us back here trying to |
109 // resolve this class again. | 109 // resolve this class again. |
110 resolveTypeVariableBounds(node.typeParameters); | 110 resolveTypeVariableBounds(node.typeParameters); |
111 | 111 |
112 // Setup the supertype for the element (if there is a cycle in the | 112 // Setup the supertype for the element (if there is a cycle in the |
113 // class hierarchy, it has already been set to Object). | 113 // class hierarchy, it has already been set to Object). |
114 if (element.supertype == null && node.superclass != null) { | 114 if (element.supertype == null && node.superclass != null) { |
115 MixinApplication superMixin = node.superclass.asMixinApplication(); | 115 MixinApplication superMixin = node.superclass.asMixinApplication(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 'cyclic resolution of class $element'); | 236 'cyclic resolution of class $element'); |
237 } | 237 } |
238 | 238 |
239 if (identical(node.classKeyword.stringValue, 'typedef')) { | 239 if (identical(node.classKeyword.stringValue, 'typedef')) { |
240 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic | 240 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic |
241 // together with corresponding TODO in parser.dart. | 241 // together with corresponding TODO in parser.dart. |
242 compiler.reportWarning(node.classKeyword, | 242 compiler.reportWarning(node.classKeyword, |
243 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX); | 243 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX); |
244 } | 244 } |
245 | 245 |
246 InterfaceType type = element.computeType(compiler); | 246 element.computeType(compiler); |
247 scope = new TypeDeclarationScope(scope, element); | 247 scope = new TypeDeclarationScope(scope, element); |
248 resolveTypeVariableBounds(node.typeParameters); | 248 resolveTypeVariableBounds(node.typeParameters); |
249 | 249 |
250 // Generate anonymous mixin application elements for the | 250 // Generate anonymous mixin application elements for the |
251 // intermediate mixin applications (excluding the last). | 251 // intermediate mixin applications (excluding the last). |
252 DartType supertype = resolveSupertype(element, node.superclass); | 252 DartType supertype = resolveSupertype(element, node.superclass); |
253 Link<Node> link = node.mixins.nodes; | 253 Link<Node> link = node.mixins.nodes; |
254 while (!link.tail.isEmpty) { | 254 while (!link.tail.isEmpty) { |
255 supertype = applyMixin(supertype, checkMixinType(link.head), link.head); | 255 supertype = applyMixin(supertype, checkMixinType(link.head), link.head); |
256 link = link.tail; | 256 link = link.tail; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 Identifier selector = node.selector.asIdentifier(); | 629 Identifier selector = node.selector.asIdentifier(); |
630 var e = prefixElement.lookupLocalMember(selector.source); | 630 var e = prefixElement.lookupLocalMember(selector.source); |
631 if (e == null || !e.impliesType) { | 631 if (e == null || !e.impliesType) { |
632 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, | 632 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, |
633 {'typeName': node.selector}); | 633 {'typeName': node.selector}); |
634 return; | 634 return; |
635 } | 635 } |
636 loadSupertype(e, node); | 636 loadSupertype(e, node); |
637 } | 637 } |
638 } | 638 } |
OLD | NEW |