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.base.Joiner; | 7 import com.google.common.base.Joiner; |
8 import com.google.dart.compiler.DartCompilationError; | 8 import com.google.dart.compiler.DartCompilationError; |
9 import com.google.dart.compiler.ErrorCode; | 9 import com.google.dart.compiler.ErrorCode; |
10 import com.google.dart.compiler.ast.DartClass; | 10 import com.google.dart.compiler.ast.DartClass; |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 " static final f6;", // error | 1126 " static final f6;", // error |
1127 " method() {", | 1127 " method() {", |
1128 " final f7 = 1;", | 1128 " final f7 = 1;", |
1129 " final f8;", // error | 1129 " final f8;", // error |
1130 " }", | 1130 " }", |
1131 "}"), | 1131 "}"), |
1132 errEx(ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE, 4, 7 , 2), | 1132 errEx(ResolverErrorCode.TOPLEVEL_FINAL_REQUIRES_VALUE, 4, 7 , 2), |
1133 errEx(ResolverErrorCode.STATIC_FINAL_REQUIRES_VALUE, 9, 16, 2), | 1133 errEx(ResolverErrorCode.STATIC_FINAL_REQUIRES_VALUE, 9, 16, 2), |
1134 errEx(ResolverErrorCode.CONSTANTS_MUST_BE_INITIALIZED, 12, 11, 2)); | 1134 errEx(ResolverErrorCode.CONSTANTS_MUST_BE_INITIALIZED, 12, 11, 2)); |
1135 } | 1135 } |
| 1136 |
| 1137 public void testNoGetterOrSetter() { |
| 1138 resolveAndTest(Joiner.on("\n").join( |
| 1139 "class Object {}", |
| 1140 "get getter1() {}", |
| 1141 "set setter1(arg) {}", |
| 1142 "class A {", |
| 1143 " static get getter2() {}", |
| 1144 " static set setter2(arg) {}", |
| 1145 " get getter3() {}", |
| 1146 " set setter3(arg) {}", |
| 1147 "}", |
| 1148 "method() {", |
| 1149 " var result;", |
| 1150 " result = getter1;", |
| 1151 " getter1 = 1;", |
| 1152 " result = setter1;", |
| 1153 " setter1 = 1;", |
| 1154 " result = A.getter2;", |
| 1155 " A.getter2 = 1;", |
| 1156 " result = A.setter2;", |
| 1157 " A.setter2 = 1;", |
| 1158 " var instance = new A();", |
| 1159 " result = instance.getter3;", |
| 1160 " instance.getter3 = 1;", |
| 1161 " result = instance.setter3;", |
| 1162 " instance.setter3 = 1;", |
| 1163 "}"), |
| 1164 errEx(ResolverErrorCode.FIELD_DOES_NOT_HAVE_A_SETTER, 17, 5, 7), |
| 1165 errEx(ResolverErrorCode.FIELD_DOES_NOT_HAVE_A_GETTER, 18, 14, 7)); |
| 1166 } |
1136 } | 1167 } |
OLD | NEW |