Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6e821af

Browse files
author
Dart CI
committed
Version 2.14.0-366.0.dev
Merge commit 'ac137cf40ff1d5da95ec8e99653538b2ed6eef5b' into 'dev'
2 parents 54f1ff2 + ac137cf commit 6e821af

31 files changed

+690
-3
lines changed

pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,12 @@ class KernelTarget extends TargetImplementation {
10531053
// To report errors on the first definition of a constructor, we need to
10541054
// iterate until that last element.
10551055
ConstructorBuilder earliest = constructorBuilder;
1056-
while (earliest.next != null) {
1057-
earliest = earliest.next as ConstructorBuilder;
1056+
Builder earliestBuilder = constructorBuilder;
1057+
while (earliestBuilder.next != null) {
1058+
earliestBuilder = earliestBuilder.next!;
1059+
if (earliestBuilder is ConstructorBuilder) {
1060+
earliest = earliestBuilder;
1061+
}
10581062
}
10591063

10601064
bool isRedirecting = false;

pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
T func<T>(T value) => value;
66
var funcValue = func;
77
int Function(int) f = funcValue.call; // Disallowed!
8+
int Function(int) g = funcValue.call<int>; // Disallowed!
9+
10+
test(Function f) {
11+
int Function(int) g = f.call<int>; // Disallowed!
12+
}
813

914
main() {}

pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart.strong.expect

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@ library /*isNonNullableByDefault*/;
66
// int Function(int) f = funcValue.call; // Disallowed!
77
// ^
88
//
9+
// pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:11:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Function'.
10+
// - 'Function' is from 'dart:core'.
11+
// Try changing the operand or remove the type arguments.
12+
// int Function(int) g = f.call<int>; // Disallowed!
13+
// ^
14+
//
915
import self as self;
1016
import "dart:core" as core;
1117

1218
static field <T extends core::Object? = dynamic>(T%) → T% funcValue = #C1;
1319
static field (core::int) → core::int f = let final Never #t1 = invalid-expression "pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:7:33: Error: A value of type 'T Function<T>(T)' can't be assigned to a variable of type 'int Function(int)'.
1420
int Function(int) f = funcValue.call; // Disallowed!
1521
^" in self::funcValue.call as{TypeError,ForNonNullableByDefault} (core::int) → core::int;
22+
static field (core::int) → core::int g = self::funcValue.call<core::int>;
1623
static method func<T extends core::Object? = dynamic>(self::func::T% value) → self::func::T%
1724
return value;
25+
static method test(core::Function f) → dynamic {
26+
(core::int) → core::int g = invalid-expression "pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:11:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Function'.
27+
- 'Function' is from 'dart:core'.
28+
Try changing the operand or remove the type arguments.
29+
int Function(int) g = f.call<int>; // Disallowed!
30+
^";
31+
}
1832
static method main() → dynamic {}
1933

2034
constants {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
T func<T>(T value) => value;
22
var funcValue = func;
33
int Function(int) f = funcValue.call;
4+
int Function(int) g = funcValue.call<int>;
5+
test(Function f) {}
46
main() {}

pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart.weak.expect

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@ library /*isNonNullableByDefault*/;
66
// int Function(int) f = funcValue.call; // Disallowed!
77
// ^
88
//
9+
// pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:11:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Function'.
10+
// - 'Function' is from 'dart:core'.
11+
// Try changing the operand or remove the type arguments.
12+
// int Function(int) g = f.call<int>; // Disallowed!
13+
// ^
14+
//
915
import self as self;
1016
import "dart:core" as core;
1117

1218
static field <T extends core::Object? = dynamic>(T%) → T% funcValue = #C1;
1319
static field (core::int) → core::int f = let final Never #t1 = invalid-expression "pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:7:33: Error: A value of type 'T Function<T>(T)' can't be assigned to a variable of type 'int Function(int)'.
1420
int Function(int) f = funcValue.call; // Disallowed!
1521
^" in self::funcValue.call as{TypeError,ForNonNullableByDefault} (core::int) → core::int;
22+
static field (core::int) → core::int g = self::funcValue.call<core::int>;
1623
static method func<T extends core::Object? = dynamic>(self::func::T% value) → self::func::T%
1724
return value;
25+
static method test(core::Function f) → dynamic {
26+
(core::int) → core::int g = invalid-expression "pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart:11:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Function'.
27+
- 'Function' is from 'dart:core'.
28+
Try changing the operand or remove the type arguments.
29+
int Function(int) g = f.call<int>; // Disallowed!
30+
^";
31+
}
1832
static method main() → dynamic {}
1933

2034
constants {

pkg/front_end/testcases/constructor_tearoffs/call_instantiation.dart.weak.outline.expect

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import "dart:core" as core;
44

55
static field <T extends core::Object? = dynamic>(T%) → T% funcValue;
66
static field (core::int) → core::int f;
7+
static field (core::int) → core::int g;
78
static method func<T extends core::Object? = dynamic>(self::func::T% value) → self::func::T%
89
;
10+
static method test(core::Function f) → dynamic
11+
;
912
static method main() → dynamic
1013
;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2021, 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+
test1(dynamic x) => x.foo<int>; // Error.
6+
test2(Never x) => x.foo<int>; // Error.
7+
test3(dynamic x) => x.toString<int>; // Error.
8+
test4(Never x) => x.toString<int>; // Error.
9+
10+
main() {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
6+
// Try changing the operand or remove the type arguments.
7+
// test1(dynamic x) => x.foo<int>; // Error.
8+
// ^
9+
//
10+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
11+
// Try changing the operand or remove the type arguments.
12+
// test2(Never x) => x.foo<int>; // Error.
13+
// ^
14+
//
15+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
16+
// Try changing the operand or remove the type arguments.
17+
// test3(dynamic x) => x.toString<int>; // Error.
18+
// ^
19+
//
20+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
21+
// Try changing the operand or remove the type arguments.
22+
// test4(Never x) => x.toString<int>; // Error.
23+
// ^
24+
//
25+
import self as self;
26+
27+
static method test1(dynamic x) → dynamic
28+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
29+
Try changing the operand or remove the type arguments.
30+
test1(dynamic x) => x.foo<int>; // Error.
31+
^";
32+
static method test2(Never x) → dynamic
33+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
34+
Try changing the operand or remove the type arguments.
35+
test2(Never x) => x.foo<int>; // Error.
36+
^";
37+
static method test3(dynamic x) → dynamic
38+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
39+
Try changing the operand or remove the type arguments.
40+
test3(dynamic x) => x.toString<int>; // Error.
41+
^";
42+
static method test4(Never x) → dynamic
43+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
44+
Try changing the operand or remove the type arguments.
45+
test4(Never x) => x.toString<int>; // Error.
46+
^";
47+
static method main() → dynamic {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
6+
// Try changing the operand or remove the type arguments.
7+
// test1(dynamic x) => x.foo<int>; // Error.
8+
// ^
9+
//
10+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
11+
// Try changing the operand or remove the type arguments.
12+
// test2(Never x) => x.foo<int>; // Error.
13+
// ^
14+
//
15+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
16+
// Try changing the operand or remove the type arguments.
17+
// test3(dynamic x) => x.toString<int>; // Error.
18+
// ^
19+
//
20+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
21+
// Try changing the operand or remove the type arguments.
22+
// test4(Never x) => x.toString<int>; // Error.
23+
// ^
24+
//
25+
import self as self;
26+
27+
static method test1(dynamic x) → dynamic
28+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
29+
Try changing the operand or remove the type arguments.
30+
test1(dynamic x) => x.foo<int>; // Error.
31+
^";
32+
static method test2(Never x) → dynamic
33+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
34+
Try changing the operand or remove the type arguments.
35+
test2(Never x) => x.foo<int>; // Error.
36+
^";
37+
static method test3(dynamic x) → dynamic
38+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
39+
Try changing the operand or remove the type arguments.
40+
test3(dynamic x) => x.toString<int>; // Error.
41+
^";
42+
static method test4(Never x) → dynamic
43+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
44+
Try changing the operand or remove the type arguments.
45+
test4(Never x) => x.toString<int>; // Error.
46+
^";
47+
static method main() → dynamic {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
test1(dynamic x) => x.foo<int>;
2+
test2(Never x) => x.foo<int>;
3+
test3(dynamic x) => x.toString<int>;
4+
test4(Never x) => x.toString<int>;
5+
main() {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
6+
// Try changing the operand or remove the type arguments.
7+
// test1(dynamic x) => x.foo<int>; // Error.
8+
// ^
9+
//
10+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
11+
// Try changing the operand or remove the type arguments.
12+
// test2(Never x) => x.foo<int>; // Error.
13+
// ^
14+
//
15+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
16+
// Try changing the operand or remove the type arguments.
17+
// test3(dynamic x) => x.toString<int>; // Error.
18+
// ^
19+
//
20+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
21+
// Try changing the operand or remove the type arguments.
22+
// test4(Never x) => x.toString<int>; // Error.
23+
// ^
24+
//
25+
import self as self;
26+
27+
static method test1(dynamic x) → dynamic
28+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
29+
Try changing the operand or remove the type arguments.
30+
test1(dynamic x) => x.foo<int>; // Error.
31+
^";
32+
static method test2(Never x) → dynamic
33+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
34+
Try changing the operand or remove the type arguments.
35+
test2(Never x) => x.foo<int>; // Error.
36+
^";
37+
static method test3(dynamic x) → dynamic
38+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
39+
Try changing the operand or remove the type arguments.
40+
test3(dynamic x) => x.toString<int>; // Error.
41+
^";
42+
static method test4(Never x) → dynamic
43+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
44+
Try changing the operand or remove the type arguments.
45+
test4(Never x) => x.toString<int>; // Error.
46+
^";
47+
static method main() → dynamic {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
4+
static method test1(dynamic x) → dynamic
5+
;
6+
static method test2(Never x) → dynamic
7+
;
8+
static method test3(dynamic x) → dynamic
9+
;
10+
static method test4(Never x) → dynamic
11+
;
12+
static method main() → dynamic
13+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
6+
// Try changing the operand or remove the type arguments.
7+
// test1(dynamic x) => x.foo<int>; // Error.
8+
// ^
9+
//
10+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
11+
// Try changing the operand or remove the type arguments.
12+
// test2(Never x) => x.foo<int>; // Error.
13+
// ^
14+
//
15+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
16+
// Try changing the operand or remove the type arguments.
17+
// test3(dynamic x) => x.toString<int>; // Error.
18+
// ^
19+
//
20+
// pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
21+
// Try changing the operand or remove the type arguments.
22+
// test4(Never x) => x.toString<int>; // Error.
23+
// ^
24+
//
25+
import self as self;
26+
27+
static method test1(dynamic x) → dynamic
28+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:5:26: Error: The static type of the explicit instantiation operand must be a generic function type but is 'dynamic'.
29+
Try changing the operand or remove the type arguments.
30+
test1(dynamic x) => x.foo<int>; // Error.
31+
^";
32+
static method test2(Never x) → dynamic
33+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:6:24: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
34+
Try changing the operand or remove the type arguments.
35+
test2(Never x) => x.foo<int>; // Error.
36+
^";
37+
static method test3(dynamic x) → dynamic
38+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:7:31: Error: The static type of the explicit instantiation operand must be a generic function type but is 'String Function()'.
39+
Try changing the operand or remove the type arguments.
40+
test3(dynamic x) => x.toString<int>; // Error.
41+
^";
42+
static method test4(Never x) → dynamic
43+
return invalid-expression "pkg/front_end/testcases/constructor_tearoffs/dynamic_explicit_instantiation.dart:8:29: Error: The static type of the explicit instantiation operand must be a generic function type but is 'Never'.
44+
Try changing the operand or remove the type arguments.
45+
test4(Never x) => x.toString<int>; // Error.
46+
^";
47+
static method main() → dynamic {}

pkg/front_end/testcases/constructor_tearoffs/explicit_new_as_unnamed.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,28 @@ class D {
2020
D(); // Error.
2121
}
2222

23+
class E1 {
24+
E1._();
25+
E1();
26+
factory E1.new() => E1._(); // Error.
27+
}
28+
29+
class E2 {
30+
E2._();
31+
factory E2.new() => E2._(); // Error.
32+
E2();
33+
}
34+
35+
class E3 {
36+
E3._();
37+
E3();
38+
factory E3.new() = E3._; // Error.
39+
}
40+
41+
class E4 {
42+
E4._();
43+
factory E4.new() = E4._;
44+
E4(); // Error.
45+
}
46+
2347
main() {}

0 commit comments

Comments
 (0)