Skip to content

Commit

Permalink
Version 3.0.0-373.0.dev
Browse files Browse the repository at this point in the history
Merge e687628 into dev
  • Loading branch information
Dart CI committed Mar 27, 2023
2 parents af5457b + e687628 commit f49a838
Show file tree
Hide file tree
Showing 123 changed files with 238 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1379,11 +1379,11 @@ FfiCode.PACKED_ANNOTATION_ALIGNMENT:
FfiCode.SIZE_ANNOTATION_DIMENSIONS:
status: needsEvaluation
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS:
status: hasFix
status: noFix
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
status: hasFix
status: noFix
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH:
status: hasFix
status: noFix
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS:
status: hasFix
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,15 +1350,6 @@ class FixProcessor extends BaseProcessor {
CompileTimeErrorCode.YIELD_OF_INVALID_TYPE: [
MakeReturnTypeNullable.new,
],
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS: [
RemoveNameFromDeclarationClause.new,
],
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS: [
RemoveNameFromDeclarationClause.new,
],
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH: [
RemoveNameFromDeclarationClause.new,
],
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS: [
RemoveNameFromDeclarationClause.new,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ void main() {
defineReflectiveTests(MixinOfNonInterfaceTest);
defineReflectiveTests(SubtypeOfFfiClassInExtendsTest);
defineReflectiveTests(SubtypeOfFfiClassInImplementsTest);
defineReflectiveTests(SubtypeOfFfiClassInWithTest);
defineReflectiveTests(SubtypeOfStructClassInExtendsTest);
defineReflectiveTests(SubtypeOfStructClassInImplementsTest);
defineReflectiveTests(SubtypeOfStructClassInWithTest);
});
}
Expand Down Expand Up @@ -214,8 +212,6 @@ final class C extends Double {}
import 'dart:ffi';
final class C {}
''',
errorFilter: (error) =>
error.errorCode == FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS,
);
}
}
Expand All @@ -235,31 +231,10 @@ final class C implements Double {}
import 'dart:ffi';
final class C {}
''',
errorFilter: (error) =>
error.errorCode == FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS,
);
}
}

@reflectiveTest
class SubtypeOfFfiClassInWithTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_NAME_FROM_DECLARATION_CLAUSE;

Future<void> test_oneName() async {
await resolveTestCode('''
import 'dart:ffi';
final class C with Double {}
''');
await assertHasFix('''
import 'dart:ffi';
final class C {}
''',
errorFilter: (error) =>
error.errorCode == FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH);
}
}

@reflectiveTest
class SubtypeOfStructClassInExtendsTest extends FixProcessorTest {
@override
Expand All @@ -283,27 +258,6 @@ final class C {}
}
}

@reflectiveTest
class SubtypeOfStructClassInImplementsTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_NAME_FROM_DECLARATION_CLAUSE;

Future<void> test_oneName() async {
await resolveTestCode('''
import 'dart:ffi';
final class C implements Struct {}
''');
await assertHasFix(
'''
import 'dart:ffi';
final class C {}
''',
errorFilter: (error) =>
error.errorCode == FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS,
);
}
}

@reflectiveTest
class SubtypeOfStructClassInWithTest extends FixProcessorTest {
@override
Expand Down
22 changes: 4 additions & 18 deletions pkg/analyzer/lib/src/generated/ffi_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
_validateAbiSpecificIntegerAnnotation(node);
_validateAbiSpecificIntegerMappingAnnotation(
node.name, node.metadata);
} else if (className != _allocatorClassName &&
className != _opaqueClassName &&
className != _abiSpecificIntegerClassName) {
_errorReporter.reportErrorForNode(
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS,
superclass.name,
[node.name.lexeme, superclass.name.name]);
}
} else if (superclass.isCompoundSubtype ||
superclass.isAbiSpecificIntegerSubtype) {
Expand All @@ -117,18 +110,13 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
}

// No classes from the FFI may be explicitly implemented.
void checkSupertype(NamedType typename, FfiCode subtypeOfFfiCode,
FfiCode subtypeOfStructCode) {
void checkSupertype(NamedType typename, FfiCode subtypeOfStructCode) {
final superName = typename.name.staticElement?.name;
if (superName == _allocatorClassName ||
superName == _finalizableClassName) {
return;
}
if (typename.ffiClass != null) {
_errorReporter.reportErrorForNode(subtypeOfFfiCode, typename,
[node.name.lexeme, typename.name.toSource()]);
} else if (typename.isCompoundSubtype ||
typename.isAbiSpecificIntegerSubtype) {
if (typename.isCompoundSubtype || typename.isAbiSpecificIntegerSubtype) {
_errorReporter.reportErrorForNode(subtypeOfStructCode, typename,
[node.name.lexeme, typename.name.toSource()]);
}
Expand All @@ -137,15 +125,13 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
var implementsClause = node.implementsClause;
if (implementsClause != null) {
for (NamedType type in implementsClause.interfaces) {
checkSupertype(type, FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS,
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS);
checkSupertype(type, FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS);
}
}
var withClause = node.withClause;
if (withClause != null) {
for (NamedType type in withClause.mixinTypes) {
checkSupertype(type, FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH,
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_WITH);
checkSupertype(type, FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_WITH);
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19266,6 +19266,7 @@ FfiCode:
}
```
SUBTYPE_OF_FFI_CLASS_IN_EXTENDS:
removed: 3.0
sharedName: SUBTYPE_OF_FFI_CLASS
problemMessage: "The class '{0}' can't extend '{1}'."
correctionMessage: "Try extending 'Struct' or 'Union'."
Expand Down Expand Up @@ -19316,6 +19317,7 @@ FfiCode:
final class C {}
```
SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
removed: 3.0
sharedName: SUBTYPE_OF_FFI_CLASS
problemMessage: "The class '{0}' can't implement '{1}'."
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'."
Expand All @@ -19325,6 +19327,7 @@ FfiCode:
1: the name of the class being extended, implemented, or mixed in
hasPublishedDocs: true
SUBTYPE_OF_FFI_CLASS_IN_WITH:
removed: 3.0
sharedName: SUBTYPE_OF_FFI_CLASS
problemMessage: "The class '{0}' can't mix in '{1}'."
correctionMessage: "Try extending 'Struct' or 'Union'."
Expand Down
Loading

0 comments on commit f49a838

Please sign in to comment.