Disallow UI-as-code in constants if constant-update-2018 is disabled.

Analyzer unit tests exercising the behavior of UI-as-code had to be
replicated so that we could test the behavior both with and without
constant-update-2018.

Note that as of the writing of this CL, constant-update-2018 has been
enabled by default, so there is no immediate functional change.  The
change will take effect if we decide to back out constant-update-2018.

Change-Id: Iff50f4cb834805bec14638220671384c97dea39d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99443
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index f3c1805..97fac61 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -43,6 +43,8 @@
   /// The current library that is being analyzed.
   final LibraryElement _currentLibrary;
 
+  final bool _constantUpdate2018Enabled;
+
   ConstantEvaluationEngine _evaluationEngine;
 
   /// Initialize a newly created constant verifier.
@@ -52,7 +54,11 @@
       this._typeProvider, this.declaredVariables,
       {bool forAnalysisDriver: false})
       : _currentLibrary = currentLibrary,
-        _typeSystem = currentLibrary.context.typeSystem {
+        _typeSystem = currentLibrary.context.typeSystem,
+        _constantUpdate2018Enabled =
+            (currentLibrary.context.analysisOptions as AnalysisOptionsImpl)
+                .experimentStatus
+                .constant_update_2018 {
     this._intType = _typeProvider.intType;
     this._evaluationEngine = new ConstantEvaluationEngine(
         _typeProvider, declaredVariables,
@@ -613,6 +619,10 @@
       verifier._errorReporter.reportErrorForNode(errorCode, element);
       return false;
     } else if (element is IfElement) {
+      if (!verifier._constantUpdate2018Enabled) {
+        verifier._errorReporter.reportErrorForNode(errorCode, element);
+        return false;
+      }
       var conditionValue = verifier._validate(element.condition, errorCode);
       var conditionBool = conditionValue?.toBoolValue();
 
@@ -642,6 +652,10 @@
     } else if (element is MapLiteralEntry) {
       return _validateMapLiteralEntry(element);
     } else if (element is SpreadElement) {
+      if (!verifier._constantUpdate2018Enabled) {
+        verifier._errorReporter.reportErrorForNode(errorCode, element);
+        return false;
+      }
       var value = verifier._validate(element.expression, errorCode);
       if (value == null) return false;
 
diff --git a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
index 89ff607..ba1168f 100644
--- a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
@@ -14,6 +14,7 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(ConstEvalThrowsExceptionTest);
     defineReflectiveTests(ConstEvalThrowsExceptionWithConstantUpdateTest);
+    defineReflectiveTests(ConstEvalThrowsExceptionWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(ConstEvalThrowsExceptionWithUIAsCodeTest);
   });
 }
@@ -152,6 +153,18 @@
 }
 
 @reflectiveTest
