forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
260 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A01_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that an interface containing a `call` method is | ||
/// assignable to the type `Function` | ||
/// @author sgrekhov22@gmail.com | ||
import '../../../../Utils/expect.dart'; | ||
|
||
class C { | ||
int call() => 1; | ||
} | ||
|
||
enum E { | ||
e1, e2; | ||
|
||
int call() => 2; | ||
} | ||
|
||
mixin M { | ||
int call() => 3; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Function f1 = C(); | ||
Function f2 = E.e1; | ||
Function f3 = MA(); | ||
|
||
Expect.equals(1, f1()); | ||
Expect.equals(2, f2()); | ||
Expect.equals(3, f3()); | ||
} |
46 changes: 46 additions & 0 deletions
46
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A01_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that an interface containing a `call` getter is not | ||
/// assignable to the type `Function` | ||
/// @author sgrekhov22@gmail.com | ||
class C { | ||
int get call => 1; | ||
} | ||
|
||
enum E { | ||
e1, e2; | ||
|
||
int get call => 2; | ||
} | ||
|
||
mixin M { | ||
int get call => 3; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Function f1 = C(); | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Function f2 = E.e1; | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Function f3 = MA(); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
46 changes: 46 additions & 0 deletions
46
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A01_t04.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that an interface containing a `call` setter is not | ||
/// assignable to the type `Function` | ||
/// @author sgrekhov22@gmail.com | ||
class C { | ||
void set call(int _) {} | ||
} | ||
|
||
enum E { | ||
e1, e2; | ||
|
||
void set call(int _) {} | ||
} | ||
|
||
mixin M { | ||
void set call(int _) {} | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Function f1 = C(); | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Function f2 = E.e1; | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Function f3 = MA(); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
29 changes: 29 additions & 0 deletions
29
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A01_t05.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks an implicit tear off `call` from a receiver whose type | ||
/// is a type variable | ||
/// @author sgrekhov22@gmail.com | ||
import '../../../../Utils/expect.dart'; | ||
import '../../../../Utils/static_type_helper.dart'; | ||
|
||
class A { | ||
int call() => 42; | ||
} | ||
|
||
Function f<X extends A>(X x) => x; | ||
|
||
void main() { | ||
f(A()).expectStaticType<Exactly<Function>>(); | ||
Expect.equals(42, f(A())()); | ||
} |
37 changes: 37 additions & 0 deletions
37
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A01_t06.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that it is a compile-time error to assign an implicit | ||
/// tear off a `call` getter or setter to the type `Function` | ||
/// @author sgrekhov22@gmail.com | ||
class A { | ||
int get call => 42; | ||
} | ||
|
||
class B { | ||
void set call(int _) {} | ||
} | ||
|
||
Function f1<X extends A>(X x) => x; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Function f2<X extends B>(X x) => x; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
void main() { | ||
print(f1); | ||
print(f2); | ||
} |
23 changes: 23 additions & 0 deletions
23
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A02_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that a record with a `call` member is not assignable to | ||
/// the type `Function` | ||
/// @author sgrekhov22@gmail.com | ||
void main() { | ||
var r = (call: () => 42); | ||
Function f = r; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
25 changes: 25 additions & 0 deletions
25
Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A02_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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 A function expression invocation i has the form | ||
/// ef <A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k), | ||
/// where ef is an expression. | ||
/// ... | ||
/// Let F be the static type of ef . If F is an interface type that has a method | ||
/// named call, i is treated as the ordinary invocation | ||
/// ef .call<A1, . . . , Ar>(a1, . . . , an, xn+1: an+1, . . . , xn+k: an+k) | ||
/// | ||
/// @description Checks that it is a compile-time error to call a a `call` | ||
/// member of a record | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 54616,54651 | ||
void main() { | ||
var r = (call: () => 42); | ||
r(); | ||
//^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
r.call(); // Ok | ||
} |