Skip to content

Commit

Permalink
Legacy. Remove 2.5 language tests, two error codes.
Browse files Browse the repository at this point in the history
Change-Id: If29c291d17fbbd74141c08afe55d0c174b303f0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349627
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Feb 1, 2024
1 parent 79cd9a6 commit 14a9782
Show file tree
Hide file tree
Showing 26 changed files with 13 additions and 781 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,6 @@ CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY:
status: needsFix
notes: |-
Remove the export.
CompileTimeErrorCode.EXPORT_LEGACY_SYMBOL:
status: noFix
notes: |-
Removed as of Dart 3.0.
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY:
status: needsFix
notes: |-
Expand Down Expand Up @@ -1842,9 +1838,6 @@ HintCode.DIVISION_OPTIMIZATION:
status: hasFix
HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION:
status: noFix
HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE:
status: noFix
notes: Deprecated
HintCode.MACRO_INFO:
status: noFix
HintCode.UNNECESSARY_CAST:
Expand Down
12 changes: 0 additions & 12 deletions pkg/analyzer/lib/src/dart/error/hint_codes.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@ class HintCode extends AnalyzerErrorCode {
hasPublishedDocs: true,
);

/// https://github.com/dart-lang/sdk/issues/44063
///
/// Parameters:
/// 0: the name of the library
static const HintCode IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE = HintCode(
'IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE',
"The library '{0}' is legacy, and shouldn't be imported into a null safe "
"library.",
correctionMessage: "Try migrating the imported library.",
hasPublishedDocs: true,
);

/// Parameters:
/// 0: the message
static const HintCode MACRO_INFO = HintCode(
Expand Down
23 changes: 0 additions & 23 deletions pkg/analyzer/lib/src/error/best_practices_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
_checkForLoadLibraryFunction(node, importElement);
}
_invalidAccessVerifier.verifyImport(node);
_checkForImportOfLegacyLibraryIntoNullSafe(node);
super.visitImportDirective(node);
}

Expand Down Expand Up @@ -996,28 +995,6 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
}
}

void _checkForImportOfLegacyLibraryIntoNullSafe(ImportDirective node) {
if (!_isNonNullableByDefault) {
return;
}

var importElement = node.element;
if (importElement == null) {
return;
}

var importedLibrary = importElement.importedLibrary;
if (importedLibrary == null || importedLibrary.isNonNullableByDefault) {
return;
}

_errorReporter.reportErrorForNode(
HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE,
node.uri,
[importedLibrary.source.uri],
);
}

/// Check that the namespace exported by [node] does not include any elements
/// annotated with `@internal`.
void _checkForInternalExport(ExportDirective node) {
Expand Down
11 changes: 0 additions & 11 deletions pkg/analyzer/lib/src/error/codes.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1543,17 +1543,6 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
hasPublishedDocs: true,
);

/// Parameters:
/// 0: the name of a symbol defined in a legacy library
static const CompileTimeErrorCode EXPORT_LEGACY_SYMBOL = CompileTimeErrorCode(
'EXPORT_LEGACY_SYMBOL',
"The symbol '{0}' is defined in a legacy library, and can't be re-exported "
"from a library with null safety enabled.",
correctionMessage:
"Try removing the export or migrating the legacy library.",
hasPublishedDocs: true,
);

/// Parameters:
/// 0: the URI pointing to a non-library declaration
static const CompileTimeErrorCode EXPORT_OF_NON_LIBRARY =
Expand Down
2 changes: 0 additions & 2 deletions pkg/analyzer/lib/src/error/error_code_values.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ const List<ErrorCode> errorCodeValues = [
CompileTimeErrorCode.EXPECTED_TWO_MAP_PATTERN_TYPE_ARGUMENTS,
CompileTimeErrorCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS,
CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY,
CompileTimeErrorCode.EXPORT_LEGACY_SYMBOL,
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
CompileTimeErrorCode.EXPRESSION_IN_MAP,
CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS,
Expand Down Expand Up @@ -631,7 +630,6 @@ const List<ErrorCode> errorCodeValues = [
HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE,
HintCode.DIVISION_OPTIMIZATION,
HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE,
HintCode.MACRO_INFO,
HintCode.UNNECESSARY_CAST,
HintCode.UNNECESSARY_IMPORT,
Expand Down
30 changes: 0 additions & 30 deletions pkg/analyzer/lib/src/generated/error_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
var exportedLibrary = exportElement.exportedLibrary;
_checkForAmbiguousExport(node, exportElement, exportedLibrary);
_checkForExportInternalLibrary(node, exportElement);
_checkForExportLegacySymbol(node);
}
super.visitExportDirective(node);
}
Expand Down Expand Up @@ -2927,35 +2926,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
[directive.uri.stringValue!]);
}

