| 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 /** A formal parameter to a [Method]. */ | 5 /** A formal parameter to a [Method]. */ |
| 6 class Parameter { | 6 class Parameter { |
| 7 FormalNode definition; | 7 FormalNode definition; |
| 8 Member method; | 8 Member method; |
| 9 | 9 |
| 10 String name; | 10 String name; |
| 11 Type type; | 11 Type type; |
| 12 bool isInitializer = false; | 12 bool isInitializer = false; |
| 13 | 13 |
| 14 Value value; | 14 Value value; |
| 15 | 15 |
| 16 Parameter(this.definition, this.method); | 16 Parameter(this.definition, this.method); |
| 17 | 17 |
| 18 resolve() { | 18 resolve() { |
| 19 name = definition.name.name; | 19 name = definition.name.name; |
| 20 if (name.startsWith('this.')) { | 20 if (name.startsWith('this.')) { |
| 21 name = name.substring(5); | 21 name = name.substring(5); |
| 22 isInitializer = true; | 22 isInitializer = true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 type = method.resolveType(definition.type, false); | 25 type = method.resolveType(definition.type, false); |
| 26 | 26 |
| 27 if (method.isStatic && method.typeParameters === null && type.hasTypeParams)
{ | |
| 28 world.error('using type parameter in static context', definition.span); | |
| 29 } | |
| 30 | |
| 31 if (definition.value != null) { | 27 if (definition.value != null) { |
| 32 // To match VM, detect cases where value was not actually specified in | 28 // To match VM, detect cases where value was not actually specified in |
| 33 // code and don't signal errors. | 29 // code and don't signal errors. |
| 34 // TODO(jimhug): Clean up after issue #352 is resolved. | 30 // TODO(jimhug): Clean up after issue #352 is resolved. |
| 35 if (definition.value is NullExpression && | 31 if (definition.value is NullExpression && |
| 36 definition.value.span.start == definition.span.start) { | 32 definition.value.span.start == definition.span.start) { |
| 37 return; | 33 return; |
| 38 } | 34 } |
| 39 if (method.name == ':call') { | 35 if (method.name == ':call') { |
| 40 // TODO(jimhug): Need simpler way to detect "true" function types vs. | 36 // TODO(jimhug): Need simpler way to detect "true" function types vs. |
| (...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 // TODO(jimhug): Clean up construction of Parameters. | 1379 // TODO(jimhug): Clean up construction of Parameters. |
| 1384 var param = new Parameter(formal, this); | 1380 var param = new Parameter(formal, this); |
| 1385 param.resolve(); | 1381 param.resolve(); |
| 1386 parameters.add(param); | 1382 parameters.add(param); |
| 1387 } | 1383 } |
| 1388 | 1384 |
| 1389 if (!isLambda) { | 1385 if (!isLambda) { |
| 1390 library._addMember(this); | 1386 library._addMember(this); |
| 1391 } | 1387 } |
| 1392 } | 1388 } |
| 1389 |
| 1390 /** Overriden to ensure that type arguments aren't used in static methods. */ |
| 1391 Type resolveType(TypeReference node, bool typeErrors) { |
| 1392 Type t = super.resolveType(node, typeErrors); |
| 1393 if (isStatic && t is ParameterType && |
| 1394 (typeParameters === null || !typeParameters.some((p) => p === t))) { |
| 1395 world.error('using type parameter in static context.', node.span); |
| 1396 } |
| 1397 return t; |
| 1398 } |
| 1393 } | 1399 } |
| 1394 | 1400 |
| 1395 | 1401 |
| 1396 class MemberSet { | 1402 class MemberSet { |
| 1397 final String name; | 1403 final String name; |
| 1398 final List<Member> members; | 1404 final List<Member> members; |
| 1399 final String jsname; | 1405 final String jsname; |
| 1400 final bool isVar; | 1406 final bool isVar; |
| 1401 | 1407 |
| 1402 MemberSet(Member member, [bool isVar=false]): | 1408 MemberSet(Member member, [bool isVar=false]): |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 } | 1731 } |
| 1726 | 1732 |
| 1727 void forEach(void f(Member member)) { | 1733 void forEach(void f(Member member)) { |
| 1728 factories.forEach((_, Map constructors) { | 1734 factories.forEach((_, Map constructors) { |
| 1729 constructors.forEach((_, Member member) { | 1735 constructors.forEach((_, Member member) { |
| 1730 f(member); | 1736 f(member); |
| 1731 }); | 1737 }); |
| 1732 }); | 1738 }); |
| 1733 } | 1739 } |
| 1734 } | 1740 } |
| OLD | NEW |