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

Side by Side Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2847213002: Synthetic function elements don't have a name or enclosing element/library. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/testcases/inference/generic_methods_uses_greatest_lower_bound.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 _InstrumentationValueForType(this.type); 112 _InstrumentationValueForType(this.type);
113 113
114 @override 114 @override
115 String toString() { 115 String toString() {
116 StringBuffer buffer = new StringBuffer(); 116 StringBuffer buffer = new StringBuffer();
117 _appendType(buffer, type); 117 _appendType(buffer, type);
118 return buffer.toString(); 118 return buffer.toString();
119 } 119 }
120 120
121 void _appendElementName(StringBuffer buffer, Element element) { 121 void _appendElementName(StringBuffer buffer, Element element) {
122 String name = element.name ?? ''; 122 // Synthetic FunctionElement(s) don't have a name or enclosing library.
123 if (element.library == null) { 123 if (element.isSynthetic && element is FunctionElement) {
124 // TODO(scheglov) This is wrong - every element must be in a library.
125 buffer.write('<unknown>::$name');
126 return; 124 return;
127 } 125 }
128 String libraryName = element.library.name; 126
129 if (libraryName == '') { 127 LibraryElement library = element.library;
130 throw new StateError('The element $name must be in a named library.'); 128 if (library == null) {
129 throw new StateError('Unexpected element without library: $element');
131 } 130 }
131 String libraryName = library.name;
132
133 String name = element.name ?? '';
132 if (libraryName != 'dart.core' && 134 if (libraryName != 'dart.core' &&
133 libraryName != 'dart.async' && 135 libraryName != 'dart.async' &&
134 libraryName != 'test') { 136 libraryName != 'test') {
135 buffer.write('$libraryName::$name'); 137 buffer.write('$libraryName::$name');
136 } else { 138 } else {
137 buffer.write('$name'); 139 buffer.write('$name');
138 } 140 }
139 } 141 }
140 142
141 void _appendList<T>(StringBuffer buffer, String open, String close, 143 void _appendList<T>(StringBuffer buffer, String open, String close,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 void _recordType(int offset, DartType type) { 301 void _recordType(int offset, DartType type) {
300 _instrumentation.record( 302 _instrumentation.record(
301 uri, offset, 'type', new _InstrumentationValueForType(type)); 303 uri, offset, 'type', new _InstrumentationValueForType(type));
302 } 304 }
303 305
304 void _recordTypeArguments(int offset, List<DartType> typeArguments) { 306 void _recordTypeArguments(int offset, List<DartType> typeArguments) {
305 _instrumentation.record(uri, offset, 'typeArgs', 307 _instrumentation.record(uri, offset, 'typeArgs',
306 new _InstrumentationValueForTypeArgs(typeArguments)); 308 new _InstrumentationValueForTypeArgs(typeArguments));
307 } 309 }
308 } 310 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/testcases/inference/generic_methods_uses_greatest_lower_bound.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698