+class ConstEvalThrowsExceptionWithUiAsCodeAndConstantsTest
+    extends ConstEvalThrowsExceptionWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class ConstEvalThrowsExceptionWithUIAsCodeTest
     extends ConstEvalThrowsExceptionTest {
   @override
@@ -162,37 +175,66 @@
     ];
 
   test_ifElement_false_thenNotEvaluated() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic nil = null;
 const c = [if (1 < 0) nil + 1];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_ifElement_nonBoolCondition_list() async {
-    assertErrorCodesInCode('''
+    assertErrorCodesInCode(
+        '''
 const dynamic nonBool = 3;
 const c = const [if (nonBool) 'a'];
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]
+            : [
+                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+                CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT
+              ]);
   }
 
   test_ifElement_nonBoolCondition_map() async {
-    assertErrorCodesInCode('''
+    assertErrorCodesInCode(
+        '''
 const dynamic nonBool = null;
 const c = const {if (nonBool) 'a' : 1};
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]
+            : [
+                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_ifElement_nonBoolCondition_set() async {
-    assertErrorCodesInCode('''
+    assertErrorCodesInCode(
+        '''
 const dynamic nonBool = 'a';
 const c = const {if (nonBool) 3};
-''', [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]
+            : [
+                CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+                CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT
+              ]);
   }
 
   test_ifElement_true_elseNotEvaluated() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic nil = null;
 const c = [if (0 < 1) 3 else nil + 1];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/const_set_element_type_implements_equals_test.dart b/pkg/analyzer/test/src/diagnostics/const_set_element_type_implements_equals_test.dart
index a11a43a..ded7bfb 100644
--- a/pkg/analyzer/test/src/diagnostics/const_set_element_type_implements_equals_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_set_element_type_implements_equals_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -12,6 +13,8 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(ConstSetElementTypeImplementsEqualsTest);
     defineReflectiveTests(
+        ConstSetElementTypeImplementsEqualsWithUIAsCodeAndConstantsTest);
+    defineReflectiveTests(
       ConstSetElementTypeImplementsEqualsWithUIAsCodeTest,
     );
   });
@@ -95,14 +98,30 @@
 }
 
 @reflectiveTest
+class ConstSetElementTypeImplementsEqualsWithUIAsCodeAndConstantsTest
+    extends ConstSetElementTypeImplementsEqualsWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class ConstSetElementTypeImplementsEqualsWithUIAsCodeTest
     extends ConstSetElementTypeImplementsEqualsTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_spread_list() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 class A {
   const A();
   operator ==(other) => false;
@@ -111,11 +130,15 @@
 main() {
   const {...[A()]};
 }
-''', [CompileTimeErrorCode.CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_spread_set() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 class A {
   const A();
   operator ==(other) => false;
@@ -124,6 +147,12 @@
 main() {
   const {...{A()}};
 }
-''', [CompileTimeErrorCode.CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS]
+            : [
+                CompileTimeErrorCode.CONST_SET_ELEMENT_TYPE_IMPLEMENTS_EQUALS,
+                CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT
+              ]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/const_spread_expected_list_or_set_test.dart b/pkg/analyzer/test/src/diagnostics/const_spread_expected_list_or_set_test.dart
index fd10f5d..5863409 100644
--- a/pkg/analyzer/test/src/diagnostics/const_spread_expected_list_or_set_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_spread_expected_list_or_set_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ConstSpreadExpectedListOrSetTest);
+    defineReflectiveTests(ConstSpreadExpectedListOrSetWithConstantsTest);
   });
 }
 
@@ -18,90 +20,141 @@
 class ConstSpreadExpectedListOrSetTest extends DriverResolutionTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_listInt() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 5;
 var b = const <int>[...a];
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_listList() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = [5];
 var b = const <int>[...a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_listMap() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int, int>{0: 1};
 var b = const <int>[...a];
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_listNull() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = null;
 var b = const <int>[...a];
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_listNull_nullable() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = null;
 var b = const <int>[...?a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_listSet() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int>{5};
 var b = const <int>[...a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_setInt() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 5;
 var b = const <int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_setList() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int>[5];
 var b = const <int>{...a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_setMap() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int, int>{1: 2};
 var b = const <int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_setNull() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = null;
 var b = const <int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_setNull_nullable() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = null;
 var b = const <int>{...?a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_setSet() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int>{5};
 var b = const <int>{...a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_nonConst_listInt() async {
@@ -118,3 +171,15 @@
 ''');
   }
 }
+
+@reflectiveTest
+class ConstSpreadExpectedListOrSetWithConstantsTest
+    extends ConstSpreadExpectedListOrSetTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
diff --git a/pkg/analyzer/test/src/diagnostics/const_spread_expected_map_test.dart b/pkg/analyzer/test/src/diagnostics/const_spread_expected_map_test.dart
index 3344ab1..93d86bb 100644
--- a/pkg/analyzer/test/src/diagnostics/const_spread_expected_map_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_spread_expected_map_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ConstSpreadExpectedMapTest);
+    defineReflectiveTests(ConstSpreadExpectedMapWithConstantsTest);
   });
 }
 
@@ -18,20 +20,31 @@
 class ConstSpreadExpectedMapTest extends DriverResolutionTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_mapInt() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 5;
 var b = const <int, int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_mapList() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int>[5];
 var b = const <int, int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_mapMap() async {
@@ -42,10 +55,14 @@
   }
 
   test_const_mapNull() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = null;
 var b = const <int, int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_mapNull_nullable() async {
@@ -56,10 +73,14 @@
   }
 
   test_const_mapSet() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = <int>{5};
 var b = const <int, int>{...a};
