Skip to content

Commit 991fbf4

Browse files
chloestefantsovaCommit Queue
authored and
Commit Queue
committed
[cfe] Avoid concurrent modification in delayed action processing
Closes flutter/flutter#148611 Change-Id: Idb091df6d771f286428809326e65ac6203f09d49 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368301 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 9a7e07a commit 991fbf4

9 files changed

+150
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,8 +1621,11 @@ class BodyBuilder extends StackListenerImpl
16211621
void _unaliasTypeAliasedConstructorInvocations(
16221622
List<TypeAliasedConstructorInvocation>
16231623
typeAliasedConstructorInvocations) {
1624-
for (TypeAliasedConstructorInvocation invocation
1625-
in typeAliasedConstructorInvocations) {
1624+
List<TypeAliasedConstructorInvocation> invocations = [
1625+
...typeAliasedConstructorInvocations
1626+
];
1627+
typeAliasedConstructorInvocations.clear();
1628+
for (TypeAliasedConstructorInvocation invocation in invocations) {
16261629
assert(invocation.hasBeenInferred || isOrphaned(invocation),
16271630
"Node $invocation has not been inferred.");
16281631

pkg/front_end/test/coverage_suite.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ const Map<String, double> _expect = {
268268
"package:front_end/src/fasta/type_inference/standard_bounds.dart":
269269
71.42857142857143,
270270
"package:front_end/src/fasta/type_inference/type_constraint_gatherer.dart":
271-
61.328125,
271+
60,
272272
"package:front_end/src/fasta/type_inference/type_demotion.dart":
273273
77.77777777777779,
274274
"package:front_end/src/fasta/type_inference/type_inference_engine.dart":
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2024, 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+
// For context see https://github.com/flutter/flutter/issues/148611.
6+
7+
class P<T> {
8+
const P(T t);
9+
}
10+
11+
class A<X> extends P<X> {
12+
const A.foo(X x) : super(x);
13+
A(super.x) : assert(const F.foo("foo") == const A.foo("foo"));
14+
}
15+
16+
typedef F<Y> = A<Y>;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef F<Y extends core::Object? = dynamic> = self::A<Y%>;
6+
class P<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
7+
const constructor •(self::P::T% t) → self::P<self::P::T%>
8+
: super core::Object::•()
9+
;
10+
}
11+
class A<X extends core::Object? = dynamic> extends self::P<self::A::X%> /*hasConstConstructor*/ {
12+
const constructor foo(self::A::X% x) → self::A<self::A::X%>
13+
: super self::P::•(x)
14+
;
15+
constructor •(self::A::X% x) → self::A<self::A::X%>
16+
: assert(#C1 =={core::Object::==}{(core::Object) → core::bool} #C1), super self::P::•(x)
17+
;
18+
}
19+
20+
constants {
21+
#C1 = self::A<core::String> {}
22+
}
23+
24+
25+
Constructor coverage from constants:
26+
org-dartlang-testcase:///flutter_issue148611.dart:
27+
- A.foo (from org-dartlang-testcase:///flutter_issue148611.dart:12:9)
28+
- P. (from org-dartlang-testcase:///flutter_issue148611.dart:8:9)
29+
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef F<Y extends core::Object? = dynamic> = self::A<Y%>;
6+
class P<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
7+
const constructor •(self::P::T% t) → self::P<self::P::T%>
8+
: super core::Object::•()
9+
;
10+
}
11+
class A<X extends core::Object? = dynamic> extends self::P<self::A::X%> /*hasConstConstructor*/ {
12+
const constructor foo(self::A::X% x) → self::A<self::A::X%>
13+
: super self::P::•(x)
14+
;
15+
constructor •(self::A::X% x) → self::A<self::A::X%>
16+
: assert(#C1 =={core::Object::==}{(core::Object) → core::bool} #C1), super self::P::•(x)
17+
;
18+
}
19+
20+
constants {
21+
#C1 = self::A<core::String> {}
22+
}
23+
24+
25+
Constructor coverage from constants:
26+
org-dartlang-testcase:///flutter_issue148611.dart:
27+
- A.foo (from org-dartlang-testcase:///flutter_issue148611.dart:12:9)
28+
- P. (from org-dartlang-testcase:///flutter_issue148611.dart:8:9)
29+
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef F<Y extends core::Object? = dynamic> = self::A<Y%>;
6+
class P<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
7+
const constructor •(self::P::T% t) → self::P<self::P::T%>
8+
: super core::Object::•()
9+
;
10+
}
11+
class A<X extends core::Object? = dynamic> extends self::P<self::A::X%> /*hasConstConstructor*/ {
12+
const constructor foo(self::A::X% x) → self::A<self::A::X%>
13+
: super self::P::•(x)
14+
;
15+
constructor •(self::A::X% x) → self::A<self::A::X%>
16+
;
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef F<Y extends core::Object? = dynamic> = self::A<Y%>;
6+
class P<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
7+
const constructor •(self::P::T% t) → self::P<self::P::T%>
8+
: super core::Object::•()
9+
;
10+
}
11+
class A<X extends core::Object? = dynamic> extends self::P<self::A::X%> /*hasConstConstructor*/ {
12+
const constructor foo(self::A::X% x) → self::A<self::A::X%>
13+
: super self::P::•(x)
14+
;
15+
constructor •(self::A::X% x) → self::A<self::A::X%>
16+
: assert(#C1 =={core::Object::==}{(core::Object) → core::bool} #C1), super self::P::•(x)
17+
;
18+
}
19+
20+
constants {
21+
#C1 = self::A<core::String> {}
22+
}
23+
24+
Extra constant evaluation status:
25+
Evaluated: EqualsCall @ org-dartlang-testcase:///flutter_issue148611.dart:13:42 -> BoolConstant(true)
26+
Extra constant evaluation: evaluated: 3, effectively constant: 1
27+
28+
29+
Constructor coverage from constants:
30+
org-dartlang-testcase:///flutter_issue148611.dart:
31+
- A.foo (from org-dartlang-testcase:///flutter_issue148611.dart:12:9)
32+
- P. (from org-dartlang-testcase:///flutter_issue148611.dart:8:9)
33+
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class P<T> {
2+
const P(T t);
3+
}
4+
5+
class A<X> extends P<X> {
6+
const A.foo(X x) : super(x);
7+
A(super.x) : assert(const F.foo("foo") == const A.foo("foo"));
8+
}
9+
10+
typedef F<Y> = A<Y>;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class A<X> extends P<X> {
2+
A(super.x) : assert(const F.foo("foo") == const A.foo("foo"));
3+
const A.foo(X x) : super(x);
4+
}
5+
6+
class P<T> {
7+
const P(T t);
8+
}
9+
10+
typedef F<Y> = A<Y>;

0 commit comments

Comments
 (0)