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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 2001093006: Changes dart2js to warn at reified usage of method type variables. (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
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Selectors; 8 import '../common/names.dart' show Selectors;
9 import '../common/resolution.dart' show Feature; 9 import '../common/resolution.dart' show Feature;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 // `e is! T`. 1114 // `e is! T`.
1115 Node typeNode = notTypeNode.receiver; 1115 Node typeNode = notTypeNode.receiver;
1116 type = resolveTypeAnnotation(typeNode); 1116 type = resolveTypeAnnotation(typeNode);
1117 sendStructure = new IsNotStructure(type); 1117 sendStructure = new IsNotStructure(type);
1118 } else { 1118 } else {
1119 // `e is T`. 1119 // `e is T`.
1120 Node typeNode = node.arguments.head; 1120 Node typeNode = node.arguments.head;
1121 type = resolveTypeAnnotation(typeNode); 1121 type = resolveTypeAnnotation(typeNode);
1122 sendStructure = new IsStructure(type); 1122 sendStructure = new IsStructure(type);
1123 } 1123 }
1124
1125 // GENERIC_METHODS: Method type variables are not reified so we must warn
1126 // about the error which will occur at runtime.
1127 if (type is MethodTypeVariableType) {
1128 reporter.reportWarningMessage(
1129 node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
1130 }
1131
1124 registry.registerTypeUse(new TypeUse.isCheck(type)); 1132 registry.registerTypeUse(new TypeUse.isCheck(type));
1125 registry.registerSendStructure(node, sendStructure); 1133 registry.registerSendStructure(node, sendStructure);
1126 return const NoneResult(); 1134 return const NoneResult();
1127 } 1135 }
1128 1136
1129 /// Handle a type cast expression, like `a as T`. 1137 /// Handle a type cast expression, like `a as T`.
1130 ResolutionResult handleAs(Send node) { 1138 ResolutionResult handleAs(Send node) {
1131 Node expression = node.receiver; 1139 Node expression = node.receiver;
1132 visitExpression(expression); 1140 visitExpression(expression);
1133 1141
1134 Node typeNode = node.arguments.head; 1142 Node typeNode = node.arguments.head;
1135 DartType type = resolveTypeAnnotation(typeNode); 1143 DartType type = resolveTypeAnnotation(typeNode);
1144
1145 // GENERIC_METHODS: Method type variables are not reified so we must warn
1146 // about the error which will occur at runtime.
1147 if (type is MethodTypeVariableType) {
1148 reporter.reportWarningMessage(
1149 node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
1150 }
1151
1136 registry.registerTypeUse(new TypeUse.asCast(type)); 1152 registry.registerTypeUse(new TypeUse.asCast(type));
1137 registry.registerSendStructure(node, new AsStructure(type)); 1153 registry.registerSendStructure(node, new AsStructure(type));
1138 return const NoneResult(); 1154 return const NoneResult();
1139 } 1155 }
1140 1156
1141 /// Handle the unary expression of an unresolved unary operator [text], like 1157 /// Handle the unary expression of an unresolved unary operator [text], like
1142 /// the no longer supported `+a`. 1158 /// the no longer supported `+a`.
1143 ResolutionResult handleUnresolvedUnary(Send node, String text) { 1159 ResolutionResult handleUnresolvedUnary(Send node, String text) {
1144 Node expression = node.receiver; 1160 Node expression = node.receiver;
1145 if (node.isSuperCall) { 1161 if (node.isSuperCall) {
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 node, 1897 node,
1882 name.text, 1898 name.text,
1883 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 1899 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
1884 {'typeVariableName': name}, 1900 {'typeVariableName': name},
1885 isError: true); 1901 isError: true);
1886 registry.registerFeature(Feature.COMPILE_TIME_ERROR); 1902 registry.registerFeature(Feature.COMPILE_TIME_ERROR);
1887 semantics = new StaticAccess.invalid(error); 1903 semantics = new StaticAccess.invalid(error);
1888 // TODO(johnniwinther): Clean up registration of elements and selectors 1904 // TODO(johnniwinther): Clean up registration of elements and selectors
1889 // for this case. 1905 // for this case.
1890 } else { 1906 } else {
1907 // GENERIC_METHODS: Method type variables are not reified so we must warn
1908 // about the error which will occur at runtime.
1909 if (element.type is MethodTypeVariableType) {
1910 reporter.reportWarningMessage(
1911 node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
1912 }
1891 semantics = new StaticAccess.typeParameterTypeLiteral(element); 1913 semantics = new StaticAccess.typeParameterTypeLiteral(element);
1892 } 1914 }
1893 1915
1894 registry.useElement(node, element); 1916 registry.useElement(node, element);
1895 registry.registerTypeLiteral(node, element.type); 1917 registry.registerTypeLiteral(node, element.type);
1896 1918
1897 if (node.isCall) { 1919 if (node.isCall) {
1898 CallStructure callStructure = 1920 CallStructure callStructure =
1899 resolveArguments(node.argumentsNode).callStructure; 1921 resolveArguments(node.argumentsNode).callStructure;
1900 Selector selector = callStructure.callSelector; 1922 Selector selector = callStructure.callSelector;
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after
4696 } 4718 }
4697 return const NoneResult(); 4719 return const NoneResult();
4698 } 4720 }
4699 } 4721 }
4700 4722
4701 /// Looks up [name] in [scope] and unwraps the result. 4723 /// Looks up [name] in [scope] and unwraps the result.
4702 Element lookupInScope( 4724 Element lookupInScope(
4703 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4725 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4704 return Elements.unwrap(scope.lookup(name), reporter, node); 4726 return Elements.unwrap(scope.lookup(name), reporter, node);
4705 } 4727 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698