-''', [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_nonConst_mapInt() async {
@@ -76,3 +97,15 @@
 ''');
   }
 }
+
+@reflectiveTest
+class ConstSpreadExpectedMapWithConstantsTest
+    extends ConstSpreadExpectedMapTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
diff --git a/pkg/analyzer/test/src/diagnostics/equal_elements_in_const_set_test.dart b/pkg/analyzer/test/src/diagnostics/equal_elements_in_const_set_test.dart
index 94723ea..91c8202f 100644
--- a/pkg/analyzer/test/src/diagnostics/equal_elements_in_const_set_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/equal_elements_in_const_set_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(EqualElementsInConstSetTest);
+    defineReflectiveTests(EqualElementsInConstSetWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(EqualElementsInConstSetWithUIAsCodeTest);
   });
 }
@@ -53,6 +54,18 @@
 }
 
 @reflectiveTest
+class EqualElementsInConstSetWithUIAsCodeAndConstantsTest
+    extends EqualElementsInConstSetWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class EqualElementsInConstSetWithUIAsCodeTest
     extends EqualElementsInConstSetTest {
   @override
@@ -63,50 +76,82 @@
     ];
 
   test_const_ifElement_thenElseFalse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1, if (1 < 0) 2 else 1};
-''', [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_onlyElse() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {if (0 < 1) 1 else 1};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {1, if (0 < 1) 2 else 1};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_onlyThen() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {if (0 < 1) 1 else 1};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {2, if (1 < 0) 2};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1, if (0 < 1) 1};
-''', [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_spread__noDuplicate() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1, ...{2}};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_spread_hasDuplicate() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1, ...{1}};
-''', [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_ELEMENTS_IN_CONST_SET]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/equal_keys_in_const_map_test.dart b/pkg/analyzer/test/src/diagnostics/equal_keys_in_const_map_test.dart
index 002bb31..c4ff97b 100644
--- a/pkg/analyzer/test/src/diagnostics/equal_keys_in_const_map_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/equal_keys_in_const_map_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(EqualKeysInConstMapTest);
+    defineReflectiveTests(EqualKeysInConstMapWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(EqualKeysInConstMapWithUIAsCodeTest);
   });
 }
@@ -53,6 +54,18 @@
 }
 
 @reflectiveTest
+class EqualKeysInConstMapWithUIAsCodeAndConstantsTest
+    extends EqualKeysInConstMapWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class EqualKeysInConstMapWithUIAsCodeTest extends EqualKeysInConstMapTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -62,50 +75,82 @@
     ];
 
   test_const_ifElement_thenElseFalse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1: null, if (1 < 0) 2: null else 1: null};
-''', [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_onlyElse() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {if (0 < 1) 1: null else 1: null};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {1: null, if (0 < 1) 2: null else 1: null};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_onlyThen() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {if (0 < 1) 1: null else 1: null};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse() async {
-    assertNoErrorsInCode('''
+    assertErrorCodesInCode(
+        '''
 var c = const {2: null, if (1 < 0) 2: 2};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1: null, if (0 < 1) 1: null};
-''', [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread__noDuplicate() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1: null, ...{2: null}};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread_hasDuplicate() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var c = const {1: null, ...{1: null}};
-''', [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.EQUAL_KEYS_IN_CONST_MAP]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/list_element_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/list_element_type_not_assignable_test.dart
index 5c5e180..65a09dc 100644
--- a/pkg/analyzer/test/src/diagnostics/list_element_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/list_element_type_not_assignable_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,8 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ListElementTypeNotAssignableTest);
+    defineReflectiveTests(
+        ListElementTypeNotAssignableWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(ListElementTypeNotAssignableWithUIAsCodeTest);
   });
 }
@@ -70,59 +73,105 @@
 }
 
 @reflectiveTest
