Skip to content

Commit 4854aab

Browse files
scheglovCommit Queue
authored andcommitted
Stop expecting 'inlineKeyword' during class parsing.
Inline classes will be replaced with extension types. Change-Id: I9472dfbb92f7f50a4649e6f1953481a9ac237fe3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313284 Commit-Queue: Konstantin Shcheglov <[email protected]> Auto-Submit: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent d29235c commit 4854aab

File tree

11 files changed

+28
-115
lines changed

11 files changed

+28
-115
lines changed

pkg/analysis_server/lib/src/computer/computer_highlights.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
685685

686686
@override
687687
void visitClassDeclaration(ClassDeclaration node) {
688-
computer._addRegion_token(node.inlineKeyword, HighlightRegionType.KEYWORD);
689688
computer._addRegion_token(
690689
node.abstractKeyword, HighlightRegionType.BUILT_IN);
691690
computer._addRegion_token(node.sealedKeyword, HighlightRegionType.BUILT_IN);

pkg/analysis_server/test/analysis/notification_highlights2_test.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,14 +1418,6 @@ f(a, b) {
14181418
assertHasRegion(HighlightRegionType.KEYWORD, 'else');
14191419
}
14201420

1421-
Future<void> test_KEYWORD_inline() async {
1422-
addTestFile('''
1423-
inline class A {}
1424-
''');
1425-
await prepareHighlights();
1426-
assertHasRegion(HighlightRegionType.KEYWORD, 'inline');
1427-
}
1428-
14291421
Future<void> test_KEYWORD_late() async {
14301422
addTestFile('''
14311423
class C {

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 = 290;
90+
static const int DATA_VERSION = 291;
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/ast/ast.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,6 +2720,7 @@ abstract final class ClassDeclaration implements NamedCompilationUnitMember {
27202720
ImplementsClause? get implementsClause;
27212721

27222722
/// Return the 'inline' keyword, or `null` if the keyword was absent.
2723+
@Deprecated('Replaced with extension types')
27232724
@experimental
27242725
Token? get inlineKeyword;
27252726

@@ -2780,9 +2781,6 @@ final class ClassDeclarationImpl extends NamedCompilationUnitMemberImpl
27802781
@override
27812782
final Token? mixinKeyword;
27822783

2783-
@override
2784-
final Token? inlineKeyword;
2785-
27862784
@override
27872785
final Token classKeyword;
27882786

@@ -2824,7 +2822,6 @@ final class ClassDeclarationImpl extends NamedCompilationUnitMemberImpl
28242822
required this.interfaceKeyword,
28252823
required this.finalKeyword,
28262824
required this.mixinKeyword,
2827-
required this.inlineKeyword,
28282825
required this.classKeyword,
28292826
required super.name,
28302827
required this.typeParameters,
@@ -2860,11 +2857,16 @@ final class ClassDeclarationImpl extends NamedCompilationUnitMemberImpl
28602857
classKeyword;
28612858
}
28622859

2860+
@Deprecated('Replaced with extension types')
2861+
@override
2862+
Token? get inlineKeyword {
2863+
return null;
2864+
}
2865+
28632866
@override
28642867
ChildEntities get _childEntities => super._childEntities
28652868
..addToken('abstractKeyword', abstractKeyword)
28662869
..addToken('macroKeyword', macroKeyword)
2867-
..addToken('inlineKeyword', inlineKeyword)
28682870
..addToken('sealedKeyword', sealedKeyword)
28692871
..addToken('baseKeyword', baseKeyword)
28702872
..addToken('interfaceKeyword', interfaceKeyword)

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

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,6 @@ abstract class ClassElement implements InterfaceElement {
448448
/// or mixed in.
449449
bool get isFinal;
450450

451-
/// Whether the class is an inline class.
452-
///
453-
/// A class is an inline class if it has an explicit `inline` modifier.
454-
@experimental
455-
bool get isInline;
456-
457451
/// Whether the class is an interface class.
458452
///
459453
/// A class is an interface class if it has an explicit `interface` modifier,
@@ -709,15 +703,6 @@ class ClassElementImpl extends ClassOrMixinElementImpl
709703
setModifier(Modifier.FINAL, isFinal);
710704
}
711705

712-
@override
713-
bool get isInline {
714-
return hasModifier(Modifier.INLINE);
715-
}
716-
717-
set isInline(bool isInline) {
718-
setModifier(Modifier.INLINE, isInline);
719-
}
720-
721706
@override
722707
bool get isInterface {
723708
return hasModifier(Modifier.INTERFACE);
@@ -6824,56 +6809,53 @@ class Modifier implements Comparable<Modifier> {
68246809
/// type being referred to is the return type.
68256810
static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 19);
68266811

6827-
/// Indicates that the modifier 'inline' was applied to the element.
6828-
static const Modifier INLINE = Modifier('INLINE', 20);
6829-
68306812
/// Indicates that the modifier 'interface' was applied to the element.
6831-
static const Modifier INTERFACE = Modifier('INTERFACE', 21);
6813+
static const Modifier INTERFACE = Modifier('INTERFACE', 20);
68326814

68336815
/// Indicates that the method invokes the super method with the same name.
6834-
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 22);
6816+
static const Modifier INVOKES_SUPER_SELF = Modifier('INVOKES_SUPER_SELF', 21);
68356817

68366818
/// Indicates that modifier 'lazy' was applied to the element.
6837-
static const Modifier LATE = Modifier('LATE', 23);
6819+
static const Modifier LATE = Modifier('LATE', 22);
68386820

68396821
/// Indicates that a class is a macro builder.
6840-
static const Modifier MACRO = Modifier('MACRO', 24);
6822+
static const Modifier MACRO = Modifier('MACRO', 23);
68416823

68426824
/// Indicates that a class is a mixin application.
6843-
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 25);
6825+
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 24);
68446826

68456827
/// Indicates that a class is a mixin class.
6846-
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 26);
6828+
static const Modifier MIXIN_CLASS = Modifier('MIXIN_CLASS', 25);
68476829

6848-
static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 27);
6830+
static const Modifier PROMOTABLE = Modifier('IS_PROMOTABLE', 26);
68496831

68506832
/// Indicates whether the type of a [PropertyInducingElementImpl] should be
68516833
/// used to infer the initializer. We set it to `false` if the type was
68526834
/// inferred from the initializer itself.
68536835
static const Modifier SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE =
6854-
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 28);
6836+
Modifier('SHOULD_USE_TYPE_FOR_INITIALIZER_INFERENCE', 27);
68556837

68566838
/// Indicates that the modifier 'sealed' was applied to the element.
6857-
static const Modifier SEALED = Modifier('SEALED', 29);
6839+
static const Modifier SEALED = Modifier('SEALED', 28);
68586840

68596841
/// Indicates that the pseudo-modifier 'set' was applied to the element.
6860-
static const Modifier SETTER = Modifier('SETTER', 30);
6842+
static const Modifier SETTER = Modifier('SETTER', 29);
68616843

68626844
/// See [TypeParameterizedElement.isSimplyBounded].
6863-
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 31);
6845+
static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 30);
68646846

68656847
/// Indicates that the modifier 'static' was applied to the element.
6866-
static const Modifier STATIC = Modifier('STATIC', 32);
6848+
static const Modifier STATIC = Modifier('STATIC', 31);
68676849

68686850
/// Indicates that the element does not appear in the source code but was
68696851
/// implicitly created. For example, if a class does not define any
68706852
/// constructors, an implicit zero-argument constructor will be created and it
68716853
/// will be marked as being synthetic.
6872-
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 33);
6854+
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 32);
68736855

68746856
/// Indicates that the element was appended to this enclosing element to
68756857
/// simulate temporary the effect of applying augmentation.
6876-
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 34);
6858+
static const Modifier TEMP_AUGMENTATION = Modifier('TEMP_AUGMENTATION', 33);
68776859

68786860
static const List<Modifier> values = [
68796861
ABSTRACT,
@@ -6895,7 +6877,6 @@ class Modifier implements Comparable<Modifier> {
68956877
HAS_SINCE_SDK_VERSION_COMPUTED,
68966878
HAS_SINCE_SDK_VERSION_VALUE,
68976879
IMPLICIT_TYPE,
6898-
INLINE,
68996880
INTERFACE,
69006881
INVOKES_SUPER_SELF,
69016882
LATE,

pkg/analyzer/lib/src/fasta/ast_builder.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ class AstBuilder extends StackListener {
302302
}
303303
}
304304
push(macroToken ?? NullValues.Token);
305-
push(inlineToken ?? NullValues.Token);
306305
push(sealedToken ?? NullValues.Token);
307306
push(baseToken ?? NullValues.Token);
308307
push(interfaceToken ?? NullValues.Token);
@@ -754,7 +753,6 @@ class AstBuilder extends StackListener {
754753
metadata: null,
755754
abstractKeyword: null,
756755
macroKeyword: null,
757-
inlineKeyword: null,
758756
sealedKeyword: null,
759757
baseKeyword: null,
760758
interfaceKeyword: null,
@@ -3678,7 +3676,6 @@ class AstBuilder extends StackListener {
36783676
var interfaceKeyword = pop(NullValues.Token) as Token?;
36793677
var baseKeyword = pop(NullValues.Token) as Token?;
36803678
var sealedKeyword = pop(NullValues.Token) as Token?;
3681-
var inlineKeyword = pop(NullValues.Token) as Token?;
36823679
var macroKeyword = pop(NullValues.Token) as Token?;
36833680
var modifiers = pop() as _Modifiers?;
36843681
var typeParameters = pop() as TypeParameterListImpl?;
@@ -3693,7 +3690,6 @@ class AstBuilder extends StackListener {
36933690
metadata: metadata,
36943691
abstractKeyword: abstractKeyword,
36953692
macroKeyword: macroKeyword,
3696-
inlineKeyword: inlineKeyword,
36973693
sealedKeyword: sealedKeyword,
36983694
baseKeyword: baseKeyword,
36993695
interfaceKeyword: interfaceKeyword,
@@ -6094,7 +6090,6 @@ class _ClassDeclarationBuilder extends _ClassLikeDeclarationBuilder {
60946090
final Token? augmentKeyword;
60956091
final Token? abstractKeyword;
60966092
final Token? macroKeyword;
6097-
final Token? inlineKeyword;
60986093
final Token? sealedKeyword;
60996094
final Token? baseKeyword;
61006095
final Token? interfaceKeyword;
@@ -6116,7 +6111,6 @@ class _ClassDeclarationBuilder extends _ClassLikeDeclarationBuilder {
61166111
required this.augmentKeyword,
61176112
required this.abstractKeyword,
61186113
required this.macroKeyword,
6119-
required this.inlineKeyword,
61206114
required this.sealedKeyword,
61216115
required this.baseKeyword,
61226116
required this.interfaceKeyword,
@@ -6137,7 +6131,6 @@ class _ClassDeclarationBuilder extends _ClassLikeDeclarationBuilder {
61376131
augmentKeyword: augmentKeyword,
61386132
abstractKeyword: abstractKeyword,
61396133
macroKeyword: macroKeyword,
6140-
inlineKeyword: inlineKeyword,
61416134
sealedKeyword: sealedKeyword,
61426135
baseKeyword: baseKeyword,
61436136
interfaceKeyword: interfaceKeyword,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
9191
element.isAugmentation = node.augmentKeyword != null;
9292
element.isBase = node.baseKeyword != null;
9393
element.isFinal = node.finalKeyword != null;
94-
element.isInline = node.inlineKeyword != null;
9594
element.isInterface = node.interfaceKeyword != null;
9695
element.isMacro = node.macroKeyword != null;
9796
element.isMixinClass = node.mixinKeyword != null;

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ class ClassElementFlags {
1111
static const int _isAugmentation = 1 << 1;
1212
static const int _isBase = 1 << 2;
1313
static const int _isFinal = 1 << 3;
14-
static const int _isInline = 1 << 4;
15-
static const int _isInterface = 1 << 5;
16-
static const int _isMacro = 1 << 6;
17-
static const int _isMixinApplication = 1 << 7;
18-
static const int _isMixinClass = 1 << 8;
19-
static const int _isSealed = 1 << 9;
20-
static const int _isSimplyBounded = 1 << 10;
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;
2120

2221
static void read(
2322
SummaryDataReader reader,
@@ -28,7 +27,6 @@ class ClassElementFlags {
2827
element.isAugmentation = (byte & _isAugmentation) != 0;
2928
element.isBase = (byte & _isBase) != 0;
3029
element.isFinal = (byte & _isFinal) != 0;
31-
element.isInline = (byte & _isInline) != 0;
3230
element.isInterface = (byte & _isInterface) != 0;
3331
element.isMacro = (byte & _isMacro) != 0;
3432
element.isMixinApplication = (byte & _isMixinApplication) != 0;
@@ -46,7 +44,6 @@ class ClassElementFlags {
4644
result |= element.isAugmentation ? _isAugmentation : 0;
4745
result |= element.isBase ? _isBase : 0;
4846
result |= element.isFinal ? _isFinal : 0;
49-
result |= element.isInline ? _isInline : 0;
5047
result |= element.isInterface ? _isInterface : 0;
5148
result |= element.isMacro ? _isMacro : 0;
5249
result |= element.isMixinApplication ? _isMixinApplication : 0;

pkg/analyzer/test/src/fasta/ast_builder_test.dart

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,27 +329,6 @@ ClassDeclaration
329329
withOffsets: true);
330330
}
331331

332-
void test_class_inline() {
333-
var parseResult = parseStringWithErrors(r'''
334-
/// text
335-
inline class A {}
336-
''');
337-
parseResult.assertNoErrors();
338-
339-
var node = parseResult.findNode.classDeclaration('class A {}');
340-
assertParsedNodeText(node, r'''
341-
ClassDeclaration
342-
documentationComment: Comment
343-
tokens
344-
/// text
345-
inlineKeyword: inline
346-
classKeyword: class
347-
name: A
348-
leftBracket: {
349-
rightBracket: }
350-
''');
351-
}
352-
353332
void test_class_interface() {
354333
var parseResult = parseStringWithErrors(r'''
355334
/// text

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ class _ElementWriter {
567567
_sink.writeIf(e.isBase, 'base ');
568568
_sink.writeIf(e.isInterface, 'interface ');
569569
_sink.writeIf(e.isFinal, 'final ');
570-
_sink.writeIf(e.isInline, 'inline ');
571570
_sink.writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
572571
_sink.writeIf(e.isMixinClass, 'mixin ');
573572
_sink.write('class ');

0 commit comments

Comments
 (0)