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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 2042293002: Adds status entries for initializing_formal tests. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js.typechecker; 5 library dart2js.typechecker;
6 6
7 import 'common/names.dart' show Identifiers; 7 import 'common/names.dart' show Identifiers;
8 import 'common/resolution.dart' show Resolution; 8 import 'common/resolution.dart' show Resolution;
9 import 'common/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'common.dart'; 10 import 'common.dart';
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 DartType visitIdentifier(Identifier node) { 674 DartType visitIdentifier(Identifier node) {
675 if (node.isThis()) { 675 if (node.isThis()) {
676 return thisType; 676 return thisType;
677 } else if (node.isSuper()) { 677 } else if (node.isSuper()) {
678 return superType; 678 return superType;
679 } else { 679 } else {
680 TypedElement element = elements[node]; 680 TypedElement element = elements[node];
681 assert(invariant(node, element != null, 681 assert(invariant(node, element != null,
682 message: 'Missing element for identifier')); 682 message: 'Missing element for identifier'));
683 assert(invariant( 683 assert(invariant(
684 node, element.isVariable || element.isParameter || element.isField, 684 node,
685 element.isVariable ||
686 element.isParameter ||
687 element.isField ||
688 (element.isInitializingFormal &&
689 compiler.options.enableInitializingFormalAccess),
685 message: 'Unexpected context element ${element}')); 690 message: 'Unexpected context element ${element}'));
686 return element.computeType(resolution); 691 return element.computeType(resolution);
687 } 692 }
688 } 693 }
689 694
690 DartType visitIf(If node) { 695 DartType visitIf(If node) {
691 Expression condition = node.condition.expression; 696 Expression condition = node.condition.expression;
692 Statement thenPart = node.thenPart; 697 Statement thenPart = node.thenPart;
693 698
694 checkCondition(node.condition); 699 checkCondition(node.condition);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 if (unaliasedBound.treatAsDynamic) { 760 if (unaliasedBound.treatAsDynamic) {
756 return new DynamicAccess(); 761 return new DynamicAccess();
757 } 762 }
758 InterfaceType interface = 763 InterfaceType interface =
759 Types.computeInterfaceType(resolution, unaliasedBound); 764 Types.computeInterfaceType(resolution, unaliasedBound);
760 ElementAccess access = getAccess(memberName, unaliasedBound, interface); 765 ElementAccess access = getAccess(memberName, unaliasedBound, interface);
761 if (access != null) { 766 if (access != null) {
762 return access; 767 return access;
763 } 768 }
764 if (receiverElement != null && 769 if (receiverElement != null &&
765 (receiverElement.isVariable || receiverElement.isParameter)) { 770 (receiverElement.isVariable || receiverElement.isParameter ||
771 (receiverElement.isInitializingFormal &&
772 compiler.options.enableInitializingFormalAccess))) {
766 Link<TypePromotion> typePromotions = typePromotionsMap[receiverElement]; 773 Link<TypePromotion> typePromotions = typePromotionsMap[receiverElement];
767 if (typePromotions != null) { 774 if (typePromotions != null) {
768 while (!typePromotions.isEmpty) { 775 while (!typePromotions.isEmpty) {
769 TypePromotion typePromotion = typePromotions.head; 776 TypePromotion typePromotion = typePromotions.head;
770 if (!typePromotion.isValid) { 777 if (!typePromotion.isValid) {
771 DartType unaliasedBound = 778 DartType unaliasedBound =
772 Types.computeUnaliasedBound(resolution, typePromotion.type); 779 Types.computeUnaliasedBound(resolution, typePromotion.type);
773 if (!unaliasedBound.treatAsDynamic) { 780 if (!unaliasedBound.treatAsDynamic) {
774 InterfaceType interface = 781 InterfaceType interface =
775 Types.computeInterfaceType(resolution, unaliasedBound); 782 Types.computeInterfaceType(resolution, unaliasedBound);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 return null; 1078 return null;
1072 } 1079 }
1073 } 1080 }
1074 1081
1075 ElementAccess createResolvedAccess(Send node, String name, Element element) { 1082 ElementAccess createResolvedAccess(Send node, String name, Element element) {
1076 checkPrivateAccess(node, element, name); 1083 checkPrivateAccess(node, element, name);
1077 return createPromotedAccess(element); 1084 return createPromotedAccess(element);
1078 } 1085 }
1079 1086
1080 ElementAccess createPromotedAccess(Element element) { 1087 ElementAccess createPromotedAccess(Element element) {
1081 if (element.isVariable || element.isParameter) { 1088 if (element.isVariable || element.isParameter ||
1089 (element.isInitializingFormal &&
1090 compiler.options.enableInitializingFormalAccess)) {
1082 TypePromotion typePromotion = getKnownTypePromotion(element); 1091 TypePromotion typePromotion = getKnownTypePromotion(element);
1083 if (typePromotion != null) { 1092 if (typePromotion != null) {
1084 return new PromotedAccess(element, typePromotion.type); 1093 return new PromotedAccess(element, typePromotion.type);
1085 } 1094 }
1086 } 1095 }
1087 return new ResolvedAccess(element); 1096 return new ResolvedAccess(element);
1088 } 1097 }
1089 1098
1090 /** 1099 /**
1091 * Computes the type of the access of [name] on the [node] possibly using the 1100 * Computes the type of the access of [name] on the [node] possibly using the
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 // Look for the variable element within parenthesized expressions. 1215 // Look for the variable element within parenthesized expressions.
1207 ParenthesizedExpression parentheses = 1216 ParenthesizedExpression parentheses =
1208 node.receiver.asParenthesizedExpression(); 1217 node.receiver.asParenthesizedExpression();
1209 while (parentheses != null) { 1218 while (parentheses != null) {
1210 variable = elements[parentheses.expression]; 1219 variable = elements[parentheses.expression];
1211 if (variable != null) break; 1220 if (variable != null) break;
1212 parentheses = parentheses.expression.asParenthesizedExpression(); 1221 parentheses = parentheses.expression.asParenthesizedExpression();
1213 } 1222 }
1214 } 1223 }
1215 1224
1216 if (variable != null && (variable.isVariable || variable.isParameter)) { 1225 if (variable != null &&
1226 (variable.isVariable ||
1227 variable.isParameter ||
1228 (variable.isInitializingFormal &&
1229 compiler.options.enableInitializingFormalAccess))) {
1217 DartType knownType = getKnownType(variable); 1230 DartType knownType = getKnownType(variable);
1218 if (!knownType.isDynamic) { 1231 if (!knownType.isDynamic) {
1219 DartType shownType = elements.getType(node.arguments.head); 1232 DartType shownType = elements.getType(node.arguments.head);
1220 TypePromotion typePromotion = 1233 TypePromotion typePromotion =
1221 new TypePromotion(node, variable, shownType); 1234 new TypePromotion(node, variable, shownType);
1222 if (!types.isMoreSpecific(shownType, knownType)) { 1235 if (!types.isMoreSpecific(shownType, knownType)) {
1223 String variableName = variable.name; 1236 String variableName = variable.name;
1224 if (!types.isSubtype(shownType, knownType)) { 1237 if (!types.isSubtype(shownType, knownType)) {
1225 typePromotion.addHint(reporter.createMessage( 1238 typePromotion.addHint(reporter.createMessage(
1226 node, MessageKind.NOT_MORE_SPECIFIC_SUBTYPE, { 1239 node, MessageKind.NOT_MORE_SPECIFIC_SUBTYPE, {
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 2039
2027 visitTypedef(Typedef node) { 2040 visitTypedef(Typedef node) {
2028 // Do not typecheck [Typedef] nodes. 2041 // Do not typecheck [Typedef] nodes.
2029 } 2042 }
2030 2043
2031 visitNode(Node node) { 2044 visitNode(Node node) {
2032 reporter.internalError(node, 2045 reporter.internalError(node,
2033 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 2046 'Unexpected node ${node.getObjectDescription()} in the type checker.');
2034 } 2047 }
2035 } 2048 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/dart_messages/lib/shared_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698