+class ListElementTypeNotAssignableWithUIAsCodeAndConstantsTest
+    extends ListElementTypeNotAssignableWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class ListElementTypeNotAssignableWithUIAsCodeTest
     extends ListElementTypeNotAssignableTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_ifElement_thenElseFalse_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 0;
 var v = const <int>[if (1 < 0) a else b];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 'b';
 var v = const <int>[if (1 < 0) a else b];
-''', [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int>[if (1 < 0) 'a'];
-''', [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT
+              ]);
   }
 
   test_const_ifElement_thenFalse_intString_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int>[if (1 < 0) a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int>[if (true) a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int>[if (true) a];
-''', [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_spread_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int>[...[0, 1]];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_nonConst_ifElement_thenElseFalse_intDynamic() async {
diff --git a/pkg/analyzer/test/src/diagnostics/map_key_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/map_key_type_not_assignable_test.dart
index afe320c..e629629 100644
--- a/pkg/analyzer/test/src/diagnostics/map_key_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/map_key_type_not_assignable_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(MapKeyTypeNotAssignableTest);
+    defineReflectiveTests(MapKeyTypeNotAssignableWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(MapKeyTypeNotAssignableWithUIAsCodeTest);
   });
 }
@@ -59,73 +61,130 @@
 }
 
 @reflectiveTest
+class MapKeyTypeNotAssignableWithUIAsCodeAndConstantsTest
+    extends MapKeyTypeNotAssignableWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class MapKeyTypeNotAssignableWithUIAsCodeTest
     extends MapKeyTypeNotAssignableTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_ifElement_thenElseFalse_intInt_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 0;
 var v = const <int, bool>{if (1 < 0) a: true else b: false};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 'b';
 var v = const <int, bool>{if (1 < 0) a: true else b: false};
-''', [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int, bool>{if (1 < 0) a: true};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString_value() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int, bool>{if (1 < 0) 'a': true};
-''', [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_const_ifElement_thenTrue_intInt_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int, bool>{if (true) a: true};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int, bool>{if (true) a: true};
-''', [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_notConst() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final a = 0;
 var v = const <int, bool>{if (1 < 2) a: true};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int, String>{...{1: 'a'}};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int, String>{...{a: 'a'}};
-''', [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_nonConst_ifElement_thenElseFalse_intInt_dynamic() async {
diff --git a/pkg/analyzer/test/src/diagnostics/map_value_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/map_value_type_not_assignable_test.dart
index f0d2c32..c5e15e3 100644
--- a/pkg/analyzer/test/src/diagnostics/map_value_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/map_value_type_not_assignable_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,8 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(MapValueTypeNotAssignableTest);
+    defineReflectiveTests(
+        MapValueTypeNotAssignableWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(MapValueTypeNotAssignableWithUIAsCodeTest);
   });
 }
@@ -59,73 +62,129 @@
 }
 
 @reflectiveTest
+class MapValueTypeNotAssignableWithUIAsCodeAndConstantsTest
+    extends MapValueTypeNotAssignableWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
+}
+
+@reflectiveTest
 class MapValueTypeNotAssignableWithUIAsCodeTest
     extends MapValueTypeNotAssignableTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_ifElement_thenElseFalse_intInt_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 0;
 var v = const <bool, int>{if (1 < 0) true: a else false: b};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 'b';
 var v = const <bool, int>{if (1 < 0) true: a else false: b};
-''', [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <bool, int>{if (1 < 0) true: a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString_value() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <bool, int>{if (1 < 0) true: 'a'};
-''', [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_const_ifElement_thenTrue_intInt_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <bool, int>{if (true) true: a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <bool, int>{if (true) true: a};
-''', [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_notConst() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final a = 0;
 var v = const <bool, int>{if (1 < 2) true: a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <bool, int>{...{true: 1}};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_spread_intString_dynamic() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <bool, int>{...{true: a}};
-''', [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_nonConst_ifElement_thenElseFalse_intInt_dynamic() async {
diff --git a/pkg/analyzer/test/src/diagnostics/non_bool_condition_test.dart b/pkg/analyzer/test/src/diagnostics/non_bool_condition_test.dart
index 8d79c00..3199d246 100644
--- a/pkg/analyzer/test/src/diagnostics/non_bool_condition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_bool_condition_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
 //    defineReflectiveTests(NonBoolConditionTest);
+    defineReflectiveTests(NonBoolConditionWithUIAsCodeAndConstantsTest);
     defineReflectiveTests(NonBoolConditionWithUIAsCodeTest);
   });
 }
@@ -20,6 +21,18 @@
 class NonBoolConditionTest extends DriverResolutionTest {}
 
 @reflectiveTest
+class NonBoolConditionWithUIAsCodeAndConstantsTest
+    extends NonBoolConditionWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonBoolConditionWithUIAsCodeTest extends NonBoolConditionTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -29,8 +42,15 @@
     ];
 
   test_ifElement() async {
-    assertErrorCodesInCode('''
+    assertErrorCodesInCode(
+        '''
 const c = [if (3) 1];
-''', [StaticTypeWarningCode.NON_BOOL_CONDITION]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticTypeWarningCode.NON_BOOL_CONDITION]
+            : [
+                StaticTypeWarningCode.NON_BOOL_CONDITION,
+                CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT
+              ]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_if_element_condition_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_if_element_condition_from_deferred_library_test.dart
index 921f6d4..759b7de 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_if_element_condition_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_if_element_condition_from_deferred_library_test.dart
@@ -28,14 +28,18 @@
   test_inList_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const [if(a.c) 0];
-}''', [
-      CompileTimeErrorCode
-          .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_inList_nonConst() async {
@@ -51,24 +55,32 @@
   test_inList_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const [if(a.c) 0];
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_inMap_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const {if(a.c) 0 : 0};
-}''', [
-      CompileTimeErrorCode
-          .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_inMap_notConst() async {
@@ -84,24 +96,32 @@
   test_inMap_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const {if(a.c) 0 : 0};
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_inSet_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const {if(a.c) 0};
-}''', [
-      CompileTimeErrorCode
-          .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_inSet_notConst() async {
@@ -117,10 +137,26 @@
   test_inSet_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const bool c = true;''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const {if(a.c) 0};
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 }
+
+@reflectiveTest
+class NonConstantIfElementConditionFromDeferredLibraryWithConstantsTest
+    extends NonConstantIfElementConditionFromDeferredLibraryTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
index 4fd149d..8359de2 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
@@ -13,6 +13,8 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantListElementFromDeferredLibraryTest);
     defineReflectiveTests(
+        NonConstantListValueFromDeferredLibraryWithUiAsCodeAndConstantsTest);
+    defineReflectiveTests(
         NonConstantListValueFromDeferredLibraryWithUiAsCodeTest);
   });
 }
@@ -40,6 +42,18 @@
 }
 
 @reflectiveTest
+class NonConstantListValueFromDeferredLibraryWithUiAsCodeAndConstantsTest
+    extends NonConstantListValueFromDeferredLibraryWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantListValueFromDeferredLibraryWithUiAsCodeTest
     extends NonConstantListElementFromDeferredLibraryTest {
   @override
@@ -64,10 +78,17 @@
   test_const_ifElement_thenTrue_deferredThen() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const int c = 1;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 const cond = true;
 var v = const [ if (cond) a.c ];
-''', [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_test.dart
index 9544d6e..aafeb85 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantListElementTest);
+    defineReflectiveTests(NonConstantListElementWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(NonConstantListElementWithUiAsCodeTest);
   });
 }
@@ -41,6 +42,18 @@
 }
 
 @reflectiveTest
+class NonConstantListElementWithUiAsCodeAndConstantsTest
+    extends NonConstantListElementWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantListElementWithUiAsCodeTest
     extends NonConstantListElementTest {
   @override
@@ -86,10 +99,14 @@
   }
 
   test_const_ifElement_thenFalse_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const [if (1 < 0) a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_finalThen() async {
@@ -100,10 +117,14 @@
   }
 
   test_const_ifElement_thenTrue_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const [if (1 > 0) a];
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_finalThen() async {
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_element_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_element_test.dart
index 421cd20..692b49b 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_element_test.dart
@@ -11,6 +11,7 @@
 
 main() {
   defineReflectiveSuite(() {
+    defineReflectiveTests(NonConstantMapElementWithUiAsCodeAndConstantTest);
     defineReflectiveTests(NonConstantMapElementWithUiAsCodeTest);
     defineReflectiveTests(NonConstantMapKeyTest);
     defineReflectiveTests(NonConstantMapKeyWithUiAsCodeTest);
@@ -20,6 +21,18 @@
 }
 
 @reflectiveTest
+class NonConstantMapElementWithUiAsCodeAndConstantTest
+    extends NonConstantMapElementWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantMapElementWithUiAsCodeTest extends DriverResolutionTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -54,19 +67,27 @@
   }
 
   test_ifElement_mayBeConst() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 void main() {
   const {1: null, if (true) null: null};
 }
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_ifElement_nested_mayBeConst() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 void main() {
   const {1: null, if (true) if (true) null: null};
 }
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_ifElement_notConstCondition() async {
@@ -79,20 +100,28 @@
   }
 
   test_ifElementWithElse_mayBeConst() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 void main() {
   const isTrue = true;
   const {1: null, if (isTrue) null: null else null: null};
 }
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_spreadElement_mayBeConst() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 void main() {
   const {1: null, ...{null: null}};
 }
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_spreadElement_notConst() async {
@@ -132,59 +161,91 @@
     ];
 
   test_const_ifElement_thenElseFalse_finalElse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) 0: 0 else a: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) a: 0 else 0: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_finalElse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) 0: 0 else a: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) a: 0 else 0: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int, int>{if (1 < 0) a: 0};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) a: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int, int>{if (1 > 0) a: 0};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) a: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
 
@@ -215,58 +276,90 @@
     ];
 
   test_const_ifElement_thenElseFalse_finalElse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) 0: 0 else 0: a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) 0: a else 0: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_finalElse() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) 0: 0 else 0: a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenElseTrue_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) 0: a else 0: 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int, int>{if (1 < 0) 0: a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 < 0) 0: a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int, int>{if (1 > 0) 0: a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_finalThen() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 final dynamic a = 0;
 var v = const <int, int>{if (1 > 0) 0: a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
index d437cb6..43225c7 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
@@ -12,6 +12,8 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantMapKeyFromDeferredLibraryTest);
+    defineReflectiveTests(
+        NonConstantMapKeyFromDeferredLibraryWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(NonConstantMapKeyFromDeferredLibraryWithUiAsCodeTest);
   });
 }
