| // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import '../dart/resolution/context_collection_resolution.dart'; |
| |
| main() { |
| defineReflectiveSuite(() { |
| defineReflectiveTests(GenericStructSubclassTest); |
| }); |
| } |
| |
| @reflectiveTest |
| class GenericStructSubclassTest extends PubPackageResolutionTest { |
| test_genericStruct() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| import 'dart:ffi'; |
| final class S<T> extends Struct { |
| // ^ |
| // [diag.genericStructSubclass] The class 'S' can't extend 'Struct' or 'Union' because 'S' is generic. |
| external Pointer notEmpty; |
| } |
| '''); |
| } |
| |
| test_genericUnion() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| import 'dart:ffi'; |
| final class S<T> extends Union { |
| // ^ |
| // [diag.genericStructSubclass] The class 'S' can't extend 'Struct' or 'Union' because 'S' is generic. |
| external Pointer notEmpty; |
| } |
| '''); |
| } |
| |
| test_validStruct() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| import 'dart:ffi'; |
| final class S extends Struct { |
| external Pointer notEmpty; |
| } |
| '''); |
| } |
| } |