@@ -469,6 +469,19 @@ class B<T> {}
469
469
''' , () => findNode.constructorReference ('B<int>.new' ));
470
470
}
471
471
472
+ test_constructorReference_explicitTypeArguments_nonConst () async {
473
+ await _assertNotConst ('''
474
+ import '' deferred as self;
475
+ class A {
476
+ Object x;
477
+ const A(): x = B<self.A>.new;
478
+ }
479
+
480
+ class B<T> {}
481
+ ''' , () => findNode.constructorReference ('B<self.A>.new' ),
482
+ () => [findNode.typeAnnotation ('self.A' )]);
483
+ }
484
+
472
485
test_constructorReference_noTypeArguments () async {
473
486
await _assertConst ('''
474
487
class A {
@@ -491,6 +504,19 @@ X id<X>(X x) => x;
491
504
''' , () => findNode.functionReference ('id<int>' ));
492
505
}
493
506
507
+ test_functionReference_explicitTypeArguments_nonConst () async {
508
+ await _assertNotConst ('''
509
+ import '' deferred as self;
510
+ class A {
511
+ final int Function(int) x;
512
+ const A(): x = id<self.A>;
513
+ }
514
+
515
+ X id<X>(X x) => x;
516
+ ''' , () => findNode.functionReference ('id<self.A>' ),
517
+ () => [findNode.typeAnnotation ('self.A' )]);
518
+ }
519
+
494
520
test_functionReference_noTypeArguments () async {
495
521
await _assertConst ('''
496
522
class A {
@@ -617,20 +643,39 @@ var x = const [a, b, 2];
617
643
() => [findNode.simple ('a,' ), findNode.simple ('b,' )]);
618
644
}
619
645
646
+ test_listLiteral_ofDynamic () async {
647
+ await _assertConst ('''
648
+ var x = const <dynamic>[];
649
+ ''' , () => _xInitializer ());
650
+ }
651
+
652
+ test_listLiteral_ofNever () async {
653
+ await _assertConst ('''
654
+ var x = const <Never>[];
655
+ ''' , () => _xInitializer ());
656
+ }
657
+
658
+ test_listLiteral_ofVoid () async {
659
+ await _assertConst ('''
660
+ var x = const <void>[];
661
+ ''' , () => _xInitializer ());
662
+ }
663
+
620
664
test_listLiteral_typeArgument () async {
621
665
await _assertConst (r'''
622
666
var x = const <int>[0, 1, 2];
623
667
''' , () => _xInitializer ());
624
668
}
625
669
626
670
test_listLiteral_typeArgument_notConstType () async {
627
- await _assertNotConst (r'''
628
- class A<T> {
671
+ await _assertNotConst ('''
672
+ import '' deferred as self;
673
+ class A {
629
674
m() {
630
- var x = const <T>[0, 1, 2 ];
675
+ var x = const <self.A>[ ];
631
676
}
632
677
}
633
- ''' , () => _xInitializer (), () => [findNode.namedType ('T>[0 ' )]);
678
+ ''' , () => _xInitializer (), () => [findNode.namedType ('A>[ ' )]);
634
679
}
635
680
636
681
test_literal_bool () async {
@@ -1039,13 +1084,14 @@ var x = const <int>{0, 1, 2};
1039
1084
}
1040
1085
1041
1086
test_setLiteral_typeArgument_notConstType () async {
1042
- await _assertNotConst (r'''
1043
- class A<T> {
1087
+ await _assertNotConst ('''
1088
+ import '' deferred as self;
1089
+ class A {
1044
1090
m() {
1045
- var x = const <T>{0, 1, 2 };
1091
+ var x = const <self.A>{ };
1046
1092
}
1047
1093
}
1048
- ''' , () => _xInitializer (), () => [findNode.namedType ('T>{0 ' )]);
1094
+ ''' , () => _xInitializer (), () => [findNode.namedType ('A>{ ' )]);
1049
1095
}
1050
1096
1051
1097
test_simpleIdentifier_class () async {
@@ -1230,6 +1276,17 @@ class A {
1230
1276
''' , () => findNode.typeLiteral ('List<int>' ));
1231
1277
}
1232
1278
1279
+ test_typeLiteral_nonConst () async {
1280
+ await _assertNotConst ('''
1281
+ import '' deferred as self;
1282
+ class A {
1283
+ Type x;
1284
+ const A(): x = List<self.A>;
1285
+ }
1286
+ ''' , () => findNode.typeLiteral ('List<self.A>' ),
1287
+ () => [findNode.typeAnnotation ('self.A' )]);
1288
+ }
1289
+
1233
1290
_assertConst (String code, AstNode Function () getNode) async {
1234
1291
await resolveTestCode (code);
1235
1292
var node = getNode ();
0 commit comments