@@ -38,6 +40,18 @@
 }
 
 @reflectiveTest
+class NonConstantMapKeyFromDeferredLibraryWithUiAsCodeAndConstantsTest
+    extends NonConstantMapKeyFromDeferredLibraryWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantMapKeyFromDeferredLibraryWithUiAsCodeTest
     extends NonConstantMapKeyFromDeferredLibraryTest {
   @override
@@ -62,10 +76,14 @@
   test_const_ifElement_thenTrue_deferredThen() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const int c = 1;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 const cond = true;
 var v = const { if (cond) a.c : 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_test.dart
index 2f18461..48a454b 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantMapKeyTest);
+    defineReflectiveTests(NonConstantMapKeyWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(NonConstantMapKeyWithUiAsCodeTest);
   });
 }
@@ -27,6 +28,18 @@
 }
 
 @reflectiveTest
+class NonConstantMapKeyWithUiAsCodeAndConstantsTest
+    extends NonConstantMapKeyWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantMapKeyWithUiAsCodeTest extends NonConstantMapKeyTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -36,18 +49,26 @@
     ];
 
   test_const_ifElement_thenTrue_elseFinal() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 final dynamic a = 0;
 const cond = true;
 var v = const {if (cond) 0: 1 else a : 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_thenFinal() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 final dynamic a = 0;
 const cond = true;
 var v = const {if (cond) a : 0};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
index d67f586..ddfde67 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
@@ -13,6 +13,8 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantMapValueFromDeferredLibraryTest);
     defineReflectiveTests(
+        NonConstantMapValueFromDeferredLibraryWithUiAsCodeAndConstantsTest);
+    defineReflectiveTests(
         NonConstantMapValueFromDeferredLibraryWithUiAsCodeTest);
   });
 }
