@@ -22,26 +22,28 @@ import 'migration_visitor_test_base.dart';
2222
2323main () {
2424 defineReflectiveSuite (() {
25- defineReflectiveTests (_AlreadyMigratedCodeDecoratorTest );
25+ defineReflectiveTests (_AlreadyMigratedCodeDecoratorTestNormal );
26+ defineReflectiveTests (_AlreadyMigratedCodeDecoratorTestProvisional );
2627 });
2728}
2829
29- @reflectiveTest
30- class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
30+ class _AlreadyMigratedCodeDecoratorTestBase extends Object with EdgeTester {
3131 final TypeProvider typeProvider;
3232
3333 final AlreadyMigratedCodeDecorator decorator;
3434
3535 final NullabilityGraphForTesting graph;
3636
37+ final NullabilitySuffix suffix;
38+
3739 Element element = _MockElement ();
3840
39- factory _AlreadyMigratedCodeDecoratorTest () {
40- return _AlreadyMigratedCodeDecoratorTest ._(
41- NullabilityGraphForTesting (), TestTypeProvider ());
42- }
41+ _AlreadyMigratedCodeDecoratorTestBase (NullabilitySuffix nullabilitySuffix)
42+ : this ._(nullabilitySuffix, NullabilityGraphForTesting (),
43+ TestTypeProvider (nullabilitySuffix: nullabilitySuffix));
4344
44- _AlreadyMigratedCodeDecoratorTest ._(this .graph, this .typeProvider)
45+ _AlreadyMigratedCodeDecoratorTestBase ._(
46+ this .suffix, this .graph, this .typeProvider)
4547 : decorator = AlreadyMigratedCodeDecorator (graph, typeProvider);
4648
4749 NullabilityNode get always => graph.always;
@@ -140,7 +142,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
140142 ..bound = typeProvider.numType;
141143 var decoratedType = decorate (FunctionTypeImpl .synthetic (
142144 TypeParameterTypeImpl (typeFormal), [typeFormal], [],
143- nullabilitySuffix: NullabilitySuffix .star ));
145+ nullabilitySuffix: suffix ));
144146 expect (decoratedType.typeFormalBounds, hasLength (1 ));
145147 checkNum (decoratedType.typeFormalBounds[0 ], checkExplicitlyNonNullable);
146148 checkTypeParameter (
@@ -151,7 +153,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
151153 var typeFormal = TypeParameterElementImpl .synthetic ('T' );
152154 var decoratedType = decorate (FunctionTypeImpl .synthetic (
153155 TypeParameterTypeImpl (typeFormal), [typeFormal], [],
154- nullabilitySuffix: NullabilitySuffix .star ));
156+ nullabilitySuffix: suffix ));
155157 expect (decoratedType.typeFormalBounds, hasLength (1 ));
156158 checkObject (decoratedType.typeFormalBounds[0 ], checkExplicitlyNullable);
157159 checkTypeParameter (
@@ -166,7 +168,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
166168 ParameterElementImpl .synthetic (
167169 'x' , typeProvider.dynamicType, ParameterKind .NAMED )
168170 ],
169- nullabilitySuffix: NullabilitySuffix .star ))
171+ nullabilitySuffix: suffix ))
170172 .namedParameters['x' ]);
171173 }
172174
@@ -178,7 +180,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
178180 ParameterElementImpl .synthetic (
179181 'x' , typeProvider.dynamicType, ParameterKind .REQUIRED )
180182 ],
181- nullabilitySuffix: NullabilitySuffix .star ))
183+ nullabilitySuffix: suffix ))
182184 .positionalParameters[0 ]);
183185 }
184186
@@ -190,7 +192,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
190192 ParameterElementImpl .synthetic (
191193 'x' , typeProvider.dynamicType, ParameterKind .POSITIONAL )
192194 ],
193- nullabilitySuffix: NullabilitySuffix .star ))
195+ nullabilitySuffix: suffix ))
194196 .positionalParameters[0 ]);
195197 }
196198
@@ -204,14 +206,14 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
204206 test_decorate_functionType_returnType () {
205207 checkDynamic (decorate (FunctionTypeImpl .synthetic (
206208 typeProvider.dynamicType, [], [],
207- nullabilitySuffix: NullabilitySuffix .star ))
209+ nullabilitySuffix: suffix ))
208210 .returnType);
209211 }
210212
211213 test_decorate_functionType_star () {
212214 checkExplicitlyNonNullable (decorate (FunctionTypeImpl .synthetic (
213215 typeProvider.voidType, [], [],
214- nullabilitySuffix: NullabilitySuffix .star ))
216+ nullabilitySuffix: suffix ))
215217 .node);
216218 }
217219
@@ -225,7 +227,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
225227 test_decorate_interfaceType_simple_star () {
226228 checkInt (
227229 decorate (InterfaceTypeImpl (typeProvider.intType.element,
228- nullabilitySuffix: NullabilitySuffix .star )),
230+ nullabilitySuffix: suffix )),
229231 checkExplicitlyNonNullable);
230232 }
231233
@@ -246,8 +248,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
246248 test_decorate_typeParameterType_star () {
247249 var element = TypeParameterElementImpl .synthetic ('T' );
248250 checkTypeParameter (
249- decorate (TypeParameterTypeImpl (element,
250- nullabilitySuffix: NullabilitySuffix .star)),
251+ decorate (TypeParameterTypeImpl (element, nullabilitySuffix: suffix)),
251252 checkExplicitlyNonNullable,
252253 element);
253254 }
@@ -275,7 +276,7 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
275276 name: 'C' ,
276277 typeParameters: [t],
277278 supertype: typeProvider.iterableType2 (
278- t.instantiate (nullabilitySuffix: NullabilitySuffix .star ),
279+ t.instantiate (nullabilitySuffix: suffix ),
279280 ),
280281 );
281282 var decoratedSupertypes = decorator.getImmediateSupertypes (class_).toList ();
@@ -321,6 +322,30 @@ class _AlreadyMigratedCodeDecoratorTest extends Object with EdgeTester {
321322 }
322323}
323324
325+ /// Specialization of [_AlreadyMigratedCodeDecoratorTestBase] for testing the
326+ /// situation where the already migrated code does not contain star types. In
327+ /// the final product, by definition all already-migrated code will be free of
328+ /// star types. However, since we do not yet migrate using a fully NNBD-aware
329+ /// SDK, we need to handle both star and non-star variants on a short term
330+ /// basis.
331+ @reflectiveTest
332+ class _AlreadyMigratedCodeDecoratorTestNormal
333+ extends _AlreadyMigratedCodeDecoratorTestBase {
334+ _AlreadyMigratedCodeDecoratorTestNormal () : super (NullabilitySuffix .none);
335+ }
336+
337+ /// Specialization of [_AlreadyMigratedCodeDecoratorTestBase] for testing the
338+ /// situation where the already migrated code contains star types. In the final
339+ /// product, this will never happen. However, since we do not yet migrate using
340+ /// a fully NNBD-aware SDK, we need to handle both star and non-star variants on
341+ /// a short term basis.
342+ @reflectiveTest
343+ class _AlreadyMigratedCodeDecoratorTestProvisional
344+ extends _AlreadyMigratedCodeDecoratorTestBase {
345+ _AlreadyMigratedCodeDecoratorTestProvisional ()
346+ : super (NullabilitySuffix .star);
347+ }
348+
324349class _MockElement implements Element {
325350 noSuchMethod (Invocation invocation) => super .noSuchMethod (invocation);
326351}
0 commit comments