Skip to content

Commit

Permalink
#2559. Add augmenting functions signature tests. Part 2 (#2614)
Browse files Browse the repository at this point in the history
Add augmenting functions signature tests. Part 2
  • Loading branch information
sgrekhov committed Apr 19, 2024
1 parent 140d5fa commit 9ca77ed
Show file tree
Hide file tree
Showing 22 changed files with 1,664 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 signature of the function augmentation does not exactly match the
/// original function. This means the return types must be the same; there
/// must be the same number of positional, optional, and named parameters; the
/// types of corresponding positional and optional parameters must be the
/// same; the names and types of named parameters must be the same; any type
/// parameters and bounds must be the same; and any required or covariant
/// modifiers must match.
///
/// @description Checks that it is a compile-time error if number of type
/// parameters of an augmentation doesn't exactly match the original function
/// @author sgrekhov22@gmail.com
/// @issue 55478
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_functions_A04_t11_lib.dart';

void topLevelFunction<T>() {}

class C {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

mixin M {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

enum E {
e1;

static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

class A {}

extension Ext on A {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// 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 signature of the function augmentation does not exactly match the
/// original function. This means the return types must be the same; there
/// must be the same number of positional, optional, and named parameters; the
/// types of corresponding positional and optional parameters must be the
/// same; the names and types of named parameters must be the same; any type
/// parameters and bounds must be the same; and any required or covariant
/// modifiers must match.
///
/// @description Checks that it is a compile-time error if number of type
/// parameters of an augmentation doesn't exactly match the original function
/// @author sgrekhov22@gmail.com
/// @issue 55478
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_functions_A04_t11.dart';

augment void topLevelFunction() {}
// ^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void topLevelFunction<T, X>() {}
// ^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C {
augment static void staticMethod() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment static void staticMethod<T, X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<T, X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M {
augment static void staticMethod() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment static void staticMethod<T, X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<T, X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e1;

augment static void staticMethod() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment static void staticMethod<T, X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<T, X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
augment static void staticMethod() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment static void staticMethod<T, X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<T, X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 signature of the function augmentation does not exactly match the
/// original function. This means the return types must be the same; there
/// must be the same number of positional, optional, and named parameters; the
/// types of corresponding positional and optional parameters must be the
/// same; the names and types of named parameters must be the same; any type
/// parameters and bounds must be the same; and any required or covariant
/// modifiers must match.
///
/// @description Checks that it is a compile-time error if names of type
/// parameters of an augmentation doesn't exactly match the original function
/// @author sgrekhov22@gmail.com
/// @issue 55478
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_functions_A04_t12_lib.dart';

void topLevelFunction<T>() {}

class C {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

mixin M {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

enum E {
e1;

static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

class A {}

extension Ext on A {
static void staticMethod<T>() {}
void instanceMethod<T>() {}
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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 signature of the function augmentation does not exactly match the
/// original function. This means the return types must be the same; there
/// must be the same number of positional, optional, and named parameters; the
/// types of corresponding positional and optional parameters must be the
/// same; the names and types of named parameters must be the same; any type
/// parameters and bounds must be the same; and any required or covariant
/// modifiers must match.
///
/// @description Checks that it is a compile-time error if names of type
/// parameters of an augmentation doesn't exactly match the original function
/// @author sgrekhov22@gmail.com
/// @issue 55478
// SharedOptions=--enable-experiment=macros

augment library 'augmenting_functions_A04_t12.dart';

augment void topLevelFunction<X>() {}
// ^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment class C {
augment static void staticMethod<X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M {
augment static void staticMethod<X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e1;

augment static void staticMethod<X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
augment static void staticMethod<X>() {}
// ^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augment void instanceMethod<X>() {}
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 signature of the function augmentation does not exactly match the
/// original function. This means the return types must be the same; there
/// must be the same number of positional, optional, and named parameters; the
/// types of corresponding positional and optional parameters must be the
/// same; the names and types of named parameters must be the same; any type
/// parameters and bounds must be the same; and any required or covariant
/// modifiers must match.
///
/// @description Checks that it is a compile-time error if bounds of type
/// parameters of an augmentation doesn't exactly match the original function
/// @author sgrekhov22@gmail.com
/// @issue 55478
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_functions_A04_t13_lib.dart';

void topLevelFunction<T extends num>() {}

class C {
static void staticMethod<T extends num>() {}
void instanceMethod<T extends num>() {}
}

mixin M {
static void staticMethod<T extends num>() {}
void instanceMethod<T extends num>() {}
}

enum E {
e1;

static void staticMethod<T extends num>() {}
void instanceMethod<T extends num>() {}
}

class A {}

extension Ext on A {
static void staticMethod<T extends num>() {}
void instanceMethod<T extends num>() {}
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}

0 comments on commit 9ca77ed

Please sign in to comment.