@@ -39,6 +41,18 @@
 }
 
 @reflectiveTest
+class NonConstantMapValueFromDeferredLibraryWithUiAsCodeAndConstantsTest
+    extends NonConstantMapValueFromDeferredLibraryWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantMapValueFromDeferredLibraryWithUiAsCodeTest
     extends NonConstantMapValueFromDeferredLibraryTest {
   @override
@@ -63,10 +77,17 @@
   test_const_ifElement_thenTrue_thenDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const int c = 1;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 const cond = true;
 var v = const { if (cond) 'a' : a.c};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_test.dart
index b31b995..a88a96d 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantMapValueTest);
+    defineReflectiveTests(NonConstantMapValueWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(NonConstantMapValueWithUiAsCodeTest);
   });
 }
@@ -27,6 +28,18 @@
 }
 
 @reflectiveTest
+class NonConstantMapValueWithUiAsCodeAndConstantsTest
+    extends NonConstantMapValueWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantMapValueWithUiAsCodeTest extends NonConstantMapValueTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -36,18 +49,29 @@
     ];
 
   test_const_ifTrue_elseFinal() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 final dynamic a = 0;
 const cond = true;
 var v = const {if (cond) 'a': 'b', 'c' : a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [
+                CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE,
+                CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT
+              ]);
   }
 
   test_const_ifTrue_thenFinal() async {
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 final dynamic a = 0;
 const cond = true;
 var v = const {if (cond) 'a' : a};
-''', [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_set_element_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_set_element_from_deferred_library_test.dart
index defffb9..7a2ea68 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_set_element_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_set_element_from_deferred_library_test.dart
@@ -13,6 +13,8 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantSetElementFromDeferredLibraryTest);
     defineReflectiveTests(
+        NonConstantSetElementFromDeferredLibraryWithUiAsCodeAndConstantsTest);
+    defineReflectiveTests(
         NonConstantSetElementFromDeferredLibraryWithUiAsCodeTest);
   });
 }
@@ -40,6 +42,18 @@
 }
 
 @reflectiveTest
+class NonConstantSetElementFromDeferredLibraryWithUiAsCodeAndConstantsTest
+    extends NonConstantSetElementFromDeferredLibraryWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantSetElementFromDeferredLibraryWithUiAsCodeTest
     extends NonConstantSetElementFromDeferredLibraryTest {
   @override
@@ -64,10 +78,17 @@
   test_const_ifElement_thenTrue_thenDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const int c = 1;''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 const cond = true;
 var v = const {if (cond) a.c};
-''', [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT_FROM_DEFERRED_LIBRARY]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_SET_ELEMENT_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_set_element_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_set_element_test.dart
index 914db7c..753d602 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_set_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_set_element_test.dart
@@ -12,6 +12,7 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantSetElementTest);
+    defineReflectiveTests(NonConstantSetElementWithUiAsCodeAndConstantsTest);
     defineReflectiveTests(NonConstantSetElementWithUiAsCodeTest);
   });
 }
