Skip to content

Commit 024a967

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Store isPromotable for synthetic fields.
Change-Id: I1f6dd03e3d7436f18c3f986c5208488d65a20fbc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395403 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 8576547 commit 024a967

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import 'package:meta/meta.dart';
9999
// TODO(scheglov): Clean up the list of implicitly analyzed files.
100100
class AnalysisDriver {
101101
/// The version of data format, should be incremented on every format change.
102-
static const int DATA_VERSION = 422;
102+
static const int DATA_VERSION = 423;
103103

104104
/// The number of exception contexts allowed to write. Once this field is
105105
/// zero, we stop writing any new exception contexts in this process.

pkg/analyzer/lib/src/summary2/bundle_reader.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,15 +1603,17 @@ class LibraryReader {
16031603
variables2!.add(variableElement);
16041604
}
16051605
} else {
1606+
var isPromotable = _reader.readBool();
16061607
if (existing is FieldElementImpl && canUseExisting(existing)) {
16071608
propertyFragment = existing;
16081609
} else {
16091610
propertyFragment = FieldElementImpl(name, -1)
16101611
..enclosingElement3 = enclosingElement
16111612
..reference = propertyFragmentReference
1613+
..name2 = accessor.name2
16121614
..isStatic = accessor.isStatic
16131615
..isSynthetic = true
1614-
..name2 = accessor.name2;
1616+
..isPromotable = isPromotable;
16151617
propertyFragmentReference.element ??= propertyFragment;
16161618
propertyFragments.add(propertyFragment);
16171619
}

pkg/analyzer/lib/src/summary2/bundle_writer.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ class BundleWriter {
634634
?.element
635635
.reference,
636636
);
637+
switch (variableFragment) {
638+
case FieldElementImpl fieldFragment:
639+
var field = fieldFragment.element;
640+
_sink.writeBool(field.isPromotable);
641+
}
637642
}
638643
}
639644

pkg/analyzer/test/src/summary/elements/class_test.dart

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12694,6 +12694,80 @@ library
1269412694
''');
1269512695
}
1269612696

12697+
test_class_field_isPromotable_abstractGetter() async {
12698+
var library = await buildLibrary(r'''
12699+
abstract class A {
12700+
int? get _foo;
12701+
}
12702+
''');
12703+
12704+
checkElementText(library, r'''
12705+
library
12706+
reference: <testLibrary>
12707+
definingUnit: <testLibraryFragment>
12708+
units
12709+
<testLibraryFragment>
12710+
enclosingElement3: <null>
12711+
classes
12712+
abstract class A @15
12713+
reference: <testLibraryFragment>::@class::A
12714+
enclosingElement3: <testLibraryFragment>
12715+
fields
12716+
synthetic promotable _foo @-1
12717+
reference: <testLibraryFragment>::@class::A::@field::_foo
12718+
enclosingElement3: <testLibraryFragment>::@class::A
12719+
type: int?
12720+
constructors
12721+
synthetic @-1
12722+
reference: <testLibraryFragment>::@class::A::@constructor::new
12723+
enclosingElement3: <testLibraryFragment>::@class::A
12724+
accessors
12725+
abstract get _foo @30
12726+
reference: <testLibraryFragment>::@class::A::@getter::_foo
12727+
enclosingElement3: <testLibraryFragment>::@class::A
12728+
returnType: int?
12729+
----------------------------------------
12730+
library
12731+
reference: <testLibrary>
12732+
fragments
12733+
<testLibraryFragment>
12734+
element: <testLibrary>
12735+
classes
12736+
class A @15
12737+
reference: <testLibraryFragment>::@class::A
12738+
element: <testLibrary>::@class::A
12739+
fields
12740+
promotable _foo
12741+
reference: <testLibraryFragment>::@class::A::@field::_foo
12742+
element: <testLibraryFragment>::@class::A::@field::_foo#element
12743+
getter2: <testLibraryFragment>::@class::A::@getter::_foo
12744+
constructors
12745+
synthetic new
12746+
reference: <testLibraryFragment>::@class::A::@constructor::new
12747+
element: <testLibraryFragment>::@class::A::@constructor::new#element
12748+
typeName: A
12749+
getters
12750+
get _foo @30
12751+
reference: <testLibraryFragment>::@class::A::@getter::_foo
12752+
element: <testLibraryFragment>::@class::A::@getter::_foo#element
12753+
classes
12754+
abstract class A
12755+
reference: <testLibrary>::@class::A
12756+
firstFragment: <testLibraryFragment>::@class::A
12757+
fields
12758+
synthetic _foo
12759+
firstFragment: <testLibraryFragment>::@class::A::@field::_foo
12760+
type: int?
12761+
getter: <testLibraryFragment>::@class::A::@getter::_foo#element
12762+
constructors
12763+
synthetic new
12764+
firstFragment: <testLibraryFragment>::@class::A::@constructor::new
12765+
getters
12766+
abstract get _foo
12767+
firstFragment: <testLibraryFragment>::@class::A::@getter::_foo
12768+
''');
12769+
}
12770+
1269712771
test_class_field_isPromotable_hasGetter() async {
1269812772
var library = await buildLibrary(r'''
1269912773
class A {

0 commit comments

Comments
 (0)