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

Unified Diff: runtime/vm/parser.cc

Issue 10108020: Fix bug 1991, variable resolution in string interpolation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 6643)
+++ runtime/vm/parser.cc (working copy)
@@ -7094,8 +7094,21 @@
AstNode* var_or_field = NULL;
ResolveIdentInLocalScope(ident_pos, ident, &var_or_field);
if (var_or_field == NULL) {
- // Not found in the local scope, so try finding the variable in the
- // library scope (current library and all libraries imported by it).
+ // Check whether the identifier is a type parameter. Type parameters
+ // can never be used in primary expressions.
+ const Class& scope_class = Class::Handle(TypeParametersScopeClass());
+ if (!scope_class.IsNull()) {
+ TypeParameter& type_param = TypeParameter::Handle(
+ scope_class.LookupTypeParameter(ident, ident_pos));
+ if (!type_param.IsNull()) {
+ String& type_param_name = String::Handle(type_param.Name());
+ ErrorMsg(ident_pos, "illegal use of type parameter %s",
+ type_param_name.ToCString());
+ }
+ }
+ // Not found in the local scope, and the name is not a type parameter.
+ // Try finding the variable in the library scope (current library
+ // and all libraries imported by it).
QualIdent qual_ident;
qual_ident.lib_prefix = NULL;
qual_ident.ident_pos = ident_pos;
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698