Skip to content

Commit 6fbb923

Browse files
committed
Version 2.16.2
* Cherry-pick refs/changes/41/238041/1 to stable * Cherry-pick a999d21 to stable
2 parents 0180af2 + 967a84f commit 6fbb923

File tree

58 files changed

+1963
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1963
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.16.2 - 2022-03-24
2+
3+
This is a patch release that fixes a dart2js crash when building some Flutter
4+
web apps (issue [#47916][]).
5+
6+
[#47916]: https://github.com/dart-lang/sdk/issues/47916
7+
18
## 2.16.1 - 2022-02-09
29

310
This is a patch release that fixes an AOT precompiler crash when building some

pkg/front_end/lib/src/fasta/builder/factory_builder.dart

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,14 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
396396
inferrer.helper = library.loader.createBodyBuilderForOutlineExpression(
397397
library, classBuilder, this, classBuilder!.scope, fileUri);
398398
Builder? targetBuilder = redirectionTarget.target;
399+
if (targetBuilder is MemberBuilder) {
400+
// Ensure that target has been built.
401+
targetBuilder.buildOutlineExpressions(
402+
targetBuilder.library as SourceLibraryBuilder,
403+
coreTypes,
404+
delayedActionPerformers,
405+
synthesizedFunctionNodes);
406+
}
399407
if (targetBuilder is FunctionBuilder) {
400408
target = targetBuilder.member;
401409
} else if (targetBuilder is DillMemberBuilder) {
@@ -446,13 +454,33 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
446454
new RedirectingFactoryBody(target, typeArguments, function);
447455
function.body!.parent = function;
448456
}
449-
if (_factoryTearOff != null &&
450-
(target is Constructor || target is Procedure && target.isFactory)) {
451-
synthesizedFunctionNodes.add(buildRedirectingFactoryTearOffBody(
452-
_factoryTearOff!,
453-
target!,
454-
typeArguments ?? [],
455-
_tearOffTypeParameters!));
457+
if (_factoryTearOff != null) {
458+
Set<Procedure> seenTargets = {};
459+
while (target is Procedure && target.isRedirectingFactory) {
460+
if (!seenTargets.add(target)) {
461+
// Cyclic dependency.
462+
target = null;
463+
break;
464+
}
465+
RedirectingFactoryBody body =
466+
target.function.body as RedirectingFactoryBody;
467+
if (typeArguments != null) {
468+
Substitution substitution = Substitution.fromPairs(
469+
target.function.typeParameters, typeArguments);
470+
typeArguments =
471+
body.typeArguments?.map(substitution.substituteType).toList();
472+
} else {
473+
typeArguments = body.typeArguments;
474+
}
475+
target = body.target;
476+
}
477+
if (target is Constructor || target is Procedure && target.isFactory) {
478+
synthesizedFunctionNodes.add(buildRedirectingFactoryTearOffBody(
479+
_factoryTearOff!,
480+
target!,
481+
typeArguments ?? [],
482+
_tearOffTypeParameters!));
483+
}
456484
}
457485
if (isConst && isPatch) {
458486
_finishPatch();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2022, 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+
abstract class A {
6+
const factory A() = B;
7+
}
8+
9+
abstract class B implements A {
10+
const factory B() = C;
11+
}
12+
13+
class C implements B {
14+
const C();
15+
}
16+
17+
main() {
18+
A.new;
19+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
abstract class A extends core::Object {
6+
static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
7+
static factory •() → self::A
8+
return self::B::•();
9+
static method _#new#tearOff() → self::A
10+
return new self::C::•();
11+
}
12+
abstract class B extends core::Object implements self::A {
13+
static final field dynamic _redirecting# = <dynamic>[#C2]/*isLegacy*/;
14+
static factory •() → self::B
15+
return new self::C::•();
16+
static method _#new#tearOff() → self::B
17+
return new self::C::•();
18+
}
19+
class C extends core::Object implements self::B /*hasConstConstructor*/ {
20+
const constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
static method _#new#tearOff() → self::C
24+
return new self::C::•();
25+
}
26+
static method main() → dynamic {
27+
#C3;
28+
}
29+
30+
constants {
31+
#C1 = constructor-tearoff self::A::•
32+
#C2 = constructor-tearoff self::B::•
33+
#C3 = static-tearoff self::A::_#new#tearOff
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
abstract class A extends core::Object {
6+
static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
7+
static factory •() → self::A
8+
return self::B::•();
9+
static method _#new#tearOff() → self::A
10+
return new self::C::•();
11+
}
12+
abstract class B extends core::Object implements self::A {
13+
static final field dynamic _redirecting# = <dynamic>[#C2]/*isLegacy*/;
14+
static factory •() → self::B
15+
return new self::C::•();
16+
static method _#new#tearOff() → self::B
17+
return new self::C::•();
18+
}
19+
class C extends core::Object implements self::B /*hasConstConstructor*/ {
20+
const constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
static method _#new#tearOff() → self::C
24+
return new self::C::•();
25+
}
26+
static method main() → dynamic {
27+
#C3;
28+
}
29+
30+
constants {
31+
#C1 = constructor-tearoff self::A::•
32+
#C2 = constructor-tearoff self::B::•
33+
#C3 = static-tearoff self::A::_#new#tearOff
34+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
abstract class A {
2+
const factory A() = B;
3+
}
4+
5+
abstract class B implements A {
6+
const factory B() = C;
7+
}
8+
9+
class C implements B {
10+
const C();
11+
}
12+
13+
main() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
abstract class A {
2+
const factory A() = B;
3+
}
4+
5+
abstract class B implements A {
6+
const factory B() = C;
7+
}
8+
9+
class C implements B {
10+
const C();
11+
}
12+
13+
main() {}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
abstract class A extends core::Object {
6+
static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
7+
static factory •() → self::A
8+
return self::B::•();
9+
static method _#new#tearOff() → self::A
10+
return new self::C::•();
11+
}
12+
abstract class B extends core::Object implements self::A {
13+
static final field dynamic _redirecting# = <dynamic>[#C2]/*isLegacy*/;
14+
static factory •() → self::B
15+
return new self::C::•();
16+
static method _#new#tearOff() → self::B
17+
return new self::C::•();
18+
}
19+
class C extends core::Object implements self::B /*hasConstConstructor*/ {
20+
const constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
static method _#new#tearOff() → self::C
24+
return new self::C::•();
25+
}
26+
static method main() → dynamic {
27+
#C3;
28+
}
29+
30+
constants {
31+
#C1 = constructor-tearoff self::A::•
32+
#C2 = constructor-tearoff self::B::•
33+
#C3 = static-tearoff self::A::_#new#tearOff
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
abstract class A extends core::Object {
6+
static final field dynamic _redirecting# = <dynamic>[#C1]/*isLegacy*/;
7+
static factory •() → self::A
8+
return self::B::•();
9+
static method _#new#tearOff() → self::A
10+
return new self::C::•();
11+
}
12+
abstract class B extends core::Object implements self::A {
13+
static final field dynamic _redirecting# = <dynamic>[#C2]/*isLegacy*/;
14+
static factory •() → self::B
15+
return new self::C::•();
16+
static method _#new#tearOff() → self::B
17+
return new self::C::•();
18+
}
19+
class C extends core::Object implements self::B /*hasConstConstructor*/ {
20+
const constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
static method _#new#tearOff() → self::C
24+
return new self::C::•();
25+
}
26+
static method main() → dynamic {
27+
#C3;
28+
}
29+
30+
constants {
31+
#C1 = constructor-tearoff self::A::•
32+
#C2 = constructor-tearoff self::B::•
33+
#C3 = static-tearoff self::A::_#new#tearOff
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
abstract class A extends core::Object {
6+
static final field dynamic _redirecting# = <dynamic>[self::A::•]/*isLegacy*/;
7+
static factory •() → self::A
8+
return self::B::•();
9+
static method _#new#tearOff() → self::A
10+
return new self::C::•();
11+
}
12+
abstract class B extends core::Object implements self::A {
13+
static final field dynamic _redirecting# = <dynamic>[self::B::•]/*isLegacy*/;
14+
static factory •() → self::B
15+
return new self::C::•();
16+
static method _#new#tearOff() → self::B
17+
return new self::C::•();
18+
}
19+
class C extends core::Object implements self::B /*hasConstConstructor*/ {
20+
const constructor •() → self::C
21+
: super core::Object::•()
22+
;
23+
static method _#new#tearOff() → self::C
24+
return new self::C::•();
25+
}
26+
static method main() → dynamic
27+
;
28+
29+
30+
Extra constant evaluation status:
31+
Evaluated: ConstructorTearOff @ org-dartlang-testcase:///issue47916.dart:5:16 -> ConstructorTearOffConstant(A.)
32+
Evaluated: ConstructorTearOff @ org-dartlang-testcase:///issue47916.dart:9:16 -> ConstructorTearOffConstant(B.)
33+
Extra constant evaluation: evaluated: 9, effectively constant: 2

0 commit comments

Comments
 (0)