Skip to content

Commit

Permalink
Version 2.17.0-15.0.dev
Browse files Browse the repository at this point in the history
Merge commit '763f35ace89140ce7babd5bd7619f17569efc0fe' into 'dev'
  • Loading branch information
Dart CI committed Jan 14, 2022
2 parents 68ccd13 + 763f35a commit dcab0d0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class FfiCode extends AnalyzerErrorCode {
static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS = FfiCode(
'SUBTYPE_OF_FFI_CLASS',
"The class '{0}' can't implement '{1}'.",
correctionMessage: "Try extending 'Struct' or 'Union'.",
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'.",
uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS',
);

Expand Down
4 changes: 3 additions & 1 deletion pkg/analyzer/lib/src/generated/ffi_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
static const _allocatorExtensionName = 'AllocatorAlloc';
static const _arrayClassName = 'Array';
static const _dartFfiLibraryName = 'dart.ffi';
static const _finalizableClassName = 'Finalizable';
static const _isLeafParamName = 'isLeaf';
static const _opaqueClassName = 'Opaque';
static const _ffiNativeName = 'FfiNative';
Expand Down Expand Up @@ -116,7 +117,8 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
void checkSupertype(NamedType typename, FfiCode subtypeOfFfiCode,
FfiCode subtypeOfStructCode) {
final superName = typename.name.staticElement?.name;
if (superName == _allocatorClassName) {
if (superName == _allocatorClassName ||
superName == _finalizableClassName) {
return;
}
if (typename.ffiClass != null) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ class AbiSpecificIntegerMapping {
const AbiSpecificIntegerMapping(this.mapping);
}
abstract class Finalizable {
factory Finalizable._() => throw UnsupportedError("");
}
''',
)
]);
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13993,7 +13993,7 @@ FfiCode:
SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
sharedName: SUBTYPE_OF_FFI_CLASS
problemMessage: "The class '{0}' can't implement '{1}'."
correctionMessage: "Try extending 'Struct' or 'Union'."
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'."
comment: |-
Parameters:
0: the name of the subclass
Expand Down
18 changes: 18 additions & 0 deletions pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ class C extends Double {}
]);
}

test_Finalizable() async {
await assertErrorsInCode(r'''
import 'dart:ffi';
class C extends Finalizable {}
''', [
error(FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS, 35, 11),
error(CompileTimeErrorCode.NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS, 35,
11),
]);
}

test_Float() async {
await assertErrorsInCode(r'''
import 'dart:ffi';
Expand Down Expand Up @@ -169,6 +180,13 @@ class C implements ffi.Double {}
]);
}

test_Finalizable() async {
await assertNoErrorsInCode(r'''
import 'dart:ffi';
class C implements Finalizable {}
''');
}

test_Float() async {
await assertErrorsInCode(r'''
import 'dart:ffi';
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 2
MINOR 17
PATCH 0
PRERELEASE 14
PRERELEASE 15
PRERELEASE_PATCH 0

0 comments on commit dcab0d0

Please sign in to comment.