File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed
Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -153,9 +153,13 @@ $stackTrace''');
153153 var namedParameters = const < String , DecoratedType > {};
154154 if (type is InterfaceType && type.typeParameters.isNotEmpty) {
155155 if (node is TypeName ) {
156- assert (node.typeArguments != null );
157- typeArguments =
158- node.typeArguments.arguments.map ((t) => t.accept (this )).toList ();
156+ if (node.typeArguments == null ) {
157+ typeArguments =
158+ type.typeArguments.map (_decorateImplicitTypeArgument).toList ();
159+ } else {
160+ typeArguments =
161+ node.typeArguments.arguments.map ((t) => t.accept (this )).toList ();
162+ }
159163 } else {
160164 assert (false ); // TODO(paulberry): is this possible?
161165 }
@@ -227,6 +231,16 @@ $stackTrace''');
227231 return _NullabilityComment .none;
228232 }
229233
234+ /// Creates a DecoratedType corresponding to [type] , with fresh nullability
235+ /// nodes everywhere that don't correspond to any source location. These
236+ /// nodes can later be unioned with other nodes.
237+ DecoratedType _decorateImplicitTypeArgument (DartType type) {
238+ if (type.isDynamic) {
239+ return DecoratedType (type, _graph.always);
240+ }
241+ throw UnimplementedError ('TODO(paulberry): ${type .runtimeType }' );
242+ }
243+
230244 /// Common handling of function and method declarations.
231245 void _handleExecutableDeclaration (
232246 ExecutableElement declaredElement,
Original file line number Diff line number Diff line change @@ -645,6 +645,18 @@ int f(int i) {
645645 await _checkSingleFileChanges (content, expected);
646646 }
647647
648+ test_genericType_noTypeArguments () async {
649+ var content = '''
650+ void f(C c) {}
651+ class C<E> {}
652+ ''' ;
653+ var expected = '''
654+ void f(C c) {}
655+ class C<E> {}
656+ ''' ;
657+ await _checkSingleFileChanges (content, expected);
658+ }
659+
648660 test_getter_topLevel () async {
649661 var content = '''
650662int get g => 0;
Original file line number Diff line number Diff line change @@ -1339,6 +1339,19 @@ void f(void Function(int) x) {}
13391339 expect (decoratedIntType.node, isNot (never));
13401340 }
13411341
1342+ test_interfaceType_generic_instantiate_to_dynamic () async {
1343+ await analyze ('''
1344+ void f(List x) {}
1345+ ''' );
1346+ var decoratedListType = decoratedTypeAnnotation ('List' );
1347+ expect (decoratedFunctionType ('f' ).positionalParameters[0 ],
1348+ same (decoratedListType));
1349+ expect (decoratedListType.node, isNotNull);
1350+ expect (decoratedListType.node, isNot (never));
1351+ var decoratedArgType = decoratedListType.typeArguments[0 ];
1352+ expect (decoratedArgType.node, same (always));
1353+ }
1354+
13421355 test_interfaceType_typeParameter () async {
13431356 await analyze ('''
13441357void f(List<int> x) {}
You can’t perform that action at this time.
0 commit comments