| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library analyzer.test.generated.simple_resolver_test; | 5 library analyzer.test.generated.simple_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 CompilationUnitElement unit = library.definingCompilationUnit; | 1100 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1101 expect(unit, isNotNull); | 1101 expect(unit, isNotNull); |
| 1102 ClassElement a = unit.getType('A'); | 1102 ClassElement a = unit.getType('A'); |
| 1103 expect(a.isValidMixin, isFalse); | 1103 expect(a.isValidMixin, isFalse); |
| 1104 await computeAnalysisResult(source); | 1104 await computeAnalysisResult(source); |
| 1105 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 1105 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 1106 verify([source]); | 1106 verify([source]); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 test_isValidMixin_badSuperclass_withSuperMixins() async { | 1109 test_isValidMixin_badSuperclass_withSuperMixins() async { |
| 1110 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | 1110 resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1111 Source source = addSource(r''' | 1111 Source source = addSource(r''' |
| 1112 class A extends B {} | 1112 class A extends B {} |
| 1113 class B {} | 1113 class B {} |
| 1114 class C = Object with A;'''); | 1114 class C = Object with A;'''); |
| 1115 LibraryElement library = resolve2(source); | 1115 LibraryElement library = resolve2(source); |
| 1116 expect(library, isNotNull); | 1116 expect(library, isNotNull); |
| 1117 CompilationUnitElement unit = library.definingCompilationUnit; | 1117 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1118 expect(unit, isNotNull); | 1118 expect(unit, isNotNull); |
| 1119 ClassElement a = unit.getType('A'); | 1119 ClassElement a = unit.getType('A'); |
| 1120 expect(a.isValidMixin, isTrue); | 1120 expect(a.isValidMixin, isTrue); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1134 CompilationUnitElement unit = library.definingCompilationUnit; | 1134 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1135 expect(unit, isNotNull); | 1135 expect(unit, isNotNull); |
| 1136 ClassElement a = unit.getType('A'); | 1136 ClassElement a = unit.getType('A'); |
| 1137 expect(a.isValidMixin, isFalse); | 1137 expect(a.isValidMixin, isFalse); |
| 1138 await computeAnalysisResult(source); | 1138 await computeAnalysisResult(source); |
| 1139 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 1139 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 1140 verify([source]); | 1140 verify([source]); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 test_isValidMixin_constructor_withSuperMixins() async { | 1143 test_isValidMixin_constructor_withSuperMixins() async { |
| 1144 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | 1144 resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1145 Source source = addSource(r''' | 1145 Source source = addSource(r''' |
| 1146 class A { | 1146 class A { |
| 1147 A() {} | 1147 A() {} |
| 1148 } | 1148 } |
| 1149 class C = Object with A;'''); | 1149 class C = Object with A;'''); |
| 1150 LibraryElement library = resolve2(source); | 1150 LibraryElement library = resolve2(source); |
| 1151 expect(library, isNotNull); | 1151 expect(library, isNotNull); |
| 1152 CompilationUnitElement unit = library.definingCompilationUnit; | 1152 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1153 expect(unit, isNotNull); | 1153 expect(unit, isNotNull); |
| 1154 ClassElement a = unit.getType('A'); | 1154 ClassElement a = unit.getType('A'); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1169 CompilationUnitElement unit = library.definingCompilationUnit; | 1169 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1170 expect(unit, isNotNull); | 1170 expect(unit, isNotNull); |
| 1171 ClassElement a = unit.getType('A'); | 1171 ClassElement a = unit.getType('A'); |
| 1172 expect(a.isValidMixin, isTrue); | 1172 expect(a.isValidMixin, isTrue); |
| 1173 await computeAnalysisResult(source); | 1173 await computeAnalysisResult(source); |
| 1174 assertNoErrors(source); | 1174 assertNoErrors(source); |
| 1175 verify([source]); | 1175 verify([source]); |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 test_isValidMixin_factoryConstructor_withSuperMixins() async { | 1178 test_isValidMixin_factoryConstructor_withSuperMixins() async { |
| 1179 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | 1179 resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1180 Source source = addSource(r''' | 1180 Source source = addSource(r''' |
| 1181 class A { | 1181 class A { |
| 1182 factory A() => null; | 1182 factory A() => null; |
| 1183 } | 1183 } |
| 1184 class C = Object with A;'''); | 1184 class C = Object with A;'''); |
| 1185 LibraryElement library = resolve2(source); | 1185 LibraryElement library = resolve2(source); |
| 1186 expect(library, isNotNull); | 1186 expect(library, isNotNull); |
| 1187 CompilationUnitElement unit = library.definingCompilationUnit; | 1187 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1188 expect(unit, isNotNull); | 1188 expect(unit, isNotNull); |
| 1189 ClassElement a = unit.getType('A'); | 1189 ClassElement a = unit.getType('A'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1206 CompilationUnitElement unit = library.definingCompilationUnit; | 1206 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1207 expect(unit, isNotNull); | 1207 expect(unit, isNotNull); |
| 1208 ClassElement a = unit.getType('A'); | 1208 ClassElement a = unit.getType('A'); |
| 1209 expect(a.isValidMixin, isFalse); | 1209 expect(a.isValidMixin, isFalse); |
| 1210 await computeAnalysisResult(source); | 1210 await computeAnalysisResult(source); |
| 1211 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); | 1211 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); |
| 1212 verify([source]); | 1212 verify([source]); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 test_isValidMixin_super_withSuperMixins() async { | 1215 test_isValidMixin_super_withSuperMixins() async { |
| 1216 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | 1216 resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1217 Source source = addSource(r''' | 1217 Source source = addSource(r''' |
| 1218 class A { | 1218 class A { |
| 1219 toString() { | 1219 toString() { |
| 1220 return super.toString(); | 1220 return super.toString(); |
| 1221 } | 1221 } |
| 1222 } | 1222 } |
| 1223 class C = Object with A;'''); | 1223 class C = Object with A;'''); |
| 1224 LibraryElement library = resolve2(source); | 1224 LibraryElement library = resolve2(source); |
| 1225 expect(library, isNotNull); | 1225 expect(library, isNotNull); |
| 1226 CompilationUnitElement unit = library.definingCompilationUnit; | 1226 CompilationUnitElement unit = library.definingCompilationUnit; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1241 CompilationUnitElement unit = library.definingCompilationUnit; | 1241 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1242 expect(unit, isNotNull); | 1242 expect(unit, isNotNull); |
| 1243 ClassElement a = unit.getType('A'); | 1243 ClassElement a = unit.getType('A'); |
| 1244 expect(a.isValidMixin, isTrue); | 1244 expect(a.isValidMixin, isTrue); |
| 1245 await computeAnalysisResult(source); | 1245 await computeAnalysisResult(source); |
| 1246 assertNoErrors(source); | 1246 assertNoErrors(source); |
| 1247 verify([source]); | 1247 verify([source]); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 test_isValidMixin_valid_withSuperMixins() async { | 1250 test_isValidMixin_valid_withSuperMixins() async { |
| 1251 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true); | 1251 resetWith(options: new AnalysisOptionsImpl()..enableSuperMixins = true); |
| 1252 Source source = addSource(''' | 1252 Source source = addSource(''' |
| 1253 class A {} | 1253 class A {} |
| 1254 class C = Object with A;'''); | 1254 class C = Object with A;'''); |
| 1255 LibraryElement library = resolve2(source); | 1255 LibraryElement library = resolve2(source); |
| 1256 expect(library, isNotNull); | 1256 expect(library, isNotNull); |
| 1257 CompilationUnitElement unit = library.definingCompilationUnit; | 1257 CompilationUnitElement unit = library.definingCompilationUnit; |
| 1258 expect(unit, isNotNull); | 1258 expect(unit, isNotNull); |
| 1259 ClassElement a = unit.getType('A'); | 1259 ClassElement a = unit.getType('A'); |
| 1260 expect(a.isValidMixin, isTrue); | 1260 expect(a.isValidMixin, isTrue); |
| 1261 await computeAnalysisResult(source); | 1261 await computeAnalysisResult(source); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 // check propagated type | 1904 // check propagated type |
| 1905 FunctionType propagatedType = node.propagatedType as FunctionType; | 1905 FunctionType propagatedType = node.propagatedType as FunctionType; |
| 1906 expect(propagatedType.returnType, test.typeProvider.stringType); | 1906 expect(propagatedType.returnType, test.typeProvider.stringType); |
| 1907 } on AnalysisException catch (e, stackTrace) { | 1907 } on AnalysisException catch (e, stackTrace) { |
| 1908 thrownException[0] = new CaughtException(e, stackTrace); | 1908 thrownException[0] = new CaughtException(e, stackTrace); |
| 1909 } | 1909 } |
| 1910 } | 1910 } |
| 1911 return null; | 1911 return null; |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| OLD | NEW |