Skip to content

Commit dcab0d0

Browse files
author
Dart CI
committed
Version 2.17.0-15.0.dev
Merge commit '763f35ace89140ce7babd5bd7619f17569efc0fe' into 'dev'
2 parents 68ccd13 + 763f35a commit dcab0d0

File tree

6 files changed

+27
-4
lines changed

6 files changed

+27
-4
lines changed

pkg/analyzer/lib/src/dart/error/ffi_code.g.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class FfiCode extends AnalyzerErrorCode {
440440
static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS = FfiCode(
441441
'SUBTYPE_OF_FFI_CLASS',
442442
"The class '{0}' can't implement '{1}'.",
443-
correctionMessage: "Try extending 'Struct' or 'Union'.",
443+
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'.",
444444
uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS',
445445
);
446446

pkg/analyzer/lib/src/generated/ffi_verifier.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
2424
static const _allocatorExtensionName = 'AllocatorAlloc';
2525
static const _arrayClassName = 'Array';
2626
static const _dartFfiLibraryName = 'dart.ffi';
27+
static const _finalizableClassName = 'Finalizable';
2728
static const _isLeafParamName = 'isLeaf';
2829
static const _opaqueClassName = 'Opaque';
2930
static const _ffiNativeName = 'FfiNative';
@@ -116,7 +117,8 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
116117
void checkSupertype(NamedType typename, FfiCode subtypeOfFfiCode,
117118
FfiCode subtypeOfStructCode) {
118119
final superName = typename.name.staticElement?.name;
119-
if (superName == _allocatorClassName) {
120+
if (superName == _allocatorClassName ||
121+
superName == _finalizableClassName) {
120122
return;
121123
}
122124
if (typename.ffiClass != null) {

pkg/analyzer/lib/src/test_utilities/mock_sdk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,9 @@ class AbiSpecificIntegerMapping {
833833
const AbiSpecificIntegerMapping(this.mapping);
834834
}
835835
836+
abstract class Finalizable {
837+
factory Finalizable._() => throw UnsupportedError("");
838+
}
836839
''',
837840
)
838841
]);

pkg/analyzer/messages.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13993,7 +13993,7 @@ FfiCode:
1399313993
SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
1399413994
sharedName: SUBTYPE_OF_FFI_CLASS
1399513995
problemMessage: "The class '{0}' can't implement '{1}'."
13996-
correctionMessage: "Try extending 'Struct' or 'Union'."
13996+
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'."
1399713997
comment: |-
1399813998
Parameters:
1399913999
0: the name of the subclass

pkg/analyzer/test/src/diagnostics/subtype_of_ffi_class_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ class C extends Double {}
2727
]);
2828
}
2929

30+
test_Finalizable() async {
31+
await assertErrorsInCode(r'''
32+
import 'dart:ffi';
33+
class C extends Finalizable {}
34+
''', [
35+
error(FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS, 35, 11),
36+
error(CompileTimeErrorCode.NO_GENERATIVE_CONSTRUCTORS_IN_SUPERCLASS, 35,
37+
11),
38+
]);
39+
}
40+
3041
test_Float() async {
3142
await assertErrorsInCode(r'''
3243
import 'dart:ffi';
@@ -169,6 +180,13 @@ class C implements ffi.Double {}
169180
]);
170181
}
171182

183+
test_Finalizable() async {
184+
await assertNoErrorsInCode(r'''
185+
import 'dart:ffi';
186+
class C implements Finalizable {}
187+
''');
188+
}
189+
172190
test_Float() async {
173191
await assertErrorsInCode(r'''
174192
import 'dart:ffi';

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 17
2929
PATCH 0
30-
PRERELEASE 14
30+
PRERELEASE 15
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)