Skip to content

Commit 599836a

Browse files
johnniwintherCommit Queue
authored and
Commit Queue
committed
[cfe,vm] Make patch parts into actual parts
This changes the VM patch files to use parts explicitly, making handling of patch libraries similar to regular libraries. Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try Change-Id: I6280d62edba3d12a1f77ae6a7f64e1e9b5d18227 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224949 Reviewed-by: Aske Simon Christensen <[email protected]> Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 4b134e4 commit 599836a

File tree

120 files changed

+7637
-458
lines changed

Some content is hidden

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

120 files changed

+7637
-458
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,24 +1708,11 @@ class KernelTarget extends TargetImplementation {
17081708
assert(library.importUri.isScheme("dart"));
17091709
List<Uri>? patches = uriTranslator.getDartPatches(library.importUri.path);
17101710
if (patches != null) {
1711-
SourceLibraryBuilder? first;
17121711
for (Uri patch in patches) {
1713-
if (first == null) {
1714-
first = library.loader.read(patch, -1,
1715-
fileUri: patch,
1716-
origin: library,
1717-
accessor: library) as SourceLibraryBuilder;
1718-
} else {
1719-
// If there's more than one patch file, it's interpreted as a part of
1720-
// the patch library.
1721-
SourceLibraryBuilder part = library.loader.read(patch, -1,
1722-
origin: library,
1723-
fileUri: patch,
1724-
accessor: library) as SourceLibraryBuilder;
1725-
first.parts.add(part);
1726-
first.partOffsets.add(-1);
1727-
part.partOfUri = first.importUri;
1728-
}
1712+
library.loader.read(patch, -1,
1713+
fileUri: patch,
1714+
origin: library,
1715+
accessor: library) as SourceLibraryBuilder;
17291716
}
17301717
}
17311718
}

pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
799799
// TODO(johnniwinther): Add a LibraryPartBuilder instead of using
800800
// [LibraryBuilder] to represent both libraries and parts.
801801
parts.add(loader.read(resolvedUri, charOffset,
802-
fileUri: newFileUri, accessor: this));
802+
origin: isPatch ? origin : null, fileUri: newFileUri, accessor: this));
803803
partOffsets.add(charOffset);
804804

805805
// TODO(ahe): [metadata] should be stored, evaluated, and added to [part].

pkg/front_end/testcases/general/multiple_class_patches/main.dart.weak.expect

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic {
1818
}
1919

2020
library /*isNonNullableByDefault*/;
21-
//
22-
// Problems in library:
23-
//
24-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib2.dart:9:7: Error: 'Class' is already declared in this scope.
25-
// class Class {
26-
// ^^^^^
27-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib1.dart:9:7: Context: Previous declaration of 'Class'.
28-
// class Class {
29-
// ^^^^^
30-
//
3121
import self as test;
3222
import "dart:_internal" as _in;
3323
import "dart:core" as core;
@@ -36,17 +26,6 @@ import "dart:_internal";
3626
import "dart:_internal";
3727