@@ -41,6 +42,18 @@
 }
 
 @reflectiveTest
+class NonConstantSetElementWithUiAsCodeAndConstantsTest
+    extends NonConstantSetElementWithUiAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class NonConstantSetElementWithUiAsCodeTest extends NonConstantSetElementTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
@@ -78,10 +91,14 @@
   }
 
   test_const_ifElement_thenFalse_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int>{if (1 < 0) a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_finalThen() async {
@@ -92,10 +109,14 @@
   }
 
   test_const_ifElement_thenTrue_constThen() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int>{if (1 > 0) a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_finalThen() async {
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_spread_expression_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_spread_expression_from_deferred_library_test.dart
index a6c9480..5d0e702 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_spread_expression_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_spread_expression_from_deferred_library_test.dart
@@ -12,6 +12,8 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(NonConstantSpreadExpressionFromDeferredLibraryTest);
+    defineReflectiveTests(
+        NonConstantSpreadExpressionFromDeferredLibraryWithConstantsTest);
   });
 }
 
@@ -28,13 +30,18 @@
   test_inList_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const List c = [];''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const [...a.c];
-}''', [
-      CompileTimeErrorCode.NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_inList_deferred_notConst() async {
@@ -50,23 +57,32 @@
   test_inList_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const List c = [];''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const [...a.c];
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
   }
 
   test_inMap_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const Map c = <int, int>{};''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const {...a.c};
-}''', [
-      CompileTimeErrorCode.NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_inMap_notConst() async {
@@ -82,23 +98,32 @@
   test_inMap_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const Map c = <int, int>{};''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const {...a.c};
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT]);
   }
 
   test_inSet_deferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const Set c = <int>{};''');
-    await assertErrorCodesInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' deferred as a;
 f() {
   return const {...a.c};
-}''', [
-      CompileTimeErrorCode.NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
-    ]);
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [
+                CompileTimeErrorCode
+                    .NON_CONSTANT_SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY
+              ]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_inSet_notConst() async {
@@ -114,10 +139,26 @@
   test_inSet_notDeferred() async {
     newFile(convertPath('/test/lib/lib1.dart'), content: r'''
 const Set c = <int>{};''');
-    await assertNoErrorsInCode(r'''
+    await assertErrorCodesInCode(
+        r'''
 import 'lib1.dart' as a;
 f() {
   return const {...a.c};
-}''');
+}''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 }
+
+@reflectiveTest
+class NonConstantSpreadExpressionFromDeferredLibraryWithConstantsTest
+    extends NonConstantSpreadExpressionFromDeferredLibraryTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
diff --git a/pkg/analyzer/test/src/diagnostics/set_element_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/set_element_type_not_assignable_test.dart
index 180e592..1a71c80 100644
--- a/pkg/analyzer/test/src/diagnostics/set_element_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/set_element_type_not_assignable_test.dart
@@ -2,6 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -11,6 +12,8 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(SetElementTypeNotAssignableTest);
+    defineReflectiveTests(
+        SetElementTypeNotAssignableWithUiAsCodeAndConstantTest);
     defineReflectiveTests(SetElementTypeNotAssignableWithUIAsCodeTest);
   });
 }
@@ -45,59 +48,105 @@
 }
 
 @reflectiveTest
+class SetElementTypeNotAssignableWithUiAsCodeAndConstantTest
+    extends SetElementTypeNotAssignableWithUIAsCodeTest {
+  @override
+  AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections,
+      EnableString.constant_update_2018
+    ];
+}
+
+@reflectiveTest
 class SetElementTypeNotAssignableWithUIAsCodeTest
     extends SetElementTypeNotAssignableTest {
   @override
   AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
-    ..enabledExperiments = ['control-flow-collections', 'spread-collections'];
+    ..enabledExperiments = [
+      EnableString.control_flow_collections,
+      EnableString.spread_collections
+    ];
 
   test_const_ifElement_thenElseFalse_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 0;
 var v = const <int>{if (1 < 0) a else b};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenElseFalse_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 const dynamic b = 'b';
 var v = const <int>{if (1 < 0) a else b};
-''', [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenFalse_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int>{if (1 < 0) 'a'};
-''', [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [
+                StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE,
+                CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT
+              ]);
   }
 
   test_const_ifElement_thenFalse_intString_dynamic() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int>{if (1 < 0) a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 0;
 var v = const <int>{if (true) a};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_ifElement_thenTrue_intString() async {
-    await assertErrorCodesInCode('''
+    await assertErrorCodesInCode(
+        '''
 const dynamic a = 'a';
 var v = const <int>{if (true) a};
-''', [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]);
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? [StaticWarningCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE]
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_const_spread_intInt() async {
-    await assertNoErrorsInCode('''
+    await assertErrorCodesInCode(
+        '''
 var v = const <int>{...[0, 1]};
-''');
+''',
+        analysisOptions.experimentStatus.constant_update_2018
+            ? []
+            : [CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT]);
   }
 
   test_nonConst_ifElement_thenElseFalse_intDynamic() async {