Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 6 |
| 7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
| 8 import com.google.dart.compiler.ast.DartClass; | 8 import com.google.dart.compiler.ast.DartClass; |
| 9 import com.google.dart.compiler.ast.DartField; | 9 import com.google.dart.compiler.ast.DartField; |
| 10 import com.google.dart.compiler.ast.DartFunctionExpression; | 10 import com.google.dart.compiler.ast.DartFunctionExpression; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 } else { | 104 } else { |
| 105 throw new IllegalArgumentException(); | 105 throw new IllegalArgumentException(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 public static void addParameter(MethodElement method, VariableElement paramete r) { | 109 public static void addParameter(MethodElement method, VariableElement paramete r) { |
| 110 ((MethodElementImplementation) method).addParameter(parameter); | 110 ((MethodElementImplementation) method).addParameter(parameter); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static Element findElement(ClassElement cls, String name) { | 113 static Element findElement(ClassElement cls, String name) { |
| 114 return ((ClassElementImplementation) cls).findElement(name); | 114 if (cls instanceof ClassElementImplementation) { |
|
zundel
2011/10/24 15:07:44
I think rather than an instanceof test, the prefer
scheglov
2011/10/24 19:57:55
I'm not sure.
At first, we cast to this type, so i
| |
| 115 return ((ClassElementImplementation) cls).findElement(name); | |
| 116 } | |
| 117 return null; | |
| 115 } | 118 } |
| 116 | 119 |
| 117 public static MethodElement methodFromFunctionExpression(DartFunctionExpressio n node, | 120 public static MethodElement methodFromFunctionExpression(DartFunctionExpressio n node, |
| 118 Modifiers modifiers) { | 121 Modifiers modifiers) { |
| 119 return MethodElementImplementation.fromFunctionExpression(node, modifiers); | 122 return MethodElementImplementation.fromFunctionExpression(node, modifiers); |
| 120 } | 123 } |
| 121 | 124 |
| 122 static MethodElement methodFromMethodNode(DartMethodDefinition node, Enclosing Element holder) { | 125 static MethodElement methodFromMethodNode(DartMethodDefinition node, Enclosing Element holder) { |
| 123 return MethodElementImplementation.fromMethodNode(node, holder); | 126 return MethodElementImplementation.fromMethodNode(node, holder); |
| 124 } | 127 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 return VoidElement.getInstance(); | 213 return VoidElement.getInstance(); |
| 211 } | 214 } |
| 212 | 215 |
| 213 /** | 216 /** |
| 214 * Returns true if the class needs an implicit default constructor. | 217 * Returns true if the class needs an implicit default constructor. |
| 215 */ | 218 */ |
| 216 public static boolean needsImplicitDefaultConstructor(ClassElement classElemen t) { | 219 public static boolean needsImplicitDefaultConstructor(ClassElement classElemen t) { |
| 217 return !classElement.isObject() && classElement.getConstructors().isEmpty(); | 220 return !classElement.isObject() && classElement.getConstructors().isEmpty(); |
| 218 } | 221 } |
| 219 } | 222 } |
| OLD | NEW |