/// See [CompileTimeErrorCode.EXPORT_LEGACY_SYMBOL].
void _checkForExportLegacySymbol(ExportDirective node) {
if (!_isNonNullableByDefault) {
return;
}

var element = node.element!;
// TODO(scheglov): Expose from ExportElement.
var namespace =
NamespaceBuilder().createExportNamespaceForDirective(element);

for (var element in namespace.definedNames.values) {
if (element == DynamicElementImpl.instance ||
element == NeverElementImpl.instance) {
continue;
}
if (!element.library!.isNonNullableByDefault) {
errorReporter.reportErrorForNode(
CompileTimeErrorCode.EXPORT_LEGACY_SYMBOL,
node.uri,
[element.displayName],
);
// Stop after the first symbol.
// We don't want to list them all.
break;
}
}
}

/// Verify that the given extends [clause] does not extend a deferred class.
///
/// See [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS].
Expand Down
2 changes: 2 additions & 0 deletions pkg/analyzer/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4750,6 +4750,7 @@ CompileTimeErrorCode:

Remove the export directive.
EXPORT_LEGACY_SYMBOL:
removedIn: "3.0"
problemMessage: "The symbol '{0}' is defined in a legacy library, and can't be re-exported from a library with null safety enabled."
correctionMessage: Try removing the export or migrating the legacy library.
hasPublishedDocs: true
Expand Down Expand Up @@ -20657,6 +20658,7 @@ HintCode:
}
```
IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE:
removedIn: "3.0"
problemMessage: "The library '{0}' is legacy, and shouldn't be imported into a null safe library."
correctionMessage: Try migrating the imported library.
comment: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,24 +1212,24 @@ extension E<U> on int {}
_assertNotSameSignature(r'''
class A {}
''', r'''
// @dart = 2.5
// @dart = 3.2
class A {}
''');
}

test_featureSet_change() async {
_assertNotSameSignature(r'''
// @dart = 2.6
// @dart = 3.2
class A {}
''', r'''
// @dart = 2.2
// @dart = 3.3
class A {}
''');
}

test_featureSet_remove() async {
_assertNotSameSignature(r'''
// @dart = 2.5
// @dart = 3.2
class A {}
''', r'''
class A {}
Expand Down
19 changes: 0 additions & 19 deletions pkg/analyzer/test/src/dart/resolution/field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,25 +249,6 @@ class A {
assertType(findElement.field('f').type, 'dynamic');
}

test_type_inferred_nonNullify() async {
newFile('$testPackageLibPath/a.dart', r'''
// @dart = 2.7
var a = 0;
''');

await assertErrorsInCode('''
import 'a.dart';
class A {
var f = a;
}
''', [
error(HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE, 7, 8),
]);

assertType(findElement.field('f').type, 'int');
}

test_type_inferred_null() async {
await resolveTestCode('''
class A {
Expand Down
135 changes: 0 additions & 135 deletions pkg/analyzer/test/src/dart/resolution/language_version_test.dart

This file was deleted.

21 changes: 0 additions & 21 deletions pkg/analyzer/test/src/dart/resolution/local_variable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,4 @@ void f() {
expect(x.isLate, isTrue);
expect(x.isStatic, isFalse);
}

test_nonNullifyType() async {
newFile('$testPackageLibPath/a.dart', r'''
// @dart = 2.7
var a = 0;
''');

await assertErrorsInCode('''
import 'a.dart';
void f() {
var x = a;
x;
}
''', [
error(HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE, 7, 8),
]);

var x = findElement.localVar('x');
assertType(x.type, 'int');
}
}
Loading

0 comments on commit 14a9782

Please sign in to comment.