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

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

Issue 2039243002: Revert "New tests for initializing formal access." (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, 684 node, element.isVariable || element.isParameter || element.isField,
685 element.isVariable ||
686 element.isParameter ||
687 element.isField ||
688 (element.isInitializingFormal &&
689 compiler.options.enableInitializingFormalAccess),
690 message: 'Unexpected context element ${element}')); 685 message: 'Unexpected context element ${element}'));
691 return element.computeType(resolution); 686 return element.computeType(resolution);
692 } 687 }
693 } 688 }
694 689
695 DartType visitIf(If node) { 690 DartType visitIf(If node) {
696 Expression condition = node.condition.expression; 691 Expression condition = node.condition.expression;
697 Statement thenPart = node.thenPart; 692 Statement thenPart = node.thenPart;
698 693
699 checkCondition(node.condition); 694 checkCondition(node.condition);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 if (unaliasedBound.treatAsDynamic) { 755 if (unaliasedBound.treatAsDynamic) {
761 return new DynamicAccess(); 756 return new DynamicAccess();
762 } 757 }
763 InterfaceType interface = 758 InterfaceType interface =
764 Types.computeInterfaceType(resolution, unaliasedBound); 759 Types.computeInterfaceType(resolution, unaliasedBound);
765 ElementAccess access = getAccess(memberName, unaliasedBound, interface); 760 ElementAccess access = getAccess(memberName, unaliasedBound, interface);
766 if (access != null) { 761 if (access != null) {
767 return access; 762 return access;
768 } 763 }
769 if (receiverElement != null && 764 if (receiverElement != null &&
770 (receiverElement.isVariable || receiverElement.isParameter || 765 (receiverElement.isVariable || receiverElement.isParameter)) {
771 (receiverElement.isInitializingFormal &&
772 compiler.options.enableInitializingFormalAccess))) {
773 Link<TypePromotion> typePromotions = typePromotionsMap[receiverElement]; 766 Link<TypePromotion> typePromotions = typePromotionsMap[receiverElement];
774 if (typePromotions != null) { 767 if (typePromotions != null) {
775 while (!typePromotions.isEmpty) { 768 while (!typePromotions.isEmpty) {
776 TypePromotion typePromotion = typePromotions.head; 769 TypePromotion typePromotion = typePromotions.head;
777 if (!typePromotion.isValid) { 770 if (!typePromotion.isValid) {
778 DartType unaliasedBound = 771 DartType unaliasedBound =
779 Types.computeUnaliasedBound(resolution, typePromotion.type); 772 Types.computeUnaliasedBound(resolution, typePromotion.type);
780 if (!unaliasedBound.treatAsDynamic) { 773 if (!unaliasedBound.treatAsDynamic) {
781 InterfaceType interface = 774 InterfaceType interface =
782 Types.computeInterfaceType(resolution, unaliasedBound); 775 Types.computeInterfaceType(resolution, unaliasedBound);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 return null; 1071 return null;
1079 } 1072 }
1080 } 1073 }
1081 1074
1082 ElementAccess createResolvedAccess(Send node, String name, Element element) { 1075 ElementAccess createResolvedAccess(Send node, String name, Element element) {
1083 checkPrivateAccess(node, element, name); 1076 checkPrivateAccess(node, element, name);
1084 return createPromotedAccess(element); 1077 return createPromotedAccess(element);
1085 } 1078 }
1086 1079
1087 ElementAccess createPromotedAccess(Element element) { 1080 ElementAccess createPromotedAccess(Element element) {
1088 if (element.isVariable || element.isParameter || 1081 if (element.isVariable || element.isParameter) {
1089 (element.isInitializingFormal &&
1090 compiler.options.enableInitializingFormalAccess)) {
1091 TypePromotion typePromotion = getKnownTypePromotion(element); 1082 TypePromotion typePromotion = getKnownTypePromotion(element);
1092 if (typePromotion != null) { 1083 if (typePromotion != null) {
1093 return new PromotedAccess(element, typePromotion.type); 1084 return new PromotedAccess(element, typePromotion.type);
1094 } 1085 }
1095 } 1086 }
1096 return new ResolvedAccess(element); 1087 return new ResolvedAccess(element);
1097 } 1088 }
1098 1089
1099 /** 1090 /**
1100 * Computes the type of the access of [name] on the [node] possibly using the 1091 * 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
1215 // Look for the variable element within parenthesized expressions. 1206 // Look for the variable element within parenthesized expressions.
1216 ParenthesizedExpression parentheses = 1207 ParenthesizedExpression parentheses =
1217 node.receiver.asParenthesizedExpression(); 1208 node.receiver.asParenthesizedExpression();
1218 while (parentheses != null) { 1209 while (parentheses != null) {
1219 variable = elements[parentheses.expression]; 1210 variable = elements[parentheses.expression];
1220 if (variable != null) break; 1211 if (variable != null) break;
1221 parentheses = parentheses.expression.asParenthesizedExpression(); 1212 parentheses = parentheses.expression.asParenthesizedExpression();
1222 } 1213 }
1223 } 1214 }
1224 1215
1225 if (variable != null && 1216 if (variable != null && (variable.isVariable || variable.isParameter)) {
1226 (variable.isVariable ||
1227 variable.isParameter ||
1228 (variable.isInitializingFormal &&
1229 compiler.options.enableInitializingFormalAccess))) {
1230 DartType knownType = getKnownType(variable); 1217 DartType knownType = getKnownType(variable);
1231 if (!knownType.isDynamic) { 1218 if (!knownType.isDynamic) {
1232 DartType shownType = elements.getType(node.arguments.head); 1219 DartType shownType = elements.getType(node.arguments.head);
1233 TypePromotion typePromotion = 1220 TypePromotion typePromotion =
1234 new TypePromotion(node, variable, shownType); 1221 new TypePromotion(node, variable, shownType);
1235 if (!types.isMoreSpecific(shownType, knownType)) { 1222 if (!types.isMoreSpecific(shownType, knownType)) {
1236 String variableName = variable.name; 1223 String variableName = variable.name;
1237 if (!types.isSubtype(shownType, knownType)) { 1224 if (!types.isSubtype(shownType, knownType)) {
1238 typePromotion.addHint(reporter.createMessage( 1225 typePromotion.addHint(reporter.createMessage(
1239 node, MessageKind.NOT_MORE_SPECIFIC_SUBTYPE, { 1226 node, MessageKind.NOT_MORE_SPECIFIC_SUBTYPE, {
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 2026
2040 visitTypedef(Typedef node) { 2027 visitTypedef(Typedef node) {
2041 // Do not typecheck [Typedef] nodes. 2028 // Do not typecheck [Typedef] nodes.
2042 } 2029 }
2043 2030
2044 visitNode(Node node) { 2031 visitNode(Node node) {
2045 reporter.internalError(node, 2032 reporter.internalError(node,
2046 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 2033 'Unexpected node ${node.getObjectDescription()} in the type checker.');
2047 } 2034 }
2048 } 2035 }
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