OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
(...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 expect(executable.isRedirectedConstructor, isTrue); | 3180 expect(executable.isRedirectedConstructor, isTrue); |
3181 expect(executable.isFactory, isTrue); | 3181 expect(executable.isFactory, isTrue); |
3182 expect(executable.redirectedConstructorName, isEmpty); | 3182 expect(executable.redirectedConstructorName, isEmpty); |
3183 checkTypeRef(executable.redirectedConstructor, null, null, 'named', | 3183 checkTypeRef(executable.redirectedConstructor, null, null, 'named', |
3184 expectedKind: ReferenceKind.constructor, | 3184 expectedKind: ReferenceKind.constructor, |
3185 prefixExpectations: [ | 3185 prefixExpectations: [ |
3186 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D') | 3186 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D') |
3187 ]); | 3187 ]); |
3188 } | 3188 } |
3189 | 3189 |
| 3190 test_constructor_redirected_factory_named_generic() { |
| 3191 String text = ''' |
| 3192 class C<T, U> { |
| 3193 factory C() = D<U, T>.named; |
| 3194 C._(); |
| 3195 } |
| 3196 class D<T, U> extends C<U, T> { |
| 3197 D.named() : super._(); |
| 3198 } |
| 3199 '''; |
| 3200 UnlinkedExecutable executable = |
| 3201 serializeClassText(text, className: 'C').executables[0]; |
| 3202 expect(executable.isRedirectedConstructor, isTrue); |
| 3203 expect(executable.isFactory, isTrue); |
| 3204 expect(executable.redirectedConstructorName, isEmpty); |
| 3205 checkTypeRef(executable.redirectedConstructor, null, null, 'named', |
| 3206 expectedKind: ReferenceKind.constructor, |
| 3207 prefixExpectations: [ |
| 3208 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D', |
| 3209 numTypeParameters: 2) |
| 3210 ], |
| 3211 allowTypeParameters: true); |
| 3212 } |
| 3213 |
3190 test_constructor_redirected_factory_unnamed() { | 3214 test_constructor_redirected_factory_unnamed() { |
3191 String text = ''' | 3215 String text = ''' |
3192 class C { | 3216 class C { |
3193 factory C() = D; | 3217 factory C() = D; |
3194 C._(); | 3218 C._(); |
3195 } | 3219 } |
3196 class D extends C { | 3220 class D extends C { |
3197 D() : super._(); | 3221 D() : super._(); |
3198 } | 3222 } |
3199 '''; | 3223 '''; |
3200 UnlinkedExecutable executable = | 3224 UnlinkedExecutable executable = |
3201 serializeClassText(text, className: 'C').executables[0]; | 3225 serializeClassText(text, className: 'C').executables[0]; |
3202 expect(executable.isRedirectedConstructor, isTrue); | 3226 expect(executable.isRedirectedConstructor, isTrue); |
3203 expect(executable.isFactory, isTrue); | 3227 expect(executable.isFactory, isTrue); |
3204 expect(executable.redirectedConstructorName, isEmpty); | 3228 expect(executable.redirectedConstructorName, isEmpty); |
3205 checkTypeRef(executable.redirectedConstructor, null, null, 'D'); | 3229 checkTypeRef(executable.redirectedConstructor, null, null, 'D'); |
3206 } | 3230 } |
3207 | 3231 |
| 3232 test_constructor_redirected_factory_unnamed_generic() { |
| 3233 String text = ''' |
| 3234 class C<T, U> { |
| 3235 factory C() = D<U, T>; |
| 3236 C._(); |
| 3237 } |
| 3238 class D<T, U> extends C<U, T> { |
| 3239 D() : super._(); |
| 3240 } |
| 3241 '''; |
| 3242 UnlinkedExecutable executable = |
| 3243 serializeClassText(text, className: 'C').executables[0]; |
| 3244 expect(executable.isRedirectedConstructor, isTrue); |
| 3245 expect(executable.isFactory, isTrue); |
| 3246 expect(executable.redirectedConstructorName, isEmpty); |
| 3247 checkTypeRef(executable.redirectedConstructor, null, null, 'D', |
| 3248 allowTypeParameters: true, numTypeParameters: 2); |
| 3249 } |
| 3250 |
3208 test_constructor_redirected_thisInvocation_named() { | 3251 test_constructor_redirected_thisInvocation_named() { |
3209 String text = ''' | 3252 String text = ''' |
3210 class C { | 3253 class C { |
3211 C() : this.named(); | 3254 C() : this.named(); |
3212 C.named(); | 3255 C.named(); |
3213 } | 3256 } |
3214 '''; | 3257 '''; |
3215 UnlinkedExecutable executable = | 3258 UnlinkedExecutable executable = |
3216 serializeClassText(text, className: 'C').executables[0]; | 3259 serializeClassText(text, className: 'C').executables[0]; |
3217 expect(executable.isRedirectedConstructor, isTrue); | 3260 expect(executable.isRedirectedConstructor, isTrue); |
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6078 final String absoluteUri; | 6121 final String absoluteUri; |
6079 final String relativeUri; | 6122 final String relativeUri; |
6080 final int numTypeParameters; | 6123 final int numTypeParameters; |
6081 | 6124 |
6082 _PrefixExpectation(this.kind, this.name, | 6125 _PrefixExpectation(this.kind, this.name, |
6083 {this.inLibraryDefiningUnit: false, | 6126 {this.inLibraryDefiningUnit: false, |
6084 this.absoluteUri, | 6127 this.absoluteUri, |
6085 this.relativeUri, | 6128 this.relativeUri, |
6086 this.numTypeParameters: 0}); | 6129 this.numTypeParameters: 0}); |
6087 } | 6130 } |
OLD | NEW |