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

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

Issue 707073002: Fix analyzer's treatment of mixin constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve error message. Created 6 years, 1 month 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 | Annotate | Revision Log
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 engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'package:analyzer/src/generated/java_core.dart'; 8 import 'package:analyzer/src/generated/java_core.dart';
9 import 'package:analyzer/src/generated/java_engine.dart'; 9 import 'package:analyzer/src/generated/java_engine.dart';
10 import 'package:analyzer/src/generated/java_engine_io.dart'; 10 import 'package:analyzer/src/generated/java_engine_io.dart';
(...skipping 11444 matching lines...) Expand 10 before | Expand all | Expand 10 after
11455 expect(elementA.supertype, same(elementB.type)); 11455 expect(elementA.supertype, same(elementB.type));
11456 List<InterfaceType> mixins = elementA.mixins; 11456 List<InterfaceType> mixins = elementA.mixins;
11457 expect(mixins, hasLength(1)); 11457 expect(mixins, hasLength(1));
11458 expect(mixins[0], same(elementC.type)); 11458 expect(mixins[0], same(elementC.type));
11459 List<InterfaceType> interfaces = elementA.interfaces; 11459 List<InterfaceType> interfaces = elementA.interfaces;
11460 expect(interfaces, hasLength(1)); 11460 expect(interfaces, hasLength(1));
11461 expect(interfaces[0], same(elementD.type)); 11461 expect(interfaces[0], same(elementD.type));
11462 _listener.assertNoErrors(); 11462 _listener.assertNoErrors();
11463 } 11463 }
11464 11464
11465 void test_visitClassTypeAlias_constructorWithOptionalParams_ignored() {
11466 // class T {}
11467 // class B {
11468 // B.c1();
11469 // B.c2([T a0]);
11470 // B.c3({T a0});
11471 // }
11472 // class M {}
11473 // class C = B with M
11474 ClassElement classT = ElementFactory.classElement2('T', []);
11475 ClassElementImpl classB = ElementFactory.classElement2('B', []);
11476 ConstructorElementImpl constructorBc1 =
11477 ElementFactory.constructorElement2(classB, 'c1', []);
11478 ConstructorElementImpl constructorBc2 =
11479 ElementFactory.constructorElement2(classB, 'c2', [classT.type]);
11480 (constructorBc2.parameters[0] as ParameterElementImpl).parameterKind =
11481 ParameterKind.POSITIONAL;
11482 ConstructorElementImpl constructorBc3 =
11483 ElementFactory.constructorElement2(classB, 'c3', [classT.type]);
11484 (constructorBc3.parameters[0] as ParameterElementImpl).parameterKind =
11485 ParameterKind.NAMED;
11486 classB.constructors = [constructorBc1, constructorBc2, constructorBc3];
11487 ClassElement classM = ElementFactory.classElement2('M', []);
11488 WithClause withClause =
11489 AstFactory.withClause([AstFactory.typeName(classM, [])]);
11490 ClassElement classC = ElementFactory.classElement2('C', []);
11491 ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
11492 AstFactory.typeName(classB, []), withClause, null);
11493 alias.name.staticElement = classC;
11494 _resolveNode(alias, [classT, classB, classM, classC]);
11495 expect(classC.constructors, hasLength(1));
11496 ConstructorElement constructor = classC.constructors[0];
11497 expect(constructor.isFactory, isFalse);
11498 expect(constructor.isSynthetic, isTrue);
11499 expect(constructor.name, 'c1');
11500 expect(constructor.functions, hasLength(0));
11501 expect(constructor.labels, hasLength(0));
11502 expect(constructor.localVariables, hasLength(0));
11503 expect(constructor.parameters, isEmpty);
11504 }
11505
11506 void test_visitClassTypeAlias_constructorWithParams() {
11507 // class T {}
11508 // class B {
11509 // B(T a0);
11510 // }
11511 // class M {}
11512 // class C = B with M
11513 ClassElement classT = ElementFactory.classElement2('T', []);
11514 ClassElementImpl classB = ElementFactory.classElement2('B', []);
11515 ConstructorElementImpl constructorB =
11516 ElementFactory.constructorElement2(classB, '', [classT.type]);
11517 classB.constructors = [constructorB];
11518 ClassElement classM = ElementFactory.classElement2('M', []);
11519 WithClause withClause =
11520 AstFactory.withClause([AstFactory.typeName(classM, [])]);
11521 ClassElement classC = ElementFactory.classElement2('C', []);
11522 ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
11523 AstFactory.typeName(classB, []), withClause, null);
11524 alias.name.staticElement = classC;
11525 _resolveNode(alias, [classT, classB, classM, classC]);
11526 expect(classC.constructors, hasLength(1));
11527 ConstructorElement constructor = classC.constructors[0];
11528 expect(constructor.isFactory, isFalse);
11529 expect(constructor.isSynthetic, isTrue);
11530 expect(constructor.name, '');
11531 expect(constructor.functions, hasLength(0));
11532 expect(constructor.labels, hasLength(0));
11533 expect(constructor.localVariables, hasLength(0));
11534 expect(constructor.parameters, hasLength(1));
11535 expect(constructor.parameters[0].type, equals(classT.type));
11536 expect(constructor.parameters[0].name,
11537 equals(constructorB.parameters[0].name));
11538 }
11539
11540 void test_visitClassTypeAlias_defaultConstructor() {
11541 // class B {}
11542 // class M {}
11543 // class C = B with M
11544 ClassElementImpl classB = ElementFactory.classElement2('B', []);
11545 ConstructorElementImpl constructorB =
11546 ElementFactory.constructorElement2(classB, '', []);
11547 constructorB.setModifier(Modifier.SYNTHETIC, true);
11548 classB.constructors = [constructorB];
11549 ClassElement classM = ElementFactory.classElement2('M', []);
11550 WithClause withClause =
11551 AstFactory.withClause([AstFactory.typeName(classM, [])]);
11552 ClassElement classC = ElementFactory.classElement2('C', []);
11553 ClassTypeAlias alias = AstFactory.classTypeAlias('C', null, null,
11554 AstFactory.typeName(classB, []), withClause, null);
11555 alias.name.staticElement = classC;
11556 _resolveNode(alias, [classB, classM, classC]);
11557 expect(classC.constructors, hasLength(1));
11558 ConstructorElement constructor = classC.constructors[0];
11559 expect(constructor.isFactory, isFalse);
11560 expect(constructor.isSynthetic, isTrue);
11561 expect(constructor.name, '');
11562 expect(constructor.functions, hasLength(0));
11563 expect(constructor.labels, hasLength(0));
11564 expect(constructor.localVariables, hasLength(0));
11565 expect(constructor.parameters, isEmpty);
11566 }
11567
11465 void test_visitFieldFormalParameter_functionType() { 11568 void test_visitFieldFormalParameter_functionType() {
11466 InterfaceType intType = _typeProvider.intType; 11569 InterfaceType intType = _typeProvider.intType;
11467 TypeName intTypeName = AstFactory.typeName4("int", []); 11570 TypeName intTypeName = AstFactory.typeName4("int", []);
11468 String innerParameterName = "a"; 11571 String innerParameterName = "a";
11469 SimpleFormalParameter parameter = AstFactory.simpleFormalParameter3(innerPar ameterName); 11572 SimpleFormalParameter parameter = AstFactory.simpleFormalParameter3(innerPar ameterName);
11470 parameter.identifier.staticElement = ElementFactory.requiredParameter(innerP arameterName); 11573 parameter.identifier.staticElement = ElementFactory.requiredParameter(innerP arameterName);
11471 String outerParameterName = "p"; 11574 String outerParameterName = "p";
11472 FormalParameter node = AstFactory.fieldFormalParameter(null, intTypeName, ou terParameterName, AstFactory.formalParameterList([parameter])); 11575 FormalParameter node = AstFactory.fieldFormalParameter(null, intTypeName, ou terParameterName, AstFactory.formalParameterList([parameter]));
11473 node.identifier.staticElement = ElementFactory.requiredParameter(outerParame terName); 11576 node.identifier.staticElement = ElementFactory.requiredParameter(outerParame terName);
11474 DartType parameterType = _resolveFormalParameter(node, [intType.element]); 11577 DartType parameterType = _resolveFormalParameter(node, [intType.element]);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
11641 runReflectiveTests(TypeResolverVisitorTest); 11744 runReflectiveTests(TypeResolverVisitorTest);
11642 runReflectiveTests(CheckedModeCompileTimeErrorCodeTest); 11745 runReflectiveTests(CheckedModeCompileTimeErrorCodeTest);
11643 runReflectiveTests(ErrorResolverTest); 11746 runReflectiveTests(ErrorResolverTest);
11644 runReflectiveTests(HintCodeTest); 11747 runReflectiveTests(HintCodeTest);
11645 runReflectiveTests(MemberMapTest); 11748 runReflectiveTests(MemberMapTest);
11646 runReflectiveTests(NonHintCodeTest); 11749 runReflectiveTests(NonHintCodeTest);
11647 runReflectiveTests(SimpleResolverTest); 11750 runReflectiveTests(SimpleResolverTest);
11648 runReflectiveTests(StrictModeTest); 11751 runReflectiveTests(StrictModeTest);
11649 runReflectiveTests(TypePropagationTest); 11752 runReflectiveTests(TypePropagationTest);
11650 } 11753 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698