Skip to content

Commit be9f4cb

Browse files
author
Dart CI
committed
Version 2.18.0-246.0.dev
Merge commit '81d86a05b2d7159cf8c63acbcc752a86d49bbaad' into 'dev'
2 parents ad8c447 + 81d86a0 commit be9f4cb

39 files changed

+428
-576
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8531,9 +8531,20 @@ class Parser {
85318531
if (comment.indexOf('```', /* start = */ 3) != -1) {
85328532
inCodeBlock = !inCodeBlock;
85338533
}
8534-
if (!inCodeBlock && !comment.startsWith('/// ')) {
8535-
count += parseCommentReferencesInText(
8536-
token, /* start = */ 3, comment.length);
8534+
if (!inCodeBlock) {
8535+
bool parseReferences;
8536+
if (comment.startsWith('/// ')) {
8537+
String? previousComment = token.previous?.lexeme;
8538+
parseReferences = previousComment != null &&
8539+
previousComment.startsWith('///') &&
8540+
previousComment.trim().length > 3;
8541+
} else {
8542+
parseReferences = true;
8543+
}
8544+
if (parseReferences) {
8545+
count += parseCommentReferencesInText(
8546+
token, /* start = */ 3, comment.length);
8547+
}
85378548
}
85388549
}
85398550
token = token.next;

pkg/analyzer/test/generated/simple_parser_test.dart

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,20 @@ abstract class Foo {}
866866
expect(nextToken.type, TokenType.EOF);
867867
}
868868

