Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2574. Add more augmenting types tests #2581

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
///
/// - The augmenting type and corresponding type are not the same kind: class,
/// mixin, enum, or extension. You can't augment a class with a mixin, etc.
///
/// @description Checks that it is not an error if an augmenting type and the
/// corresponding type are the same kind. Test type aliases
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import '../../Utils/expect.dart';
import augment 'augmenting_types_A01_t03_lib.dart';

class C {}

mixin M {}

enum E {e1;}

typedef CAlias = C;
typedef MAlias = M;
typedef EAlias = E;

class MA = Object with M;

main() {
Expect.equals("C", C().foo());
Expect.equals("C", CAlias().foo());
Expect.equals("M", MA().foo());
Expect.equals("E", E.e1.foo());
Expect.equals("E", EAlias.e1.foo());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
///
/// - The augmenting type and corresponding type are not the same kind: class,
/// mixin, enum, or extension. You can't augment a class with a mixin, etc.
///
/// @description Checks that it is not an error if an augmenting type and the
/// corresponding type are the same kind. Test type aliases
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmenting_types_A01_t03.dart';

augment class CAlias {
String foo() => "C";
}

augment mixin MAlias {
String foo() => "M";
}

augment enum EAlias {
eernstg marked this conversation as resolved.
Show resolved Hide resolved
String foo() => "E";
}
Loading