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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into 28008_futureort Created 3 years, 11 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 // We cannot use either ElementFactory or TestTypeProvider (which uses 2418 // We cannot use either ElementFactory or TestTypeProvider (which uses
2419 // ElementFactory) because we side-effect the elements in ways that would 2419 // ElementFactory) because we side-effect the elements in ways that would
2420 // break other tests. 2420 // break other tests.
2421 // 2421 //
2422 InterfaceType objectType = _classElement("Object", null).type; 2422 InterfaceType objectType = _classElement("Object", null).type;
2423 InterfaceType boolType = _classElement("bool", objectType).type; 2423 InterfaceType boolType = _classElement("bool", objectType).type;
2424 InterfaceType numType = _classElement("num", objectType).type; 2424 InterfaceType numType = _classElement("num", objectType).type;
2425 InterfaceType doubleType = _classElement("double", numType).type; 2425 InterfaceType doubleType = _classElement("double", numType).type;
2426 InterfaceType functionType = _classElement("Function", objectType).type; 2426 InterfaceType functionType = _classElement("Function", objectType).type;
2427 InterfaceType futureType = _classElement("Future", objectType, ["T"]).type; 2427 InterfaceType futureType = _classElement("Future", objectType, ["T"]).type;
2428 InterfaceType futureOrType = _classElement("FutureOr", objectType, ["T"]).ty pe;
2428 InterfaceType intType = _classElement("int", numType).type; 2429 InterfaceType intType = _classElement("int", numType).type;
2429 InterfaceType iterableType = 2430 InterfaceType iterableType =
2430 _classElement("Iterable", objectType, ["T"]).type; 2431 _classElement("Iterable", objectType, ["T"]).type;
2431 InterfaceType listType = _classElement("List", objectType, ["E"]).type; 2432 InterfaceType listType = _classElement("List", objectType, ["E"]).type;
2432 InterfaceType mapType = _classElement("Map", objectType, ["K", "V"]).type; 2433 InterfaceType mapType = _classElement("Map", objectType, ["K", "V"]).type;
2433 InterfaceType stackTraceType = _classElement("StackTrace", objectType).type; 2434 InterfaceType stackTraceType = _classElement("StackTrace", objectType).type;
2434 InterfaceType streamType = _classElement("Stream", objectType, ["T"]).type; 2435 InterfaceType streamType = _classElement("Stream", objectType, ["T"]).type;
2435 InterfaceType stringType = _classElement("String", objectType).type; 2436 InterfaceType stringType = _classElement("String", objectType).type;
2436 InterfaceType symbolType = _classElement("Symbol", objectType).type; 2437 InterfaceType symbolType = _classElement("Symbol", objectType).type;
2437 InterfaceType typeType = _classElement("Type", objectType).type; 2438 InterfaceType typeType = _classElement("Type", objectType).type;
2438 CompilationUnitElementImpl coreUnit = 2439 CompilationUnitElementImpl coreUnit =
2439 new CompilationUnitElementImpl("core.dart"); 2440 new CompilationUnitElementImpl("core.dart");
2440 coreUnit.types = <ClassElement>[ 2441 coreUnit.types = <ClassElement>[
2441 boolType.element, 2442 boolType.element,
2442 doubleType.element, 2443 doubleType.element,
2443 functionType.element, 2444 functionType.element,
2444 intType.element, 2445 intType.element,
2445 iterableType.element, 2446 iterableType.element,
2446 listType.element, 2447 listType.element,
2447 mapType.element, 2448 mapType.element,
2448 objectType.element, 2449 objectType.element,
2449 stackTraceType.element, 2450 stackTraceType.element,
2450 stringType.element, 2451 stringType.element,
2451 symbolType.element, 2452 symbolType.element,
2452 typeType.element 2453 typeType.element
2453 ]; 2454 ];
2454 CompilationUnitElementImpl asyncUnit = 2455 CompilationUnitElementImpl asyncUnit =
2455 new CompilationUnitElementImpl("async.dart"); 2456 new CompilationUnitElementImpl("async.dart");
2456 asyncUnit.types = <ClassElement>[futureType.element, streamType.element]; 2457 asyncUnit.types = <ClassElement>[futureType.element, futureOrType.element, s treamType.element];
2457 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); 2458 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext();
2458 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode( 2459 LibraryElementImpl coreLibrary = new LibraryElementImpl.forNode(
2459 context, AstTestFactory.libraryIdentifier2(["dart.core"])); 2460 context, AstTestFactory.libraryIdentifier2(["dart.core"]));
2460 coreLibrary.definingCompilationUnit = coreUnit; 2461 coreLibrary.definingCompilationUnit = coreUnit;
2461 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode( 2462 LibraryElementImpl asyncLibrary = new LibraryElementImpl.forNode(
2462 context, AstTestFactory.libraryIdentifier2(["dart.async"])); 2463 context, AstTestFactory.libraryIdentifier2(["dart.async"]));
2463 asyncLibrary.definingCompilationUnit = asyncUnit; 2464 asyncLibrary.definingCompilationUnit = asyncUnit;
2464 // 2465 //
2465 // Create a type provider and ensure that it can return the expected types. 2466 // Create a type provider and ensure that it can return the expected types.
2466 // 2467 //
2467 TypeProviderImpl provider = new TypeProviderImpl(coreLibrary, asyncLibrary); 2468 TypeProviderImpl provider = new TypeProviderImpl(coreLibrary, asyncLibrary);
2468 expect(provider.boolType, same(boolType)); 2469 expect(provider.boolType, same(boolType));
2469 expect(provider.bottomType, isNotNull); 2470 expect(provider.bottomType, isNotNull);
2470 expect(provider.doubleType, same(doubleType)); 2471 expect(provider.doubleType, same(doubleType));
2471 expect(provider.dynamicType, isNotNull); 2472 expect(provider.dynamicType, isNotNull);
2472 expect(provider.functionType, same(functionType)); 2473 expect(provider.functionType, same(functionType));
2473 expect(provider.futureType, same(futureType)); 2474 expect(provider.futureType, same(futureType));
2475 expect(provider.futureOrType, same(futureOrType));
2474 expect(provider.intType, same(intType)); 2476 expect(provider.intType, same(intType));
2475 expect(provider.listType, same(listType)); 2477 expect(provider.listType, same(listType));
2476 expect(provider.mapType, same(mapType)); 2478 expect(provider.mapType, same(mapType));
2477 expect(provider.objectType, same(objectType)); 2479 expect(provider.objectType, same(objectType));
2478 expect(provider.stackTraceType, same(stackTraceType)); 2480 expect(provider.stackTraceType, same(stackTraceType));
2479 expect(provider.streamType, same(streamType)); 2481 expect(provider.streamType, same(streamType));
2480 expect(provider.stringType, same(stringType)); 2482 expect(provider.stringType, same(stringType));
2481 expect(provider.symbolType, same(symbolType)); 2483 expect(provider.symbolType, same(symbolType));
2482 expect(provider.typeType, same(typeType)); 2484 expect(provider.typeType, same(typeType));
2483 } 2485 }
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 */ 3616 */
3615 class _StaleElement extends ElementImpl { 3617 class _StaleElement extends ElementImpl {
3616 _StaleElement() : super("_StaleElement", -1); 3618 _StaleElement() : super("_StaleElement", -1);
3617 3619
3618 @override 3620 @override
3619 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3621 get kind => throw "_StaleElement's kind shouldn't be accessed";
3620 3622
3621 @override 3623 @override
3622 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited"; 3624 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited";
3623 } 3625 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/analysis_context_factory.dart ('k') | pkg/analyzer/test/generated/strong_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698