869+
void test_parseCommentReferences_notCodeBlock_4spaces_afterText() {
870+
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
871+
DocumentationCommentToken(
872+
TokenType.SINGLE_LINE_COMMENT, "/// comment:", 0),
873+
DocumentationCommentToken(
874+
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
875+
];
876+
createParser('');
877+
List<CommentReference> references = parser.parseCommentReferences(tokens);
878+
expectNotNullIfNoErrors(references);
879+
assertNoErrors();
880+
expect(references, hasLength(2));
881+
}
882+
869883
void test_parseCommentReferences_singleLine() {
870884
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
871885
DocumentationCommentToken(
@@ -891,6 +905,36 @@ abstract class Foo {}
891905
expect(reference.offset, 35);
892906
}
893907

908+
void test_parseCommentReferences_skipCodeBlock_4spaces_afterEmptyComment() {
909+
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
910+
DocumentationCommentToken(
911+
TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0),
912+
DocumentationCommentToken(TokenType.SINGLE_LINE_COMMENT, "///", 0),
913+
DocumentationCommentToken(
914+
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
915+
];
916+
createParser('');
917+
List<CommentReference> references = parser.parseCommentReferences(tokens);
918+
expectNotNullIfNoErrors(references);
919+
assertNoErrors();
920+
expect(references, isEmpty);
921+
}
922+
923+
void test_parseCommentReferences_skipCodeBlock_4spaces_afterEmptyLine() {
924+
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
925+
DocumentationCommentToken(
926+
TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0),
927+
DocumentationCommentToken(TokenType.SINGLE_LINE_COMMENT, "", 0),
928+
DocumentationCommentToken(
929+
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
930+
];
931+
createParser('');
932+
List<CommentReference> references = parser.parseCommentReferences(tokens);
933+
expectNotNullIfNoErrors(references);
934+
assertNoErrors();
935+
expect(references, isEmpty);
936+
}
937+
894938
void test_parseCommentReferences_skipCodeBlock_4spaces_block() {
895939
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
896940
DocumentationCommentToken(TokenType.MULTI_LINE_COMMENT,
@@ -903,12 +947,10 @@ abstract class Foo {}
903947
expect(references, isEmpty);
904948
}
905949

906-
void test_parseCommentReferences_skipCodeBlock_4spaces_lines() {
950+
void test_parseCommentReferences_skipCodeBlock_4spaces_first() {
907951
List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[
908952
DocumentationCommentToken(
909-
TokenType.SINGLE_LINE_COMMENT, "/// Code block:", 0),
910-
DocumentationCommentToken(
911-
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
953+
TokenType.SINGLE_LINE_COMMENT, "/// a[i] == b[i]", 0)
912954
];
913955
createParser('');
914956
List<CommentReference> references = parser.parseCommentReferences(tokens);

pkg/dev_compiler/lib/src/kernel/expression_compiler.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ class DartScopeBuilder extends Visitor<void> with VisitorVoidMixin {
163163

164164
@override
165165
void visitVariableDeclaration(VariableDeclaration decl) {
166+
var name = decl.name;
166167
// Collect locals and formals appearing before current breakpoint.
167168
// Note that we include variables with no offset because the offset
168169
// is not set in many cases in generated code, so omitting them would
169170
// make expression evaluation fail in too many cases.
170171
// Issue: https://github.com/dart-lang/sdk/issues/43966
171-
if (decl.fileOffset < 0 || decl.fileOffset < _offset) {
172-
_definitions[decl.name!] = decl.type;
172+
//
173+
// A null name signals that the variable was synthetically introduced by the
174+
// compiler so they are skipped.
175+
if ((decl.fileOffset < 0 || decl.fileOffset < _offset) && name != null) {
176+
_definitions[name] = decl.type;
173177
}
174178
super.visitVariableDeclaration(decl);
175179
}

pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_shared.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,35 @@ void runNullSafeSharedTests(SetupCompilerOptions setup, TestDriver driver) {
356356
expectedResult: 'true');
357357
});
358358
});
359+
360+
group('Synthetic variables', () {
361+
var source = r'''
362+
dynamic couldReturnNull() => null;
363+
364+
main() {
365+
var i = couldReturnNull() ?? 10;
366+
// Breakpoint: bp
367+
print(i);
368+
}
369+
''';
370+
371+
setUpAll(() async {
372+
await driver.initSource(setup, source);
373+
});
374+
375+
tearDownAll(() async {
376+
await driver.cleanupTest();
377+
});
378+
379+
test('do not cause a crash the expression compiler', () async {
380+
// The null aware code in the test source causes the compiler to introduce
381+
// a let statement that includes a synthetic variable declaration.
382+
// That variable has no name and was causing a crash in the expression
383+
// compiler https://github.com/dart-lang/sdk/issues/49373.
384+
await driver.check(
385+
breakpointId: 'bp', expression: 'true', expectedResult: 'true');
386+
});
387+
});
359388
}
360389

361390
/// Shared tests that are valid in legacy (before 2.12) and are agnostic to

pkg/test_runner/lib/src/configuration.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,19 @@ class TestConfiguration {
333333
_compilerConfiguration ??= CompilerConfiguration(this);
334334

335335
/// The set of [Feature]s supported by this configuration.
336-
late final Set<Feature> supportedFeatures = {
337-
// TODO(rnystrom): Define more features for things like "dart:io", separate
338-
// int/double representation, etc.
339-
if (NnbdMode.legacy == configuration.nnbdMode)
340-
Feature.nnbdLegacy
341-
else
342-
Feature.nnbd,
343-
if (NnbdMode.weak == configuration.nnbdMode) Feature.nnbdWeak,
344-
if (NnbdMode.strong == configuration.nnbdMode) Feature.nnbdStrong,
345-
};
336+
late final Set<Feature> supportedFeatures = compiler == Compiler.dart2analyzer
337+
// The analyzer should parse all tests.
338+
? {...Feature.all}
339+
: {
340+
// TODO(rnystrom): Define more features for things like "dart:io", separate
341+
// int/double representation, etc.
342+
if (NnbdMode.legacy == configuration.nnbdMode)
343+
Feature.nnbdLegacy
344+
else
345+
Feature.nnbd,
346+
if (NnbdMode.weak == configuration.nnbdMode) Feature.nnbdWeak,
347+
if (NnbdMode.strong == configuration.nnbdMode) Feature.nnbdStrong,
348+
};
346349

347350
/// Determines if this configuration has a compatible compiler and runtime
348351
/// and other valid fields.

pkg/test_runner/lib/src/testing_servers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class DispatchingServer {
4848
/// directory (i.e. '$BuildDirectory/X').
4949
/// /FOO/packages/PAZ/BAR: This will serve files from the packages listed in
5050
/// the package spec .packages. Supports a package
51-
/// root or custom package spec, and uses [dart_dir]/.packages
51+
/// root or custom package spec, and uses $dart_dir/.packages
5252
/// as the default. This will serve file lib/BAR from the package PAZ.
5353
/// /ws: This will upgrade the connection to a WebSocket connection and echo
5454
/// all data back to the client.

runtime/lib/timeline.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ DEFINE_NATIVE_ENTRY(Timeline_isDartStreamEnabled, 0, 0) {
2424
return Bool::False().ptr();
2525
}
2626

27-
DEFINE_NATIVE_ENTRY(Timeline_getNextTaskId, 0, 0) {
27+
DEFINE_NATIVE_ENTRY(Timeline_getNextAsyncId, 0, 0) {
2828
#if !defined(SUPPORT_TIMELINE)
2929
return Integer::New(0);
3030
#else
31-
return Integer::New(thread->GetNextTaskId());
31+
TimelineEventRecorder* recorder = Timeline::recorder();
32+
if (recorder == NULL) {
33+
return Integer::New(0);
34+
}
35+
return Integer::New(recorder->GetNextAsyncId());
3236
#endif
3337
}
3438

runtime/vm/bootstrap_natives.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ namespace dart {
153153
V(TypeError_throwNew, 4) \
154154
V(Stopwatch_now, 0) \
155155
V(Stopwatch_frequency, 0) \
156-
V(Timeline_getNextTaskId, 0) \
156+
V(Timeline_getNextAsyncId, 0) \
157157
V(Timeline_getTraceClock, 0) \
158158
V(Timeline_isDartStreamEnabled, 0) \
159159
V(Timeline_reportFlowEvent, 5) \

runtime/vm/compiler/asm_intrinsifier_arm.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,23 +1900,6 @@ void AsmIntrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler,
19001900
#endif
19011901
}
19021902

1903-
void AsmIntrinsifier::Timeline_getNextTaskId(Assembler* assembler,
1904-
Label* normal_ir_body) {
1905-
#if !defined(SUPPORT_TIMELINE)
1906-
__ LoadImmediate(R0, target::ToRawSmi(0));
1907-
__ Ret();
1908-
#else
1909-
__ ldr(R1, Address(THR, target::Thread::next_task_id_offset()));
1910-
__ ldr(R2, Address(THR, target::Thread::next_task_id_offset() + 4));
1911-
__ SmiTag(R0, R1); // Ignore loss of precision.
1912-
__ adds(R1, R1, Operand(1));
1913-
__ adcs(R2, R2, Operand(0));
1914-
__ str(R1, Address(THR, target::Thread::next_task_id_offset()));
1915-
__ str(R2, Address(THR, target::Thread::next_task_id_offset() + 4));
1916-
__ Ret();
1917-
#endif
1918-
}
1919-
19201903
#undef __
19211904

19221905
} // namespace compiler

runtime/vm/compiler/asm_intrinsifier_arm64.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,20 +2146,6 @@ void AsmIntrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler,
21462146
#endif
21472147
}
21482148

2149-
void AsmIntrinsifier::Timeline_getNextTaskId(Assembler* assembler,
2150-
Label* normal_ir_body) {
2151-
#if !defined(SUPPORT_TIMELINE)
2152-
__ LoadImmediate(R0, target::ToRawSmi(0));
2153-
__ ret();
2154-
#else
2155-
__ ldr(R0, Address(THR, target::Thread::next_task_id_offset()));
2156-
__ add(R1, R0, Operand(1));
2157-
__ str(R1, Address(THR, target::Thread::next_task_id_offset()));
2158-
__ SmiTag(R0); // Ignore loss of precision.
2159-
__ ret();
2160-
#endif
2161-
}
2162-
21632149
#undef __
21642150

21652151
} // namespace compiler

runtime/vm/compiler/asm_intrinsifier_ia32.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,24 +1937,6 @@ void AsmIntrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler,
19371937
#endif
19381938
}
19391939

