Skip to content

Commit b013a40

Browse files
scheglovCommit Queue
authored andcommitted
Add isInline to ClassElement.
Change-Id: I80dafc9ef0dc03b8090032a7b7168302a8d6ad66 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311150 Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent ce6634e commit b013a40

File tree

8 files changed

+74
-21
lines changed

8 files changed

+74
-21
lines changed

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ abstract class ClassElement
228228
/// or mixed in.
229229
bool get isFinal;
230230

231+
/// Returns `true` if this class is an inline class.
232+
///
233+
/// A class is an inline class if it has an explicit `inline` modifier.
234+
@experimental
235+
bool get isInline;
236+
231237
/// Return `true` if this class is an interface class.
232238
///
233239
/// A class is an interface class if it has an explicit `interface` modifier,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import 'package:analyzer/src/utilities/uri_cache.dart';
8787
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
8888
class AnalysisDriver implements AnalysisDriverGeneric {
8989
/// The version of data format, should be incremented on every format change.
90-
static const int DATA_VERSION = 277;
90+
static const int DATA_VERSION = 278;
9191

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

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,15 @@ class ClassElementImpl extends ClassOrMixinElementImpl implements ClassElement {
736736
setModifier(Modifier.FINAL, isFinal);
737737
}
738738

739+
@override
740+
bool get isInline {
741+
return hasModifier(Modifier.INLINE);
742+
}
743+
744+
set isInline(bool isInline) {
745+
setModifier(Modifier.INLINE, isInline);
746+
}
747+
739748
@override
740749
bool get isInterface {
741750
return hasModifier(Modifier.INTERFACE);
@@ -5001,53 +5010,56 @@ class Modifier implements Comparable<Modifier> {
50015010
/// type being referred to is the return type.
50025011
static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 18);
50035012

5013+
/// Indicates that the modifier 'inline' was applied to the element.
5014+
static const Modifier INLINE = Modifier('INLINE', 19);
5015+
50045016
/// Indicates that the modifier 'interface' was applied to the element.
5005-
static const Modifier INTERFACE = Modifier('INTERFACE', 19);
5017+
static const Modifier INTERFACE = Modifier('INTERFACE', 20);
50065018

50075019
/// Indicates that the method invokes the super method with the same name.
5008-
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 20);
5020+
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 21);
50095021

50105022
/// Indicates that modifier 'lazy' was applied to the element.
5011-
static const Modifier LATE = Modifier('LATE', 21);
5023+
static const Modifier LATE = Modifier('LATE', 22);
50125024

50135025
/// Indicates that a class is a macro builder.
5014-
static const Modifier MACRO = Modifier('MACRO', 22);
5026+
static const Modifier MACRO = Modifier('MACRO', 23);
50155027

50165028
/// Indicates that a class is a mixin application.
5017-
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 23);
5029+
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 24);
50185030

50195031
/// Indicates that a class is a mixin class.
5020-
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 24);
5032+
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 25);
50215033

5022-
static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 25);
5034+
static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 26);
50235035

50245036
/// Indicates whether the type of a [PropertyInducingElementImpl] should be
50255037
/// used to infer the initializer. We set it to `false` if the type was
50265038
/// inferred from the initializer itself.
50275039
static const Modifier SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE =
5028-
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 26);
5040+
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 27);
50295041

50305042
/// Indicates that the modifier 'sealed' was applied to the element.
5031-
static const Modifier SEALED = Modifier('SEALED', 27);
5043+
static const Modifier SEALED = Modifier('SEALED', 28);
50325044

50335045
/// Indicates that the pseudo-modifier 'set' was applied to the element.
5034-
static const Modifier SETTER = Modifier('SETTER', 28);
5046+
static const Modifier SETTER = Modifier('SETTER', 29);
50355047

50365048
/// See [TypeParameterizedElement.isSimplyBounded].
5037-
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 29);
5049+
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 30);
50385050

50395051
/// Indicates that the modifier 'static' was applied to the element.
5040-
static const Modifier STATIC = Modifier('STATIC', 30);
5052+
static const Modifier STATIC = Modifier('STATIC', 31);
50415053

50425054
/// Indicates that the element does not appear in the source code but was
50435055
/// implicitly created. For example, if a class does not define any
50445056
/// constructors, an implicit zero-argument constructor will be created and it
50455057
/// will be marked as being synthetic.
5046-
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 31);
5058+
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 32);
50475059

50485060
/// Indicates that the element was appended to this enclosing element to
50495061
/// simulate temporary the effect of applying augmentation.
5050-
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 32);
5062+
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 33);
50515063

