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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 2754423002: Fail inference when an instance field is referenced. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
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 analyzer.test.src.summary.resynthesize_ast_test; 5 library analyzer.test.src.summary.resynthesize_ast_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 class B { 217 class B {
218 C c = new C(); 218 C c = new C();
219 } 219 }
220 class C { 220 class C {
221 int d; 221 int d;
222 } 222 }
223 var a = new A(); 223 var a = new A();
224 var v = a.b.c.d; 224 var v = a.b.c.d;
225 '''); 225 ''');
226 expect(unit.topLevelVariables[1].type.toString(), 'int'); 226 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
227 } 227 }
228 228
229 test_infer_extractProperty_getter_sequence_generic() async { 229 test_infer_extractProperty_getter_sequence_generic() async {
230 var unit = await checkFileElement(r''' 230 var unit = await checkFileElement(r'''
231 class A<T> { 231 class A<T> {
232 B<T> b = new B<T>(); 232 B<T> b = new B<T>();
233 } 233 }
234 class B<K> { 234 class B<K> {
235 C<List<K>, int> c = new C<List<K>, int>(); 235 C<List<K>, int> c = new C<List<K>, int>();
236 } 236 }
237 class C<K, V> { 237 class C<K, V> {
238 Map<K, V> d; 238 Map<K, V> d;
239 } 239 }
240 var a = new A<double>(); 240 var a = new A<double>();
241 var v = a.b.c.d; 241 var v = a.b.c.d;
242 '''); 242 ''');
243 expect(unit.topLevelVariables[1].type.toString(), 'Map<List<double>, int>'); 243 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
244 } 244 }
245 245
246 test_infer_extractProperty_getter_sequence_withUnresolved() async { 246 test_infer_extractProperty_getter_sequence_withUnresolved() async {
247 var unit = await checkFileElement(r''' 247 var unit = await checkFileElement(r'''
248 class A { 248 class A {
249 B b = new B(); 249 B b = new B();
250 } 250 }
251 class B { 251 class B {
252 int c; 252 int c;
253 } 253 }
(...skipping 28 matching lines...) Expand all
282 } 282 }
283 class B { 283 class B {
284 C c = new C(); 284 C c = new C();
285 } 285 }
286 class C { 286 class C {
287 int m(double p1, String p2) => 42; 287 int m(double p1, String p2) => 42;
288 } 288 }
289 var a = new A(); 289 var a = new A();
290 var v = a.b.c.m; 290 var v = a.b.c.m;
291 '''); 291 ''');
292 expect(unit.topLevelVariables[1].type.toString(), '(double, String) → int'); 292 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
293 } 293 }
294 294
295 test_infer_invokeConstructor_factoryRedirected() async { 295 test_infer_invokeConstructor_factoryRedirected() async {
296 await checkFileElement(r''' 296 await checkFileElement(r'''
297 class A { 297 class A {
298 factory A() = B; 298 factory A() = B;
299 } 299 }
300 class B implements A {} 300 class B implements A {}
301 var a = new A(); 301 var a = new A();
302 '''); 302 ''');
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 class B<K> { 419 class B<K> {
420 C<List<K>, int> c = new C<List<K>, int>(); 420 C<List<K>, int> c = new C<List<K>, int>();
421 } 421 }
422 class C<K, V> { 422 class C<K, V> {
423 Map<K, V> m() => null; 423 Map<K, V> m() => null;
424 } 424 }
425 var a = new A<double>(); 425 var a = new A<double>();
426 var v = a.b.c.m(); 426 var v = a.b.c.m();
427 '''); 427 ''');
428 expect(unit.topLevelVariables[1].type.toString(), 'Map<List<double>, int>'); 428 expect(unit.topLevelVariables[1].type.toString(), 'dynamic');
429 } 429 }
430 430
431 test_infer_invokeMethodRef_method_gg() async { 431 test_infer_invokeMethodRef_method_gg() async {
432 var unit = await checkFileElement(r''' 432 var unit = await checkFileElement(r'''
433 class A<K> { 433 class A<K> {
434 /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null; 434 /*=Map<K, V>*/ m/*<V>*/(/*=V*/ a) => null;
435 } 435 }
436 var a = new A<int>(); 436 var a = new A<int>();
437 var b = a.m(1.0); 437 var b = a.m(1.0);
438 '''); 438 ''');
(...skipping 25 matching lines...) Expand all
464 class B { 464 class B {
465 int m() => 0; 465 int m() => 0;
466 } 466 }
467 var a = new A(); 467 var a = new A();
468 ''', 468 ''',
469 name: '/a.dart'); 469 name: '/a.dart');
470 var unit = await checkFileElement(r''' 470 var unit = await checkFileElement(r'''
471 import 'a.dart' as p; 471 import 'a.dart' as p;
472 var b = p.a.b.m(); 472 var b = p.a.b.m();
473 '''); 473 ''');
474 expect(unit.topLevelVariables[0].type.toString(), 'int'); 474 expect(unit.topLevelVariables[0].type.toString(), 'dynamic');
475 } 475 }
476 476
477 test_infer_invokeMethodRef_method_withInferredTypeInLibraryCycle() async { 477 test_infer_invokeMethodRef_method_withInferredTypeInLibraryCycle() async {
478 var unit = await checkFileElement(''' 478 var unit = await checkFileElement('''
479 class Base { 479 class Base {
480 int m() => 0; 480 int m() => 0;
481 } 481 }
482 class A extends Base { 482 class A extends Base {
483 m() => 0; // Inferred return type: int 483 m() => 0; // Inferred return type: int
484 } 484 }
(...skipping 24 matching lines...) Expand all
509 '''); 509 ''');
510 // Since a.dart is in a separate library file from the compilation unit 510 // Since a.dart is in a separate library file from the compilation unit
511 // containing `a` and `b`, its types are inferred first; then `a` and `b`'s 511 // containing `a` and `b`, its types are inferred first; then `a` and `b`'s
512 // types are inferred. So the inferred return type of `int` should be 512 // types are inferred. So the inferred return type of `int` should be
513 // propagated to `b`. 513 // propagated to `b`.
514 expect(unit.topLevelVariables[1].type.toString(), 'int'); 514 expect(unit.topLevelVariables[1].type.toString(), 'int');
515 } 515 }
516 516
517 @override 517 @override
518 @failingTest 518 @failingTest
519 test_inferCorrectlyOnMultipleVariablesDeclaredTogether() async {
520 await super.test_inferCorrectlyOnMultipleVariablesDeclaredTogether();
521 }
522
523 @override
524 @failingTest
525 test_inferenceInCyclesIsDeterministic() async { 519 test_inferenceInCyclesIsDeterministic() async {
526 await super.test_inferenceInCyclesIsDeterministic(); 520 await super.test_inferenceInCyclesIsDeterministic();
527 } 521 }
528 522
529 @override 523 @override
530 @failingTest 524 @failingTest
531 test_inferLocalFunctionReturnType() async { 525 test_inferLocalFunctionReturnType() async {
532 await super.test_inferLocalFunctionReturnType(); 526 await super.test_inferLocalFunctionReturnType();
533 } 527 }
534 528
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 918
925 @override 919 @override
926 AnalysisOptionsImpl createOptions() => 920 AnalysisOptionsImpl createOptions() =>
927 super.createOptions()..strongMode = isStrongMode; 921 super.createOptions()..strongMode = isStrongMode;
928 922
929 @override 923 @override
930 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) { 924 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) {
931 return _encodeLibrary(source); 925 return _encodeLibrary(source);
932 } 926 }
933 } 927 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698