1940-
void AsmIntrinsifier::Timeline_getNextTaskId(Assembler* assembler,
1941-
Label* normal_ir_body) {
1942-
#if !defined(SUPPORT_TIMELINE)
1943-
__ LoadImmediate(EAX, target::ToRawSmi(0));
1944-
__ ret();
1945-
#else
1946-
__ movl(EBX, Address(THR, target::Thread::next_task_id_offset()));
1947-
__ movl(ECX, Address(THR, target::Thread::next_task_id_offset() + 4));
1948-
__ movl(EAX, EBX);
1949-
__ SmiTag(EAX); // Ignore loss of precision.
1950-
__ addl(EBX, Immediate(1));
1951-
__ adcl(ECX, Immediate(0));
1952-
__ movl(Address(THR, target::Thread::next_task_id_offset()), EBX);
1953-
__ movl(Address(THR, target::Thread::next_task_id_offset() + 4), ECX);
1954-
__ ret();
1955-
#endif
1956-
}
1957-
19581940
#undef __
19591941

19601942
} // namespace compiler

runtime/vm/compiler/asm_intrinsifier_riscv.cc

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,30 +2160,6 @@ void AsmIntrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler,
21602160
#endif
21612161
}
21622162

2163-
void AsmIntrinsifier::Timeline_getNextTaskId(Assembler* assembler,
2164-
Label* normal_ir_body) {
2165-
#if !defined(SUPPORT_TIMELINE)
2166-
__ LoadImmediate(A0, target::ToRawSmi(0));
2167-
__ ret();
2168-
#elif XLEN == 64
2169-
__ ld(A0, Address(THR, target::Thread::next_task_id_offset()));
2170-
__ addi(A1, A0, 1);
2171-
__ sd(A1, Address(THR, target::Thread::next_task_id_offset()));
2172-
__ SmiTag(A0); // Ignore loss of precision.
2173-
__ ret();
2174-
#else
2175-
__ lw(T0, Address(THR, target::Thread::next_task_id_offset()));
2176-
__ lw(T1, Address(THR, target::Thread::next_task_id_offset() + 4));
2177-
__ SmiTag(A0, T0); // Ignore loss of precision.
2178-
__ addi(T2, T0, 1);
2179-
__ sltu(T3, T2, T0); // Carry.
2180-
__ add(T1, T1, T3);
2181-
__ sw(T2, Address(THR, target::Thread::next_task_id_offset()));
2182-
__ sw(T1, Address(THR, target::Thread::next_task_id_offset() + 4));
2183-
__ ret();
2184-
#endif
2185-
}
2186-
21872163
#undef __
21882164

