Revert "Implement the type Never"
This reverts commit 40a06c3a774a341504e6cbdf74179261876c6695.
Reason for revert: Introduced a bug that is blocking a roll.
Original change's description:
> Implement the type Never
>
> Change-Id: Icbf407bc19f602c8382946b1e735905cc165c59c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100993
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>
TBR=paulberry@google.com,scheglov@google.com,brianwilkerson@google.com,mfairhurst@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: Iebb5b8327b0be7129298f39b343555b812314abf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/test/protocol_server_test.dart b/pkg/analysis_server/test/protocol_server_test.dart
index 7bc7663..b83902c 100644
--- a/pkg/analysis_server/test/protocol_server_test.dart
+++ b/pkg/analysis_server/test/protocol_server_test.dart
@@ -183,7 +183,6 @@
engine.ElementKind.GENERIC_FUNCTION_TYPE: ElementKind.FUNCTION_TYPE_ALIAS,
engine.ElementKind.IMPORT: ElementKind.UNKNOWN,
engine.ElementKind.NAME: ElementKind.UNKNOWN,
- engine.ElementKind.NEVER: ElementKind.UNKNOWN,
engine.ElementKind.UNIVERSE: ElementKind.UNKNOWN
});
}
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 7b42b5e..fb66964 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -843,27 +843,25 @@
static const ElementKind NAME = const ElementKind('NAME', 15, "<name>");
- static const ElementKind NEVER = const ElementKind('NEVER', 16, "<never>");
-
static const ElementKind PARAMETER =
- const ElementKind('PARAMETER', 17, "parameter");
+ const ElementKind('PARAMETER', 16, "parameter");
static const ElementKind PREFIX =
- const ElementKind('PREFIX', 18, "import prefix");
+ const ElementKind('PREFIX', 17, "import prefix");
- static const ElementKind SETTER = const ElementKind('SETTER', 19, "setter");
+ static const ElementKind SETTER = const ElementKind('SETTER', 18, "setter");
static const ElementKind TOP_LEVEL_VARIABLE =
- const ElementKind('TOP_LEVEL_VARIABLE', 20, "top level variable");
+ const ElementKind('TOP_LEVEL_VARIABLE', 19, "top level variable");
static const ElementKind FUNCTION_TYPE_ALIAS =
- const ElementKind('FUNCTION_TYPE_ALIAS', 21, "function type alias");
+ const ElementKind('FUNCTION_TYPE_ALIAS', 20, "function type alias");
static const ElementKind TYPE_PARAMETER =
- const ElementKind('TYPE_PARAMETER', 22, "type parameter");
+ const ElementKind('TYPE_PARAMETER', 21, "type parameter");
static const ElementKind UNIVERSE =
- const ElementKind('UNIVERSE', 23, "<universe>");
+ const ElementKind('UNIVERSE', 22, "<universe>");
static const List<ElementKind> values = const [
CLASS,
@@ -882,7 +880,6 @@
LOCAL_VARIABLE,
METHOD,
NAME,
- NEVER,
PARAMETER,
PREFIX,
SETTER,
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 8902935..8cadd5f 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -350,7 +350,6 @@
HintCode.SDK_VERSION_EQ_EQ_OPERATOR_IN_CONST_CONTEXT,
HintCode.SDK_VERSION_GT_GT_GT_OPERATOR,
HintCode.SDK_VERSION_IS_EXPRESSION_IN_CONST_CONTEXT,
- HintCode.SDK_VERSION_NEVER,
HintCode.SDK_VERSION_SET_LITERAL,
HintCode.SDK_VERSION_UI_AS_CODE,
HintCode.STRICT_RAW_TYPE,
diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
index 01b5ac3..5f16104 100644
--- a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
@@ -631,10 +631,7 @@
if (node.isSynthetic) return;
var name = node.name;
- if (_localScopes.contains(name) ||
- name == 'void' ||
- name == 'dynamic' ||
- name == 'Never') {
+ if (_localScopes.contains(name) || name == 'void' || name == 'dynamic') {
return;
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 62ba772..421a8df 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -289,8 +289,6 @@
var rootReference = Reference.root();
rootReference.getChild('dart:core').getChild('dynamic').element =
DynamicElementImpl.instance;
- rootReference.getChild('dart:core').getChild('Never').element =
- NeverElementImpl.instance;
elementFactory = LinkedElementFactory(
analysisContext,
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 26e8d2c..9bad2c1 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -7815,30 +7815,6 @@
}
}
-/// The synthetic element representing the declaration of the type `Never`.
-class NeverElementImpl extends ElementImpl implements TypeDefiningElement {
- /// Return the unique instance of this class.
- static NeverElementImpl get instance =>
- BottomTypeImpl.instance.element as NeverElementImpl;
-
- @override
- BottomTypeImpl type;
-
- /// Initialize a newly created instance of this class. Instances of this class
- /// should <b>not</b> be created except as part of creating the type
- /// associated with this element. The single instance of this class should be
- /// accessed through the method [instance].
- NeverElementImpl() : super('Never', -1) {
- setModifier(Modifier.SYNTHETIC, true);
- }
-
- @override
- ElementKind get kind => ElementKind.NEVER;
-
- @override
- T accept<T>(ElementVisitor<T> visitor) => null;
-}
-
/// A [VariableElementImpl], which is not a parameter.
abstract class NonParameterVariableElementImpl extends VariableElementImpl {
/// The unlinked representation of the variable in the summary.
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index b55b9e6..9b55e2c 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -63,9 +63,7 @@
/**
* Prevent the creation of instances of this class.
*/
- BottomTypeImpl._() : super(new NeverElementImpl(), "Never") {
- (element as NeverElementImpl).type = this;
- }
+ BottomTypeImpl._() : super(null, "<bottom>");
@override
int get hashCode => 0;
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index a4376d3..134f410 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -628,13 +628,6 @@
correction: "Try updating the SDK constraints.");
/**
- * The type Never is being used in code that is expected to run on versions of
- * the SDK that did not support it.
- */
- static const HintCode SDK_VERSION_NEVER = const HintCode(
- 'SDK_VERSION_NEVER', "The type Never is not yet supported.");
-
- /**
* The for, if or spread element is being used in code that is expected to run
* on versions of the SDK that did not support them.
*/
diff --git a/pkg/analyzer/lib/src/dart/resolver/scope.dart b/pkg/analyzer/lib/src/dart/resolver/scope.dart
index ccd4a4c..f1fb360 100644
--- a/pkg/analyzer/lib/src/dart/resolver/scope.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/scope.dart
@@ -7,7 +7,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -726,7 +725,6 @@
// which is not possible for `dynamic`.
if (library.isDartCore) {
definedNames['dynamic'] = DynamicElementImpl.instance;
- definedNames['Never'] = BottomTypeImpl.instance.element;
}
return new Namespace(definedNames);
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 71c2e91..0f3e861 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -6553,9 +6553,6 @@
if (element == DynamicElementImpl.instance) {
_setElement(typeName, element);
type = DynamicTypeImpl.instance;
- } else if (element is NeverElementImpl) {
- _setElement(typeName, element);
- type = element.type;
} else if (element is FunctionTypeAliasElement) {
_setElement(typeName, element);
type = element.type as TypeImpl;
@@ -7234,7 +7231,7 @@
InterfaceType get mapType;
/// Return the type representing the built-in type 'Never'.
- DartType get neverType;
+ InterfaceType get neverType;
/// Return a list containing all of the types that cannot be either extended
/// or implemented.
@@ -7291,11 +7288,11 @@
abstract class TypeProviderBase implements TypeProvider {
@override
List<InterfaceType> get nonSubtypableTypes => <InterfaceType>[
- boolType,
- doubleType,
- intType,
nullType,
numType,
+ intType,
+ doubleType,
+ boolType,
stringType
];
@@ -7324,12 +7321,18 @@
/// The type representing the built-in type 'bool'.
InterfaceType _boolType;
+ /// The type representing the type 'bottom'.
+ DartType _bottomType;
+
/// The type representing the built-in type 'double'.
InterfaceType _doubleType;
/// The type representing the built-in type 'Deprecated'.
InterfaceType _deprecatedType;
+ /// The type representing the built-in type 'dynamic'.
+ DartType _dynamicType;
+
/// The type representing the built-in type 'Function'.
InterfaceType _functionType;
@@ -7372,6 +7375,9 @@
/// An shared object representing the value 'null'.
DartObjectImpl _nullObject;
+ /// The type representing the type 'Never'.
+ InterfaceType _neverType;
+
/// The type representing the type 'Null'.
InterfaceType _nullType;
@@ -7412,7 +7418,7 @@
InterfaceType get boolType => _boolType;
@override
- DartType get bottomType => BottomTypeImpl.instance;
+ DartType get bottomType => _bottomType;
@override
InterfaceType get deprecatedType => _deprecatedType;
@@ -7421,7 +7427,7 @@
InterfaceType get doubleType => _doubleType;
@override
- DartType get dynamicType => DynamicTypeImpl.instance;
+ DartType get dynamicType => _dynamicType;
@override
InterfaceType get functionType => _functionType;
@@ -7463,7 +7469,7 @@
InterfaceType get mapType => _mapType;
@override
- DartType get neverType => BottomTypeImpl.instance;
+ InterfaceType get neverType => _neverType;
@override
DartObjectImpl get nullObject {
@@ -7503,6 +7509,16 @@
@override
InterfaceType get typeType => _typeType;
+ InterfaceType _createNever(Namespace namespace) {
+ // TODO(brianwilkerson) Remove this method when the class is defined in the
+ // SDK.
+ CompilationUnitElement compilationUnit =
+ boolType.element.getAncestor((e) => e is CompilationUnitElement);
+ ClassElementImpl element = ElementFactory.classElement('Never', objectType);
+ element.enclosingElement = compilationUnit;
+ return element.type;
+ }
+
/// Return the type with the given [typeName] from the given [namespace], or
/// `null` if there is no class with the given name.
InterfaceType _getType(Namespace namespace, String typeName) {
@@ -7525,8 +7541,10 @@
new NamespaceBuilder().createPublicNamespaceForLibrary(asyncLibrary);
_boolType = _getType(coreNamespace, 'bool');
+ _bottomType = BottomTypeImpl.instance;
_deprecatedType = _getType(coreNamespace, 'Deprecated');
_doubleType = _getType(coreNamespace, 'double');
+ _dynamicType = DynamicTypeImpl.instance;
_functionType = _getType(coreNamespace, 'Function');
_futureOrType = _getType(asyncNamespace, 'FutureOr');
_futureType = _getType(asyncNamespace, 'Future');
@@ -7534,6 +7552,8 @@
_iterableType = _getType(coreNamespace, 'Iterable');
_listType = _getType(coreNamespace, 'List');
_mapType = _getType(coreNamespace, 'Map');
+ _neverType =
+ _getType(coreNamespace, 'Never') ?? _createNever(coreNamespace);
_nullType = _getType(coreNamespace, 'Null');
_numType = _getType(coreNamespace, 'num');
_objectType = _getType(coreNamespace, 'Object');
@@ -7543,13 +7563,13 @@
_stringType = _getType(coreNamespace, 'String');
_symbolType = _getType(coreNamespace, 'Symbol');
_typeType = _getType(coreNamespace, 'Type');
- _futureDynamicType = _futureType.instantiate(<DartType>[dynamicType]);
+ _futureDynamicType = _futureType.instantiate(<DartType>[_dynamicType]);
_futureNullType = _futureType.instantiate(<DartType>[_nullType]);
- _iterableDynamicType = _iterableType.instantiate(<DartType>[dynamicType]);
+ _iterableDynamicType = _iterableType.instantiate(<DartType>[_dynamicType]);
_iterableObjectType = _iterableType.instantiate(<DartType>[_objectType]);
_mapObjectObjectType =
_mapType.instantiate(<DartType>[_objectType, _objectType]);
- _streamDynamicType = _streamType.instantiate(<DartType>[dynamicType]);
+ _streamDynamicType = _streamType.instantiate(<DartType>[_dynamicType]);
// FutureOr<T> is still fairly new, so if we're analyzing an SDK that
// doesn't have it yet, create an element for it.
_futureOrType ??= createPlaceholderFutureOr(_futureType, _objectType);
diff --git a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
index 938d454..1087abd 100644
--- a/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
+++ b/pkg/analyzer/lib/src/hint/sdk_constraint_verifier.dart
@@ -81,12 +81,6 @@
bool get checkFutureAndStream => _checkFutureAndStream ??=
!before_2_1_0.intersect(_versionConstraint).isEmpty;
- /// Return `true` if references to the non-nullable features need to be
- /// checked.
- // TODO(brianwilkerson) Implement this as a version check when a version has
- // been selected.
- bool get checkNnbd => true;
-
/// Return `true` if references to set literals need to be checked.
bool get checkSetLiterals =>
_checkSetLiterals ??= !before_2_2_0.intersect(_versionConstraint).isEmpty;
@@ -220,8 +214,6 @@
}
_errorReporter.reportErrorForNode(
HintCode.SDK_VERSION_ASYNC_EXPORTED_FROM_CORE, node, [element.name]);
- } else if (checkNnbd && element == _typeProvider.neverType.element) {
- _errorReporter.reportErrorForNode(HintCode.SDK_VERSION_NEVER, node);
}
}
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 8b77137..9723dd5 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -5390,6 +5390,7 @@
InterfaceType _listType;
InterfaceType _mapType;
InterfaceType _mapObjectObjectType;
+ InterfaceType _neverType;
InterfaceType _nullType;
InterfaceType _numType;
InterfaceType _objectType;
@@ -5474,7 +5475,8 @@
_mapType ??= _buildInterfaceType(_linker.coreLibrary, 'Map');
@override
- DartType get neverType => BottomTypeImpl.instance;
+ InterfaceType get neverType =>
+ _neverType ??= _buildInterfaceType(_linker.coreLibrary, 'Never');
@override
DartObjectImpl get nullObject {
diff --git a/pkg/analyzer/lib/src/summary/summary_sdk.dart b/pkg/analyzer/lib/src/summary/summary_sdk.dart
index 516ca6b..28dc74a 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -128,6 +128,7 @@
InterfaceType _listType;
InterfaceType _mapType;
InterfaceType _mapObjectObjectType;
+ InterfaceType _neverType;
DartObjectImpl _nullObject;
InterfaceType _nullType;
InterfaceType _numType;
@@ -266,7 +267,10 @@
}
@override
- DartType get neverType => BottomTypeImpl.instance;
+ InterfaceType get neverType {
+ assert(_coreLibrary != null);
+ return _neverType ??= _getType(_coreLibrary, 'Never');
+ }
@override
DartObjectImpl get nullObject {
diff --git a/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart b/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
index a459974f6..76261f8 100644
--- a/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/builder/source_library_builder.dart
@@ -169,7 +169,6 @@
}
if ('$uri' == 'dart:core') {
localScope.declare('dynamic', reference.getChild('dynamic'));
- localScope.declare('Never', reference.getChild('Never'));
}
}
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index b3cd018..7ee0e37 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -64,8 +64,6 @@
) {
var dynamicRef = rootReference.getChild('dart:core').getChild('dynamic');
dynamicRef.element = DynamicElementImpl.instance;
- var neverRef = rootReference.getChild('dart:core').getChild('Never');
- neverRef.element = NeverElementImpl.instance;
linkingBundleContext = LinkingBundleContext(dynamicRef);
diff --git a/pkg/analyzer/test/src/dart/element/type_algebra_test.dart b/pkg/analyzer/test/src/dart/element/type_algebra_test.dart
index d3bf71a..5aa1321 100644
--- a/pkg/analyzer/test/src/dart/element/type_algebra_test.dart
+++ b/pkg/analyzer/test/src/dart/element/type_algebra_test.dart
@@ -92,7 +92,7 @@
{t: intType},
{t: BottomTypeImpl.instance},
).substituteType(type);
- assertElementTypeString(result, '(Never) → int');
+ assertElementTypeString(result, '(<bottom>) → int');
}
}
diff --git a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
deleted file mode 100644
index 1859d26..0000000
--- a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// 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/dart/analysis/features.dart';
-import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
-// defineReflectiveTests(ExtendsNonClassTest);
- defineReflectiveTests(ExtendsNonClassWithNnbdTest);
- });
-}
-
-@reflectiveTest
-class ExtendsNonClassTest extends DriverResolutionTest {}
-
-@reflectiveTest
-class ExtendsNonClassWithNnbdTest extends ExtendsNonClassTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
- sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
-
- test_Never() async {
- await assertErrorsInCode('''
-class A extends Never {}
-''', [
- error(CompileTimeErrorCode.EXTENDS_NON_CLASS, 16, 5),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart
deleted file mode 100644
index 176830e..0000000
--- a/pkg/analyzer/test/src/diagnostics/implements_non_class_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// 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/dart/analysis/features.dart';
-import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
-// defineReflectiveTests(ImplementsNonClassTest);
- defineReflectiveTests(ImplementsNonClassWithNnbdTest);
- });
-}
-
-@reflectiveTest
-class ImplementsNonClassTest extends DriverResolutionTest {}
-
-@reflectiveTest
-class ImplementsNonClassWithNnbdTest extends ImplementsNonClassTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
- sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
-
- test_Never() async {
- await assertErrorsInCode('''
-class A implements Never {}
-''', [
- error(CompileTimeErrorCode.IMPLEMENTS_NON_CLASS, 19, 5),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
deleted file mode 100644
index 6e5666d..0000000
--- a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// 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/dart/analysis/features.dart';
-import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../dart/resolution/driver_resolution.dart';
-
-main() {
- defineReflectiveSuite(() {
-// defineReflectiveTests(MixinOfNonClassTest);
- defineReflectiveTests(MixinOfNonClassWithNnbdTest);
- });
-}
-
-@reflectiveTest
-class MixinOfNonClassTest extends DriverResolutionTest {}
-
-@reflectiveTest
-class MixinOfNonClassWithNnbdTest extends MixinOfNonClassTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
- sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
-
- test_Never() async {
- await assertErrorsInCode('''
-class A with Never {}
-''', [
- error(CompileTimeErrorCode.MIXIN_OF_NON_CLASS, 13, 5),
- ]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
index 07fbff3..1479299 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_super_class_constraint_non_interface_test.dart
@@ -27,6 +27,7 @@
..contextFeatures = new FeatureSet.forTesting(
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
+ @failingTest
test_Never() async {
await assertErrorsInCode('''
mixin M on Never {}
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
deleted file mode 100644
index 749e00f..0000000
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_never_test.dart
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
-// 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/dart/analysis/features.dart';
-import 'package:analyzer/src/dart/error/hint_codes.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'sdk_constraint_verifier_support.dart';
-
-main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(SdkVersionNeverTest);
- });
-}
-
-@reflectiveTest
-class SdkVersionNeverTest extends SdkConstraintVerifierTest {
- @override
- AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
- ..contextFeatures = new FeatureSet.forTesting(
- sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
-
- @failingTest
- test_equals() async {
- // This test cannot pass because there is no version number that is equal to
- // when non-nullable was enabled.
- await verifyVersion('2.1.0', '''
-Never sink;
-''');
- }
-
- @failingTest
- test_greaterThan() async {
- // This test cannot pass because there is no version number that is equal to
- // when non-nullable was enabled.
- await verifyVersion('2.1.0', '''
-Never sink;
-''');
- }
-
- test_lessThan() async {
- await verifyVersion('2.3.0', '''
-Never sink;
-''', errorCodes: [HintCode.SDK_VERSION_NEVER]);
- }
-}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index fff3f23..5a11626 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -32,9 +32,7 @@
import 'equal_elements_in_const_set_test.dart' as equal_elements_in_const_set;
import 'equal_keys_in_const_map_test.dart' as equal_keys_in_const_map;
import 'expression_in_map_test.dart' as expression_in_map;
-import 'extends_non_class_test.dart' as extends_non_class;
import 'final_not_initialized_test.dart' as final_not_initialized;
-import 'implements_non_class_test.dart' as implements_non_class;
import 'implicit_this_reference_in_initializer_test.dart'
as implicit_this_reference_in_initializer;
import 'import_deferred_library_with_load_function_test.dart'
@@ -71,7 +69,6 @@
as missing_default_value_for_paramter;
import 'missing_required_param_test.dart' as missing_required_param;
import 'missing_return_test.dart' as missing_return;
-import 'mixin_of_non_class_test.dart' as mixin_of_non_class;
import 'mixin_on_sealed_class_test.dart' as mixin_on_sealed_class;
import 'mixin_super_class_constraint_non_interface_test.dart'
as mixin_super_class_constraint_non_interface;
@@ -131,7 +128,6 @@
as sdk_version_gt_gt_gt_operator;
import 'sdk_version_is_expression_in_const_context_test.dart'
as sdk_version_is_expression_in_const_context;
-import 'sdk_version_never_test.dart' as sdk_version_never;
import 'sdk_version_set_literal_test.dart' as sdk_version_set_literal;
import 'sdk_version_ui_as_code_test.dart' as sdk_version_ui_as_code;
import 'set_element_type_not_assignable_test.dart'
@@ -188,9 +184,7 @@
equal_elements_in_const_set.main();
equal_keys_in_const_map.main();
expression_in_map.main();
- extends_non_class.main();
final_not_initialized.main();
- implements_non_class.main();
implicit_this_reference_in_initializer.main();
import_deferred_library_with_load_function.main();
invalid_assignment.main();
@@ -215,7 +209,6 @@
missing_default_value_for_paramter.main();
missing_required_param.main();
missing_return.main();
- mixin_of_non_class.main();
mixin_on_sealed_class.main();
mixin_super_class_constraint_non_interface.main();
must_be_immutable.main();
@@ -255,7 +248,6 @@
sdk_version_eq_eq_operator.main();
sdk_version_gt_gt_gt_operator.main();
sdk_version_is_expression_in_const_context.main();
- sdk_version_never.main();
sdk_version_set_literal.main();
sdk_version_ui_as_code.main();
set_element_type_not_assignable.main();
diff --git a/pkg/analyzer/test/src/summary/linker_test.dart b/pkg/analyzer/test/src/summary/linker_test.dart
index 0e738780..ab21dcd 100644
--- a/pkg/analyzer/test/src/summary/linker_test.dart
+++ b/pkg/analyzer/test/src/summary/linker_test.dart
@@ -327,7 +327,7 @@
ClassElementForLink_Class cls = library.getContainedName('C');
expect(cls.fields, hasLength(1));
var field = cls.fields[0];
- expect(field.type.toString(), '(Never) → int');
+ expect(field.type.toString(), '(<bottom>) → int');
}
void test_inferredType_instanceField_dynamic() {
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index 69d4a5b..12b725e 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -83,8 +83,6 @@
var rootReference = Reference.root();
rootReference.getChild('dart:core').getChild('dynamic').element =
DynamicElementImpl.instance;
- rootReference.getChild('dart:core').getChild('Never').element =
- NeverElementImpl.instance;
var elementFactory = LinkedElementFactory(
analysisContext,
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 817015b..fa7d3c1 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -8969,7 +8969,7 @@
bool f() => true;
''');
checkElementText(library, r'''
-final int Function(Never) v;
+final int Function(<bottom>) v;
bool f() {}
''');
}
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index 2d41129..14ddf55 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -9504,7 +9504,7 @@
UnlinkedVariable variable = serializeVariableText('int v = null;');
expect(variable.initializer.returnType, isNull);
checkInferredTypeSlot(
- variable.initializer.inferredReturnTypeSlot, null, 'Never',
+ variable.initializer.inferredReturnTypeSlot, null, '*bottom*',
onlyInStrongMode: false);
}
@@ -10827,7 +10827,7 @@
EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot);
checkLinkedTypeRef(inferredType.syntheticReturnType, 'dart:core', 'int');
expect(inferredType.syntheticParams, hasLength(1));
- checkLinkedTypeRef(inferredType.syntheticParams[0].type, null, 'Never');
+ checkLinkedTypeRef(inferredType.syntheticParams[0].type, null, '*bottom*');
}
test_syntheticFunctionType_inGenericClass() {
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/dart/import_library_element.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/dart/import_library_element.dart
index f135dd8..d9e764c 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/dart/import_library_element.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/dart/import_library_element.dart
@@ -27,7 +27,7 @@
}
var requestedElements = requestedLibrary.exportNamespace.definedNames;
- _removeEntriesForDynamicAndNever(requestedElements);
+ _removeEntryForDynamic(requestedElements);
// Find URIs of all libraries that import the requested name into the target.
var unprefixedNameUriSet = Set<Uri>();
@@ -145,13 +145,11 @@
return ImportLibraryRequest(requestedLibraryUri, prefix);
}
-/// The types `dynamic` and `Never` are part of 'dart:core', but have no
-/// library.
-void _removeEntriesForDynamicAndNever(Map<String, Element> requestedElements) {
+/// The type `dynamic` is part of 'dart:core', but has no library.
+void _removeEntryForDynamic(Map<String, Element> requestedElements) {
requestedElements.removeWhere((_, element) {
if (element.librarySource == null) {
- assert(
- element.displayName == 'dynamic' || element.displayName == 'Never');
+ assert(element.displayName == 'dynamic');
return true;
}
return false;