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

Side by Side Diff: compiler/java/com/google/dart/compiler/resolver/ResolutionContext.java

Issue 10911087: Issue 4903. Better error message when static method attempts to use type variable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 package com.google.dart.compiler.resolver; 5 package com.google.dart.compiler.resolver;
6 import com.google.common.annotations.VisibleForTesting; 6 import com.google.common.annotations.VisibleForTesting;
7 import com.google.dart.compiler.DartCompilationError; 7 import com.google.dart.compiler.DartCompilationError;
8 import com.google.dart.compiler.DartCompilerContext; 8 import com.google.dart.compiler.DartCompilerContext;
9 import com.google.dart.compiler.ErrorCode; 9 import com.google.dart.compiler.ErrorCode;
10 import com.google.dart.compiler.ErrorSeverity; 10 import com.google.dart.compiler.ErrorSeverity;
11 import com.google.dart.compiler.PackageLibraryManager;
11 import com.google.dart.compiler.Source; 12 import com.google.dart.compiler.Source;
12 import com.google.dart.compiler.SubSystem; 13 import com.google.dart.compiler.SubSystem;
13 import com.google.dart.compiler.PackageLibraryManager;
14 import com.google.dart.compiler.ast.ASTVisitor; 14 import com.google.dart.compiler.ast.ASTVisitor;
15 import com.google.dart.compiler.ast.DartFunctionExpression; 15 import com.google.dart.compiler.ast.DartFunctionExpression;
16 import com.google.dart.compiler.ast.DartFunctionTypeAlias; 16 import com.google.dart.compiler.ast.DartFunctionTypeAlias;
17 import com.google.dart.compiler.ast.DartIdentifier; 17 import com.google.dart.compiler.ast.DartIdentifier;
18 import com.google.dart.compiler.ast.DartNode; 18 import com.google.dart.compiler.ast.DartNode;
19 import com.google.dart.compiler.ast.DartPropertyAccess; 19 import com.google.dart.compiler.ast.DartPropertyAccess;
20 import com.google.dart.compiler.ast.DartSyntheticErrorIdentifier; 20 import com.google.dart.compiler.ast.DartSyntheticErrorIdentifier;
21 import com.google.dart.compiler.ast.DartTypeNode; 21 import com.google.dart.compiler.ast.DartTypeNode;
22 import com.google.dart.compiler.ast.LibraryUnit; 22 import com.google.dart.compiler.ast.LibraryUnit;
23 import com.google.dart.compiler.ast.Modifiers; 23 import com.google.dart.compiler.ast.Modifiers;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 case CLASS: 236 case CLASS:
237 case FUNCTION_TYPE_ALIAS: 237 case FUNCTION_TYPE_ALIAS:
238 return instantiateParameterizedType((ClassElement)existingElement, 238 return instantiateParameterizedType((ClassElement)existingElement,
239 diagnosticNode, 239 diagnosticNode,
240 typeArguments, 240 typeArguments,
241 isStatic, 241 isStatic,
242 isFactory, 242 isFactory,
243 errorCode, 243 errorCode,
244 wrongNumberErrorCode); 244 wrongNumberErrorCode);
245 case NONE: 245 case NONE:
246 default:
246 if (errorCode.getSubSystem().equals(SubSystem.RESOLVER)) { 247 if (errorCode.getSubSystem().equals(SubSystem.RESOLVER)) {
247 onError(identifier, ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CO NTEXT, 248 onError(identifier, ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CO NTEXT,
248 identifier); 249 identifier);
249 } else { 250 } else {
250 onError(identifier, TypeErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEX T, 251 onError(identifier, TypeErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEX T,
251 identifier); 252 identifier);
252 } 253 }
253 return typeProvider.getDynamicType(); 254 return typeProvider.getDynamicType();
254
255 default:
256 if (errorCode.getSubSystem().equals(SubSystem.RESOLVER)) {
257 onError(identifier, ResolverErrorCode.NOT_A_TYPE, identifier, el ementKind);
258 } else {
259 onError(identifier, TypeErrorCode.NOT_A_TYPE, identifier, elemen tKind);
260 }
261 return typeProvider.getDynamicType();
262 } 255 }
263 } 256 }
264 return makeTypeVariable(typeVariableElement, typeArguments); 257 return makeTypeVariable(typeVariableElement, typeArguments);
265 } 258 }
266 case CLASS: 259 case CLASS:
267 case FUNCTION_TYPE_ALIAS: 260 case FUNCTION_TYPE_ALIAS:
268 return instantiateParameterizedType( 261 return instantiateParameterizedType(
269 (ClassElement) element, 262 (ClassElement) element,
270 diagnosticNode, 263 diagnosticNode,
271 typeArguments, 264 typeArguments,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 String name = node.getName(); 406 String name = node.getName();
414 return scope.findElement(scope.getLibrary(), name); 407 return scope.findElement(scope.getLibrary(), name);
415 } 408 }
416 409
417 @Override 410 @Override
418 public Element visitSyntheticErrorIdentifier(DartSyntheticErrorIdentifier no de) { 411 public Element visitSyntheticErrorIdentifier(DartSyntheticErrorIdentifier no de) {
419 return Elements.dynamicElement(); 412 return Elements.dynamicElement();
420 } 413 }
421 } 414 }
422 } 415 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698