OLD | NEW |
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 | 6 |
7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
8 import com.google.common.collect.Lists; | 8 import com.google.common.collect.Lists; |
9 import com.google.common.collect.Sets; | 9 import com.google.common.collect.Sets; |
10 import com.google.dart.compiler.DartCompilationPhase; | 10 import com.google.dart.compiler.DartCompilationPhase; |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 case CLASS: | 1043 case CLASS: |
1044 // Must be a static field. | 1044 // Must be a static field. |
1045 element = Elements.findElement(((ClassElement) qualifier), x.getProper
tyName()); | 1045 element = Elements.findElement(((ClassElement) qualifier), x.getProper
tyName()); |
1046 switch (ElementKind.of(element)) { | 1046 switch (ElementKind.of(element)) { |
1047 case FIELD: | 1047 case FIELD: |
1048 FieldElement field = (FieldElement) element; | 1048 FieldElement field = (FieldElement) element; |
1049 if (!field.getModifiers().isStatic()) { | 1049 if (!field.getModifiers().isStatic()) { |
1050 onError(x.getName(), ResolverErrorCode.NOT_A_STATIC_FIELD, | 1050 onError(x.getName(), ResolverErrorCode.NOT_A_STATIC_FIELD, |
1051 x.getPropertyName()); | 1051 x.getPropertyName()); |
1052 } | 1052 } |
| 1053 if (Elements.inGetterContext(x)) { |
| 1054 if (field.getGetter() == null && field.getSetter() != null) { |
| 1055 onError(x.getName(), ResolverErrorCode.FIELD_DOES_NOT_HAVE_A_G
ETTER); |
| 1056 } |
| 1057 } |
| 1058 if (Elements.inSetterContext(x)) { |
| 1059 if (field.getSetter() == null && field.getGetter() != null) { |
| 1060 onError(x.getName(), ResolverErrorCode.FIELD_DOES_NOT_HAVE_A_S
ETTER); |
| 1061 } |
| 1062 } |
| 1063 |
1053 break; | 1064 break; |
1054 | 1065 |
1055 case NONE: | 1066 case NONE: |
1056 onError(x.getName(), ResolverErrorCode.CANNOT_BE_RESOLVED, | 1067 onError(x.getName(), ResolverErrorCode.CANNOT_BE_RESOLVED, |
1057 x.getPropertyName()); | 1068 x.getPropertyName()); |
1058 break; | 1069 break; |
1059 | 1070 |
1060 case METHOD: | 1071 case METHOD: |
1061 MethodElement method = (MethodElement) element; | 1072 MethodElement method = (MethodElement) element; |
1062 if (!method.getModifiers().isStatic()) { | 1073 if (!method.getModifiers().isStatic()) { |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 ClassElement nextClass = (ClassElement) nextConstructorElement.getEnclos
ingElement(); | 1868 ClassElement nextClass = (ClassElement) nextConstructorElement.getEnclos
ingElement(); |
1858 ClassElement currentClass = (ClassElement) constructor.getEnclosingEleme
nt(); | 1869 ClassElement currentClass = (ClassElement) constructor.getEnclosingEleme
nt(); |
1859 if (nextClass == currentClass) { | 1870 if (nextClass == currentClass) { |
1860 return (ConstructorNodeElement) nextConstructorElement; | 1871 return (ConstructorNodeElement) nextConstructorElement; |
1861 } | 1872 } |
1862 } | 1873 } |
1863 } | 1874 } |
1864 return null; | 1875 return null; |
1865 } | 1876 } |
1866 } | 1877 } |
OLD | NEW |