Skip to content

Commit a39ea25

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
[cfe] Add test for dynamic access in CFE/kernel code
Change-Id: I9cd5aec2bd9b455a099503ca3c55f61659145869 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171726 Reviewed-by: Dmitry Stefantsov <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent c3f96e8 commit a39ea25

13 files changed

+469
-22
lines changed

pkg/front_end/lib/src/base/processed_options.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,7 @@ class ProcessedOptions {
561561
templateCantReadFile.withArguments(uri, e.message), Severity.error);
562562
}
563563
} catch (e) {
564-
Message message =
565-
templateExceptionReadingFile.withArguments(uri, e.message);
564+
Message message = templateExceptionReadingFile.withArguments(uri, '$e');
566565
reportWithoutLocation(message, Severity.error);
567566
// We throw a new exception to ensure that the message include the uri
568567
// that led to the exception. Exceptions in Uri don't include the

pkg/front_end/lib/src/fasta/builder/function_type_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class FunctionTypeBuilder extends TypeBuilder {
5959
buffer.write("(");
6060
if (formals != null) {
6161
bool isFirst = true;
62-
for (dynamic t in formals) {
62+
for (FormalParameterBuilder t in formals) {
6363
if (!isFirst) {
6464
buffer.write(", ");
6565
} else {
6666
isFirst = false;
6767
}
68-
buffer.write(t?.fullNameForErrors);
68+
buffer.write(t.fullNameForErrors);
6969
}
7070
}
7171
buffer.write(") ->");

pkg/front_end/lib/src/fasta/command_line_reporting.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import 'package:_fe_analyzer_shared/src/util/colors.dart'
2424
import 'package:_fe_analyzer_shared/src/util/relativize.dart'
2525
show isWindows, relativizeUri;
2626

27-
import 'package:kernel/ast.dart' show Location, TreeNode;
27+
import 'package:kernel/ast.dart' show Location, Source, TreeNode;
2828

2929
import '../compute_platform_binaries_location.dart' show translateSdk;
3030

@@ -43,7 +43,8 @@ const bool hideWarnings = false;
4343
/// Formats [message] as a string that is suitable for output from a
4444
/// command-line tool. This includes source snippets and different colors based
4545
/// on [severity].
46-
String format(LocatedMessage message, Severity severity, {Location location}) {
46+
String format(LocatedMessage message, Severity severity,
47+
{Location location, Map<Uri, Source> uriToSource}) {
4748
try {
4849
int length = message.length;
4950
if (length < 1) {
@@ -85,7 +86,7 @@ String format(LocatedMessage message, Severity severity, {Location location}) {
8586
if (location?.line == TreeNode.noOffset) {
8687
location = null;
8788
}
88-
String sourceLine = getSourceLine(location);
89+
String sourceLine = getSourceLine(location, uriToSource);
8990
return formatErrorMessage(
9091
sourceLine, location, length, path, messageText);
9192
} else {

pkg/front_end/lib/src/fasta/messages.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
library fasta.messages;
66

7-
import 'package:kernel/ast.dart' show Library, Location, Component, TreeNode;
7+
import 'package:kernel/ast.dart'
8+
show Library, Location, Component, Source, TreeNode;
89

910
import 'compiler_context.dart' show CompilerContext;
1011

@@ -21,10 +22,10 @@ Location getLocationFromUri(Uri uri, int charOffset) {
2122
return getLocation(uri, charOffset);
2223
}
2324

24-
String getSourceLine(Location location) {
25+
String getSourceLine(Location location, [Map<Uri, Source> uriToSource]) {
2526
if (location == null) return null;
26-
return CompilerContext.current.uriToSource[location.file]
27-
?.getTextLine(location.line);
27+
uriToSource ??= CompilerContext.current.uriToSource;
28+
return uriToSource[location.file]?.getTextLine(location.line);
2829
}
2930

3031
Location getLocationFromNode(TreeNode node) {

pkg/front_end/test/spell_checking_list_tests.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ compilations
126126
compiler's
127127
complement
128128
completers
129+
complicated
129130
confidence
130131
confident
131132
confirm
@@ -400,6 +401,7 @@ linebreaks
400401
lints
401402
linux
402403
listening
404+
listing
403405
literal2
404406
ln
405407
local1a
@@ -463,6 +465,7 @@ negatable
463465
newworld
464466
nil
465467
ninja
468+
noisy
466469
nondefault
467470
nonexisting
468471
noo

0 commit comments

Comments
 (0)