21892165
} // namespace compiler

runtime/vm/compiler/asm_intrinsifier_x64.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,21 +2034,6 @@ void AsmIntrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler,
20342034
#endif
20352035
}
20362036

2037-
void AsmIntrinsifier::Timeline_getNextTaskId(Assembler* assembler,
2038-
Label* normal_ir_body) {
2039-
#if !defined(SUPPORT_TIMELINE)
2040-
__ xorq(RAX, RAX); // Return Smi 0.
2041-
__ ret();
2042-
#else
2043-
__ movq(RAX, Address(THR, target::Thread::next_task_id_offset()));
2044-
__ movq(RBX, RAX);
2045-
__ incq(RBX);
2046-
__ movq(Address(THR, target::Thread::next_task_id_offset()), RBX);
2047-
__ SmiTag(RAX); // Ignore loss of precision.
2048-
__ ret();
2049-
#endif
2050-
}
2051-
20522037
#undef __
20532038

20542039
} // namespace compiler

runtime/vm/compiler/recognized_methods_list.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ namespace dart {
438438
V(::, _getDefaultTag, UserTag_defaultTag, 0x6c19c8a5) \
439439
V(::, _getCurrentTag, Profiler_getCurrentTag, 0x70ead08e) \
440440
V(::, _isDartStreamEnabled, Timeline_isDartStreamEnabled, 0xc97aafb3) \
441-
V(::, _getNextTaskId, Timeline_getNextTaskId, 0x5b2b0b0b) \
442441

443442
#define INTERNAL_LIB_INTRINSIC_LIST(V) \
444443
V(::, allocateOneByteString, AllocateOneByteString, 0x9e7745d5) \

runtime/vm/compiler/runtime_api.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,6 @@ class Thread : public AllStatic {
12501250
THREAD_XMM_CONSTANT_LIST(DECLARE_CONSTANT_OFFSET_GETTER)
12511251
#undef DECLARE_CONSTANT_OFFSET_GETTER
12521252

1253-
static word next_task_id_offset();
12541253
static word random_offset();
12551254

12561255
static word suspend_state_init_async_entry_point_offset();

0 commit comments

Comments
 (0)