50525064
static const List<Modifier> values = [
50535065
ABSTRACT,
@@ -5069,6 +5081,7 @@ class Modifier implements Comparable<Modifier> {
50695081
HAS_SINCE_SDK_VERSION_COMPUTED,
50705082
HAS_SINCE_SDK_VERSION_VALUE,
50715083
IMPLICIT_TYPE,
5084+
INLINE,
50725085
INTERFACE,
50735086
INVOKES_SUPER_SELF,
50745087
LATE,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
9797
element.isBase = node.baseKeyword != null;
9898
element.isInterface = node.interfaceKeyword != null;
9999
element.isFinal = node.finalKeyword != null;
100+
element.isInline = node.inlineKeyword != null;
100101
element.isMixinClass = node.mixinKeyword != null;
101102
element.metadata = _buildAnnotations(node.metadata);
102103
_setCodeRange(element, node);

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ class ClassElementFlags {
1010
static const int _isAbstract = 1 << 0;
1111
static const int _isBase = 1 << 1;
1212
static const int _isFinal = 1 << 2;
13-
static const int _isInterface = 1 << 3;
14-
static const int _isMacro = 1 << 4;
15-
static const int _isMixinApplication = 1 << 5;
16-
static const int _isMixinClass = 1 << 6;
17-
static const int _isSealed = 1 << 7;
18-
static const int _isSimplyBounded = 1 << 8;
13+
static const int _isInline = 1 << 3;
14+
static const int _isInterface = 1 << 4;
15+
static const int _isMacro = 1 << 5;
16+
static const int _isMixinApplication = 1 << 6;
17+
static const int _isMixinClass = 1 << 7;
18+
static const int _isSealed = 1 << 8;
19+
static const int _isSimplyBounded = 1 << 9;
1920

2021
static void read(SummaryDataReader reader, ClassElementImpl element) {
2122
var byte = reader.readUInt30();
2223
element.isAbstract = (byte & _isAbstract) != 0;
2324
element.isBase = (byte & _isBase) != 0;
2425
element.isFinal = (byte & _isFinal) != 0;
26+
element.isInline = (byte & _isInline) != 0;
2527
element.isInterface = (byte & _isInterface) != 0;
2628
element.isMacro = (byte & _isMacro) != 0;
2729
element.isMixinApplication = (byte & _isMixinApplication) != 0;
@@ -35,6 +37,7 @@ class ClassElementFlags {
3537
result |= element.isAbstract ? _isAbstract : 0;
3638
result |= element.isBase ? _isBase : 0;
3739
result |= element.isFinal ? _isFinal : 0;
40+
result |= element.isInline ? _isInline : 0;
3841
result |= element.isInterface ? _isInterface : 0;
3942
result |= element.isMacro ? _isMacro : 0;
4043
result |= element.isMixinApplication ? _isMixinApplication : 0;

pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class PubPackageResolutionTest extends ContextResolutionTest {
329329
List<String> get experiments => [
330330
EnableString.class_modifiers,
331331
EnableString.inference_update_2,
332+
EnableString.inline_class,
332333
EnableString.macros,
333334
EnableString.patterns,
334335
EnableString.records,

pkg/analyzer/test/src/summary/element_text.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class _ElementWriter {
301301
_writeIf(e.isBase, 'base ');
302302
_writeIf(e.isInterface, 'interface ');
303303
_writeIf(e.isFinal, 'final ');
304+
_writeIf(e.isInline, 'inline ');
304305
_writeIf(e.isMixinClass, 'mixin ');
305306
}
306307
_writeIf(!e.isSimplyBounded, 'notSimplyBounded ');

pkg/analyzer/test/src/summary/elements_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6574,6 +6574,34 @@ library
65746574
''');
65756575
}
65766576

6577+
test_class_inline() async {
6578+
var library = await buildLibrary(r'''
6579+
inline class A {
6580+
final int value;
6581+
A(this.value);
6582+
}
6583+
''');
6584+
checkElementText(library, r'''
6585+
library
6586+
definingUnit
6587+
classes
6588+
inline class A @13
6589+
fields
6590+
final value @29
6591+
type: int
6592+
shouldUseTypeForInitializerInference: true
6593+
constructors
6594+
@38
6595+
parameters
6596+
requiredPositional final this.value @45
6597+
type: int
6598+
field: self::@class::A::@field::value
6599+
accessors
6600+
synthetic get value @-1
6601+
returnType: int
6602+
''');
6603+
}
6604+
65776605
test_class_interface() async {
65786606
var library = await buildLibrary('interface class C {}');
65796607
checkElementText(library, r'''

0 commit comments

Comments
 (0)