3828
@#C1
39-
class Class#1#1 extends core::Object { // from org-dartlang-testcase:///patch_lib2.dart
40-
synthetic constructor •() → test::Class#1#1
41-
: super core::Object::•()
42-
;
43-
@#C1
44-
method method2() → core::int
45-
return 87;
46-
@#C1
47-
method method3() → core::int
48-
return 123;
49-
}
5029
@#C1
5130
class Class extends core::Object {
5231
synthetic constructor •() → test::Class
@@ -55,10 +34,13 @@ class Class extends core::Object {
5534
@#C1
5635
method /* from org-dartlang-testcase:///patch_lib1.dart */ method1() → core::int
5736
return 42;
58-
external method method2() → core::int;
5937
@#C1
60-
method /* from org-dartlang-testcase:///patch_lib1.dart */ method3() → core::int
61-
return 321;
38+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method2() → core::int
39+
return 87;
40+
@#C1
41+
@#C1
42+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method3() → core::int
43+
return 123;
6244
}
6345

6446
constants {

pkg/front_end/testcases/general/multiple_class_patches/main.dart.weak.modular.expect

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic {
1818
}
1919

2020
library /*isNonNullableByDefault*/;
21-
//
22-
// Problems in library:
23-
//
24-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib2.dart:9:7: Error: 'Class' is already declared in this scope.
25-
// class Class {
26-
// ^^^^^
27-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib1.dart:9:7: Context: Previous declaration of 'Class'.
28-
// class Class {
29-
// ^^^^^
30-
//
3121
import self as test;
3222
import "dart:_internal" as _in;
3323
import "dart:core" as core;
@@ -36,17 +26,6 @@ import "dart:_internal";
3626
import "dart:_internal";
3727

3828
@#C1
39-
class Class#1#1 extends core::Object { // from org-dartlang-testcase:///patch_lib2.dart
40-
synthetic constructor •() → test::Class#1#1
41-
: super core::Object::•()
42-
;
43-
@#C1
44-
method method2() → core::int
45-
return 87;
46-
@#C1
47-
method method3() → core::int
48-
return 123;
49-
}
5029
@#C1
5130
class Class extends core::Object {
5231
synthetic constructor •() → test::Class
@@ -55,10 +34,13 @@ class Class extends core::Object {
5534
@#C1
5635
method /* from org-dartlang-testcase:///patch_lib1.dart */ method1() → core::int
5736
return 42;
58-
external method method2() → core::int;
5937
@#C1
60-
method /* from org-dartlang-testcase:///patch_lib1.dart */ method3() → core::int
61-
return 321;
38+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method2() → core::int
39+
return 87;
40+
@#C1
41+
@#C1
42+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method3() → core::int
43+
return 123;
6244
}
6345

6446
constants {

pkg/front_end/testcases/general/multiple_class_patches/main.dart.weak.outline.expect

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic
99
;
1010

1111
library /*isNonNullableByDefault*/;
12-
//
13-
// Problems in library:
14-
//
15-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib2.dart:9:7: Error: 'Class' is already declared in this scope.
16-
// class Class {
17-
// ^^^^^
18-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib1.dart:9:7: Context: Previous declaration of 'Class'.
19-
// class Class {
20-
// ^^^^^
21-
//
2212
import self as self2;
2313
import "dart:_internal" as _in;
2414
import "dart:core" as core;
@@ -27,33 +17,25 @@ import "dart:_internal";
2717
import "dart:_internal";
2818

2919
@_in::patch
30-
class Class#1#1 extends core::Object { // from org-dartlang-testcase:///patch_lib2.dart
31-
synthetic constructor •() → self2::Class#1#1
32-
;
33-
@_in::patch
34-
method method2() → core::int
35-
;
36-
@_in::patch
37-
method method3() → core::int
38-
;
39-
}
4020
@_in::patch
4121
class Class extends core::Object {
4222
synthetic constructor •() → self2::Class
4323
;
4424
@_in::patch
4525
external method method1() → core::int;
26+
@_in::patch
4627
external method method2() → core::int;
4728
@_in::patch
29+
@_in::patch
4830
external method method3() → core::int;
4931
}
5032

5133

5234
Extra constant evaluation status:
53-
Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib2.dart:8:2 -> InstanceConstant(const _Patch{})
54-
Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib2.dart:10:4 -> InstanceConstant(const _Patch{})
55-
Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib2.dart:13:4 -> InstanceConstant(const _Patch{})
35+
Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:7:23 -> InstanceConstant(const _Patch{})
5636
Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:7:23 -> InstanceConstant(const _Patch{})
5737
Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:8:20 -> InstanceConstant(const _Patch{})
38+
Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:8:20 -> InstanceConstant(const _Patch{})
39+
Evaluated: StaticGet @ (unknown position in org-dartlang-testcase:///origin_lib.dart) -> InstanceConstant(const _Patch{})
5840
Evaluated: StaticGet @ (unknown position in org-dartlang-testcase:///origin_lib.dart) -> InstanceConstant(const _Patch{})
5941
Extra constant evaluation: evaluated: 6, effectively constant: 6

pkg/front_end/testcases/general/multiple_class_patches/main.dart.weak.transformed.expect

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ static method expect(dynamic expected, dynamic actual) → dynamic {
1818
}
1919

2020
library /*isNonNullableByDefault*/;
21-
//
22-
// Problems in library:
23-
//
24-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib2.dart:9:7: Error: 'Class' is already declared in this scope.
25-
// class Class {
26-
// ^^^^^
27-
// pkg/front_end/testcases/general/multiple_class_patches/patch_lib1.dart:9:7: Context: Previous declaration of 'Class'.
28-
// class Class {
29-
// ^^^^^
30-
//
3121
import self as test;
3222
import "dart:_internal" as _in;
3323
import "dart:core" as core;
@@ -36,17 +26,6 @@ import "dart:_internal";
3626
import "dart:_internal";
3727

3828
@#C1
39-
class Class#1#1 extends core::Object { // from org-dartlang-testcase:///patch_lib2.dart
40-
synthetic constructor •() → test::Class#1#1
41-
: super core::Object::•()
42-
;
43-
@#C1
44-
method method2() → core::int
45-
return 87;
46-
@#C1
47-
method method3() → core::int
48-
return 123;
49-
}
5029
@#C1
5130
class Class extends core::Object {
5231
synthetic constructor •() → test::Class
@@ -55,10 +34,13 @@ class Class extends core::Object {
5534
@#C1
5635
method /* from org-dartlang-testcase:///patch_lib1.dart */ method1() → core::int
5736
return 42;
58-
external method method2() → core::int;
5937
@#C1
60-
method /* from org-dartlang-testcase:///patch_lib1.dart */ method3() → core::int
61-
return 321;
38+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method2() → core::int
39+
return 87;
40+
@#C1
41+
@#C1
42+
method /* from org-dartlang-testcase:///patch_lib2.dart */ method3() → core::int
43+
return 123;
6244
}
6345

6446
constants {

pkg/front_end/testcases/nnbd/platform_nonnullable_fields/main.dart.strong.expect

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ library /*isNonNullableByDefault*/;
1313
//
1414
// Problems in library:
1515
//
16-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
16+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:34:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
1717
// static int staticField;
1818
// ^^^^^^^^^^^
1919
//
20-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:30:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
20+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
2121
// int field;
2222
// ^^^^^
2323
//
2424
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/origin_lib.dart:8:3: Error: This constructor should initialize field 'field' because its type 'int' doesn't allow null.
2525
// Class2.constructor1();
2626
// ^
27-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:37:7: Context: 'field' is defined here.
27+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:39:7: Context: 'field' is defined here.
2828
// int field;
2929
// ^^^^^
3030
//
@@ -34,6 +34,7 @@ import "dart:core" as core;
3434

3535
import "dart:_internal";
3636

37+
part patch_lib2.dart;
3738
@#C1
3839
class Class1 extends core::Object {
3940
field core::int field = null /* from org-dartlang-testcase:///patch_lib2.dart */;

pkg/front_end/testcases/nnbd/platform_nonnullable_fields/main.dart.strong.transformed.expect

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ library /*isNonNullableByDefault*/;
1313
//
1414
// Problems in library:
1515
//
16-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
16+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:34:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
1717
// static int staticField;
1818
// ^^^^^^^^^^^
1919
//
20-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:30:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
20+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
2121
// int field;
2222
// ^^^^^
2323
//
2424
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/origin_lib.dart:8:3: Error: This constructor should initialize field 'field' because its type 'int' doesn't allow null.
2525
// Class2.constructor1();
2626
// ^
27-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:37:7: Context: 'field' is defined here.
27+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:39:7: Context: 'field' is defined here.
2828
// int field;
2929
// ^^^^^
3030
//
@@ -34,6 +34,7 @@ import "dart:core" as core;
3434

3535
import "dart:_internal";
3636

37+
part patch_lib2.dart;
3738
@#C1
3839
class Class1 extends core::Object {
3940
field core::int field = null /* from org-dartlang-testcase:///patch_lib2.dart */;

pkg/front_end/testcases/nnbd/platform_nonnullable_fields/main.dart.weak.expect

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ library /*isNonNullableByDefault*/;
1313
//
1414
// Problems in library:
1515
//
16-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
16+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:34:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
1717
// static int staticField;
1818
// ^^^^^^^^^^^
1919
//
20-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:30:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
20+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
2121
// int field;
2222
// ^^^^^
2323
//
2424
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/origin_lib.dart:8:3: Error: This constructor should initialize field 'field' because its type 'int' doesn't allow null.
2525
// Class2.constructor1();
2626
// ^
27-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:37:7: Context: 'field' is defined here.
27+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:39:7: Context: 'field' is defined here.
2828
// int field;
2929
// ^^^^^
3030
//
@@ -34,6 +34,7 @@ import "dart:core" as core;
3434

3535
import "dart:_internal";
3636

37+
part patch_lib2.dart;
3738
@#C1
3839
class Class1 extends core::Object {
3940
field core::int field = null /* from org-dartlang-testcase:///patch_lib2.dart */;

pkg/front_end/testcases/nnbd/platform_nonnullable_fields/main.dart.weak.modular.expect

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ library /*isNonNullableByDefault*/;
1313
//
1414
// Problems in library:
1515
//
16-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
16+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:34:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
1717
// static int staticField;
1818
// ^^^^^^^^^^^
1919
//
20-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:30:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
20+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:7: Error: Field 'field' should be initialized because its type 'int' doesn't allow null.
2121
// int field;
2222
// ^^^^^
2323
//
2424
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/origin_lib.dart:8:3: Error: This constructor should initialize field 'field' because its type 'int' doesn't allow null.
2525
// Class2.constructor1();
2626
// ^
27-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:37:7: Context: 'field' is defined here.
27+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:39:7: Context: 'field' is defined here.
2828
// int field;
2929
// ^^^^^
3030
//
@@ -34,6 +34,7 @@ import "dart:core" as core;
3434

3535
import "dart:_internal";
3636

37+
part patch_lib2.dart;
3738
@#C1
3839
class Class1 extends core::Object {
3940
field core::int field = null /* from org-dartlang-testcase:///patch_lib2.dart */;

pkg/front_end/testcases/nnbd/platform_nonnullable_fields/main.dart.weak.outline.expect

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
1010
//
1111
// Problems in library:
1212
//
13-
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:32:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
13+
// pkg/front_end/testcases/nnbd/platform_nonnullable_fields/patch_lib2.dart:34:14: Error: Field 'staticField' should be initialized because its type 'int' doesn't allow null.
1414
// static int staticField;
1515
// ^^^^^^^^^^^
1616
//
@@ -20,6 +20,7 @@ import "dart:core" as core;
2020

2121
import "dart:_internal";
2222

23+
part patch_lib2.dart;
2324
@_in::patch
2425
class Class1 extends core::Object {
2526
field core::int field /* from org-dartlang-testcase:///patch_lib2.dart */;

0 commit comments

Comments
 (0)