@@ -49,34 +49,40 @@ class C {
49
49
assertInContext ("C(0" , true );
50
50
}
51
51
52
- test_inConstantContext_instanceCreation_functionLiteral () {
52
+ test_inConstantContext_instanceCreation_fieldWithConstConstructor () {
53
53
parse ('''
54
- const V = () => C();
55
54
class C {
55
+ final d = D();
56
56
const C();
57
57
}
58
+ class D {
59
+ const D();
60
+ }
58
61
''' );
59
- assertInContext ("C ()" , false );
62
+ assertInContext ("D ()" , false );
60
63
}
61
64
62
- test_inConstantContext_instanceCreation_initializer_false () {
65
+ test_inConstantContext_instanceCreation_fieldWithoutConstConstructor () {
63
66
parse ('''
64
- var c = C();
65
67
class C {
66
- const C();
68
+ final d = D();
69
+ C();
70
+ }
71
+ class D {
72
+ const D();
67
73
}
68
74
''' );
69
- assertInContext ("C ()" , false );
75
+ assertInContext ("D ()" , false );
70
76
}
71
77
72
- test_inConstantContext_instanceCreation_initializer_true () {
78
+ test_inConstantContext_instanceCreation_functionLiteral () {
73
79
parse ('''
74
- const c = C();
80
+ const V = () => C();
75
81
class C {
76
82
const C();
77
83
}
78
84
''' );
79
- assertInContext ("C()" , true );
85
+ assertInContext ("C()" , false );
80
86
}
81
87
82
88
test_inConstantContext_instanceCreation_instanceCreation_false () {
@@ -216,6 +222,26 @@ class C {
216
222
assertInContext ("C()" , true );
217
223
}
218
224
225
+ test_inConstantContext_instanceCreation_topLevelVariable_false () {
226
+ parse ('''
227
+ var c = C();
228
+ class C {
229
+ const C();
230
+ }
231
+ ''' );
232
+ assertInContext ("C()" , false );
233
+ }
234
+
235
+ test_inConstantContext_instanceCreation_topLevelVariable_true () {
236
+ parse ('''
237
+ const c = C();
238
+ class C {
239
+ const C();
240
+ }
241
+ ''' );
242
+ assertInContext ("C()" , true );
243
+ }
244
+
219
245
test_inConstantContext_listLiteral_annotation_true () {
220
246
parse ('''
221
247
@C([])
@@ -475,7 +501,7 @@ class C {
475
501
const C.c();
476
502
}
477
503
''' );
478
- assertIsConst ("C(C" , true );
504
+ assertIsConst ("C(C" , false );
479
505
}
480
506
481
507
void test_isConst_notInContext_constructor_const_constParam_named () async {
@@ -486,7 +512,7 @@ class C {
486
512
const C({c});
487
513
}
488
514
''' );
489
- assertIsConst ("C(c" , true );
515
+ assertIsConst ("C(c" , false );
490
516
}
491
517
492
518
void
@@ -498,7 +524,7 @@ class C {
498
524
const C({c});
499
525
}
500
526
''' );
501
- assertIsConst ("C(c" , true );
527
+ assertIsConst ("C(c" , false );
502
528
}
503
529
504
530
void test_isConst_notInContext_constructor_const_constParam_parens () async {
@@ -510,7 +536,7 @@ class C {
510
536
const C.c();
511
537
}
512
538
''' );
513
- assertIsConst ("C( (" , true );
539
+ assertIsConst ("C( (" , false );
514
540
}
515
541
516
542
void test_isConst_notInContext_constructor_const_generic_named () async {
@@ -521,7 +547,7 @@ class C<E> {
521
547
const C.n();
522
548
}
523
549
''' );
524
- assertIsConst ("C<int>.n" , true );
550
+ assertIsConst ("C<int>.n" , false );
525
551
}
526
552
527
553
void
@@ -536,7 +562,7 @@ class C<E> {
536
562
import 'c.dart' as p;
537
563
f() => <Object>[p.C<int>.n()];
538
564
''' );
539
- assertIsConst ("C<int>" , true );
565
+ assertIsConst ("C<int>" , false );
540
566
}
541
567
542
568
void test_isConst_notInContext_constructor_const_generic_unnamed () async {
@@ -547,7 +573,7 @@ class C<E> {
547
573
const C();
548
574
}
549
575
''' );
550
- assertIsConst ("C<int>" , true );
576
+ assertIsConst ("C<int>" , false );
551
577
}
552
578
553
579
void
@@ -562,7 +588,7 @@ class C<E> {
562
588
import 'c.dart' as p;
563
589
f() => <Object>[p.C<int>()];
564
590
''' );
565
- assertIsConst ("C<int>" , true );
591
+ assertIsConst ("C<int>" , false );
566
592
}
567
593
568
594
void
@@ -605,7 +631,7 @@ class C<E> {
605
631
const C.n();
606
632
}
607
633
''' );
608
- assertIsConst ("C.n()" , true );
634
+ assertIsConst ("C.n()" , false );
609
635
}
610
636
611
637
void
@@ -620,7 +646,7 @@ class C {
620
646
import 'c.dart' as p;
621
647
f() => <Object>[p.C.n()];
622
648
''' );
623
- assertIsConst ("C.n()" , true );
649
+ assertIsConst ("C.n()" , false );
624
650
}
625
651
626
652
void test_isConst_notInContext_constructor_const_nonGeneric_unnamed () async {
@@ -631,7 +657,7 @@ class C {
631
657
const C();
632
658
}
633
659
''' );
634
- assertIsConst ("C()" , true );
660
+ assertIsConst ("C()" , false );
635
661
}
636
662
637
663
void
@@ -646,7 +672,7 @@ class C {
646
672
import 'c.dart' as p;
647
673
f() => <Object>[p.C()];
648
674
''' );
649
- assertIsConst ("C()" , true );
675
+ assertIsConst ("C()" , false );
650
676
}
651
677
652
678
void test_isConst_notInContext_constructor_nonConst () async {
0 commit comments