Skip to content

Commit 8b3d76d

Browse files
dcharkescommit-bot@chromium.org
authored andcommitted
[analyzer/ffi] Fix crash with dynamic field in struct
Closes: #38993 Change-Id: I6aaa265020709d5846a40bd8fb1c7bd1ef38903c Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122341 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
1 parent 74d0282 commit 8b3d76d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
141141
element.name == 'DynamicLibrary' && element.library.name == 'dart.ffi';
142142

143143
/// Return `true` if the given [element] represents the class `Pointer`.
144-
bool _isPointer(ClassElement element) =>
144+
bool _isPointer(Element element) =>
145145
element.name == 'Pointer' && element.library.name == 'dart.ffi';
146146

147147
/// Return `true` if the [typeName] represents a subtype of `Struct`.

tests/ffi/regress_38993_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
//
5+
// Tests a compile time error that should not crash the analyzer or CFE.
6+
7+
import "dart:ffi";
8+
9+
class C extends Struct {
10+
dynamic x; //# 1: compile-time error
11+
}
12+
13+
main() {}

0 commit comments

Comments
 (0)