diff --git a/DEPS b/DEPS index c646483fdcf..ffeacc6b6b9 100644 --- a/DEPS +++ b/DEPS @@ -469,7 +469,7 @@ deps = { "packages": [ { "package": "dart/cfe/dart2js_dills", - "version": "binary_version:41_2", + "version": "binary_version:42", } ], "dep_type": "cipd", diff --git a/pkg/front_end/lib/src/fasta/builder/field_builder.dart b/pkg/front_end/lib/src/fasta/builder/field_builder.dart index 9e1d7c20dbe..5cb9fc05b9c 100644 --- a/pkg/front_end/lib/src/fasta/builder/field_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/field_builder.dart @@ -674,12 +674,14 @@ abstract class AbstractLateFieldEncoding implements FieldEncoding { new Field(null, fileUri: fileUri, reference: referenceFrom?.reference) ..fileOffset = charOffset ..fileEndOffset = charEndOffset - ..isNonNullableByDefault = true; + ..isNonNullableByDefault = true + ..isInternalImplementation = true; _lateIsSetField = new Field(null, fileUri: fileUri, reference: lateIsSetReferenceFrom?.reference) ..fileOffset = charOffset ..fileEndOffset = charEndOffset - ..isNonNullableByDefault = true; + ..isNonNullableByDefault = true + ..isInternalImplementation = true; _lateGetter = new Procedure( null, ProcedureKind.Getter, new FunctionNode(null), fileUri: fileUri, reference: getterReferenceFrom?.reference) diff --git a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart index 40f72852ae9..93becfc7252 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart @@ -155,11 +155,11 @@ class DillClassMember extends BuilderClassMember { @override bool get isSourceDeclaration => false; - // TODO(johnniwinther): This should be `true` for fields added for late - // lowering. Currently not needed because these fields are private and we only - // use this property while checking implementation of abstract members. @override - bool get isInternalImplementation => false; + bool get isInternalImplementation { + Member member = memberBuilder.member; + return member is Field && member.isInternalImplementation; + } @override bool get isProperty => diff --git a/pkg/front_end/test/spell_checking_list_tests.txt b/pkg/front_end/test/spell_checking_list_tests.txt index 7add1d4be82..44f1f7775b5 100644 --- a/pkg/front_end/test/spell_checking_list_tests.txt +++ b/pkg/front_end/test/spell_checking_list_tests.txt @@ -275,6 +275,7 @@ ioo isolate isolates issue41210b +issue41436c iter joo jumped diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c.dart b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c.dart new file mode 100644 index 00000000000..ec85c08b7d6 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2020, 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. + +import 'issue41436c_lib.dart'; + +class C extends B {} + +main() { + new C(); +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart new file mode 100644 index 00000000000..d7adb144358 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2020, 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. + +abstract class A { + late int x; +} + +class B implements A { + int x = 3; +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.outline.expect b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.outline.expect new file mode 100644 index 00000000000..de879f18d45 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.outline.expect @@ -0,0 +1,34 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "issue41436c_lib.dart" as iss; +import "dart:core" as core; + +import "org-dartlang-testcase:///issue41436c_lib.dart"; + +class C extends iss::B { + synthetic constructor •() → self::C + ; + no-such-method-forwarder get /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x() → core::int? + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#_#A#x, 1, const [], const [], core::Map::unmodifiable(const {}))) as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?; + no-such-method-forwarder set /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x(core::int? value) → void + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#_#A#x=, 2, const [], core::List::unmodifiable([value]), core::Map::unmodifiable(const {}))); +} +static method main() → dynamic + ; + +library /*isNonNullableByDefault*/; +import self as iss; +import "dart:core" as core; + +abstract class A extends core::Object { + field core::int? _#A#x; + synthetic constructor •() → iss::A + ; + get x() → core::int; + set x(core::int #t1) → void; +} +class B extends core::Object implements iss::A { + field core::int x; + synthetic constructor •() → iss::B + ; +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.expect b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.expect new file mode 100644 index 00000000000..05bf5e38b58 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.expect @@ -0,0 +1,49 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "issue41436c_lib.dart" as iss; +import "dart:core" as core; + +import "org-dartlang-testcase:///issue41436c_lib.dart"; + +class C extends iss::B { + synthetic constructor •() → self::C + : super iss::B::•() + ; + no-such-method-forwarder get /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x() → core::int? + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 1, #C2, #C3, core::Map::unmodifiable(#C4))) as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?; + no-such-method-forwarder set /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x(core::int? value) → void + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 2, #C2, core::List::unmodifiable([value]), core::Map::unmodifiable(#C4))); +} +static method main() → dynamic { + new self::C::•(); +} + +library /*isNonNullableByDefault*/; +import self as iss; +import "dart:core" as core; +import "dart:_internal" as _in; + +abstract class A extends core::Object { + field core::int? _#A#x = null; + synthetic constructor •() → iss::A + : super core::Object::•() + ; + get x() → core::int + return let final core::int? #t1 = this.{iss::A::_#A#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; + set x(core::int #t2) → void + this.{iss::A::_#A#x} = #t2; +} +class B extends core::Object implements iss::A { + field core::int x = 3; + synthetic constructor •() → iss::B + : super core::Object::•() + ; +} + +constants { + #C1 = #org-dartlang-testcase:///issue41436c.dart::_#A#x + #C2 = [] + #C3 = [] + #C4 = core::_ImmutableMap {_kvPairs:#C3} + #C5 = #org-dartlang-testcase:///issue41436c.dart::_#A#x= +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.transformed.expect b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.transformed.expect new file mode 100644 index 00000000000..05bf5e38b58 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.strong.transformed.expect @@ -0,0 +1,49 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "issue41436c_lib.dart" as iss; +import "dart:core" as core; + +import "org-dartlang-testcase:///issue41436c_lib.dart"; + +class C extends iss::B { + synthetic constructor •() → self::C + : super iss::B::•() + ; + no-such-method-forwarder get /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x() → core::int? + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 1, #C2, #C3, core::Map::unmodifiable(#C4))) as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?; + no-such-method-forwarder set /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x(core::int? value) → void + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 2, #C2, core::List::unmodifiable([value]), core::Map::unmodifiable(#C4))); +} +static method main() → dynamic { + new self::C::•(); +} + +library /*isNonNullableByDefault*/; +import self as iss; +import "dart:core" as core; +import "dart:_internal" as _in; + +abstract class A extends core::Object { + field core::int? _#A#x = null; + synthetic constructor •() → iss::A + : super core::Object::•() + ; + get x() → core::int + return let final core::int? #t1 = this.{iss::A::_#A#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; + set x(core::int #t2) → void + this.{iss::A::_#A#x} = #t2; +} +class B extends core::Object implements iss::A { + field core::int x = 3; + synthetic constructor •() → iss::B + : super core::Object::•() + ; +} + +constants { + #C1 = #org-dartlang-testcase:///issue41436c.dart::_#A#x + #C2 = [] + #C3 = [] + #C4 = core::_ImmutableMap {_kvPairs:#C3} + #C5 = #org-dartlang-testcase:///issue41436c.dart::_#A#x= +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.expect b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.expect new file mode 100644 index 00000000000..05bf5e38b58 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.expect @@ -0,0 +1,49 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "issue41436c_lib.dart" as iss; +import "dart:core" as core; + +import "org-dartlang-testcase:///issue41436c_lib.dart"; + +class C extends iss::B { + synthetic constructor •() → self::C + : super iss::B::•() + ; + no-such-method-forwarder get /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x() → core::int? + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 1, #C2, #C3, core::Map::unmodifiable(#C4))) as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?; + no-such-method-forwarder set /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x(core::int? value) → void + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 2, #C2, core::List::unmodifiable([value]), core::Map::unmodifiable(#C4))); +} +static method main() → dynamic { + new self::C::•(); +} + +library /*isNonNullableByDefault*/; +import self as iss; +import "dart:core" as core; +import "dart:_internal" as _in; + +abstract class A extends core::Object { + field core::int? _#A#x = null; + synthetic constructor •() → iss::A + : super core::Object::•() + ; + get x() → core::int + return let final core::int? #t1 = this.{iss::A::_#A#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; + set x(core::int #t2) → void + this.{iss::A::_#A#x} = #t2; +} +class B extends core::Object implements iss::A { + field core::int x = 3; + synthetic constructor •() → iss::B + : super core::Object::•() + ; +} + +constants { + #C1 = #org-dartlang-testcase:///issue41436c.dart::_#A#x + #C2 = [] + #C3 = [] + #C4 = core::_ImmutableMap {_kvPairs:#C3} + #C5 = #org-dartlang-testcase:///issue41436c.dart::_#A#x= +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.transformed.expect b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.transformed.expect new file mode 100644 index 00000000000..05bf5e38b58 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/issue41436c_lib.dart.weak.transformed.expect @@ -0,0 +1,49 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "issue41436c_lib.dart" as iss; +import "dart:core" as core; + +import "org-dartlang-testcase:///issue41436c_lib.dart"; + +class C extends iss::B { + synthetic constructor •() → self::C + : super iss::B::•() + ; + no-such-method-forwarder get /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x() → core::int? + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C1, 1, #C2, #C3, core::Map::unmodifiable(#C4))) as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?; + no-such-method-forwarder set /* from org-dartlang-testcase:///issue41436c_lib.dart */ _#A#x(core::int? value) → void + return this.{core::Object::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 2, #C2, core::List::unmodifiable([value]), core::Map::unmodifiable(#C4))); +} +static method main() → dynamic { + new self::C::•(); +} + +library /*isNonNullableByDefault*/; +import self as iss; +import "dart:core" as core; +import "dart:_internal" as _in; + +abstract class A extends core::Object { + field core::int? _#A#x = null; + synthetic constructor •() → iss::A + : super core::Object::•() + ; + get x() → core::int + return let final core::int? #t1 = this.{iss::A::_#A#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; + set x(core::int #t2) → void + this.{iss::A::_#A#x} = #t2; +} +class B extends core::Object implements iss::A { + field core::int x = 3; + synthetic constructor •() → iss::B + : super core::Object::•() + ; +} + +constants { + #C1 = #org-dartlang-testcase:///issue41436c.dart::_#A#x + #C2 = [] + #C3 = [] + #C4 = core::_ImmutableMap {_kvPairs:#C3} + #C5 = #org-dartlang-testcase:///issue41436c.dart::_#A#x= +} diff --git a/pkg/front_end/testcases/late_lowering/issue41436c/link.options b/pkg/front_end/testcases/late_lowering/issue41436c/link.options new file mode 100644 index 00000000000..8503704a0f4 --- /dev/null +++ b/pkg/front_end/testcases/late_lowering/issue41436c/link.options @@ -0,0 +1 @@ +issue41436c_lib.dart \ No newline at end of file diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status index 745dd0fa0fb..467c8fabb69 100644 --- a/pkg/front_end/testcases/text_serialization.status +++ b/pkg/front_end/testcases/text_serialization.status @@ -1264,6 +1264,7 @@ late_lowering/issue40601: TextSerializationFailure late_lowering/issue40805: TextSerializationFailure late_lowering/issue41436/issue41436: TextSerializationFailure late_lowering/issue41436b: TextSerializationFailure +late_lowering/issue41436c/issue41436c: TextSerializationFailure late_lowering/late_field_inference: TextSerializationFailure late_lowering/late_field_with_initializer: TextSerializationFailure late_lowering/late_field_without_initializer: TextSerializationFailure diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md index 5f9a2389746..3c70beba08f 100644 --- a/pkg/kernel/binary.md +++ b/pkg/kernel/binary.md @@ -143,7 +143,7 @@ type CanonicalName { type ComponentFile { UInt32 magic = 0x90ABCDEF; - UInt32 formatVersion = 41; + UInt32 formatVersion = 42; List problemsAsJson; // Described in problems.md. Library[] libraries; UriSource sourceMap; @@ -371,7 +371,7 @@ type Field extends Member { FileOffset fileEndOffset; UInt flags (isFinal, isConst, isStatic, hasImplicitGetter, hasImplicitSetter, isCovariant, isGenericCovariantImpl, isLate, isExtensionMember, - isNonNullableByDefault); + isNonNullableByDefault, isInternalImplementation); Name name; List annotations; DartType type; diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index 0a26190a978..e51b0a846e3 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart @@ -1739,6 +1739,7 @@ class Field extends Member { static const int FlagLate = 1 << 7; static const int FlagExtensionMember = 1 << 8; static const int FlagNonNullableByDefault = 1 << 9; + static const int FlagInternalImplementation = 1 << 10; /// Whether the field is declared with the `covariant` keyword. bool get isCovariant => flags & FlagCovariant != 0; @@ -1780,6 +1781,13 @@ class Field extends Member { /// Whether the field is declared with the `late` keyword. bool get isLate => flags & FlagLate != 0; + // If `true` this field is not part of the interface but only part of the + // class members. + // + // This is `true` for instance for synthesized fields added for the late + // lowering. + bool get isInternalImplementation => flags & FlagInternalImplementation != 0; + void set isCovariant(bool value) { flags = value ? (flags | FlagCovariant) : (flags & ~FlagCovariant); } @@ -1823,6 +1831,12 @@ class Field extends Member { flags = value ? (flags | FlagLate) : (flags & ~FlagLate); } + void set isInternalImplementation(bool value) { + flags = value + ? (flags | FlagInternalImplementation) + : (flags & ~FlagInternalImplementation); + } + /// True if the field is neither final nor const. bool get isMutable => flags & (FlagFinal | FlagConst) == 0; bool get isInstanceMember => !isStatic; diff --git a/pkg/kernel/lib/binary/tag.dart b/pkg/kernel/lib/binary/tag.dart index 1157e570dff..cec230824aa 100644 --- a/pkg/kernel/lib/binary/tag.dart +++ b/pkg/kernel/lib/binary/tag.dart @@ -149,7 +149,7 @@ class Tag { /// Internal version of kernel binary format. /// Bump it when making incompatible changes in kernel binaries. /// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md. - static const int BinaryFormatVersion = 41; + static const int BinaryFormatVersion = 42; } abstract class ConstantTag { diff --git a/runtime/vm/kernel_binary.h b/runtime/vm/kernel_binary.h index aa906255343..4ceb1c78e72 100644 --- a/runtime/vm/kernel_binary.h +++ b/runtime/vm/kernel_binary.h @@ -20,7 +20,7 @@ static const uint32_t kMagicProgramFile = 0x90ABCDEFu; // Both version numbers are inclusive. static const uint32_t kMinSupportedKernelFormatVersion = 29; -static const uint32_t kMaxSupportedKernelFormatVersion = 41; +static const uint32_t kMaxSupportedKernelFormatVersion = 42; // Keep in sync with package:kernel/lib/binary/tag.dart #define KERNEL_TAG_LIST(V) \