Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Updates status file to expect MissingCompileTimeError for illegal
Browse files Browse the repository at this point in the history
async function return type check whenever running in 'legacy mode'.

Adapts language_2_kernel.status such that a MissingCompileTimeError is
expected for illegal return types of async functions when running in
'legacy mode'. Updates the commentary in finishFunction in
body_builder.dart.

Some legacy tests* have revealed that it may not always be correct to
check whether [strongMode] is enabled before checking the return type of
async functions. The reason behind the strongMode check was to ensure
that [_typeInferrer.typeSchemaEnvironment] would be instantiated as
per ahe's suggestion.

There seems to be some inconsistency in the code base as to when
[_typeInferrer.typeSchemaEnvironment] is non-null. For example, during
the fasta perf benchmarks one may observe a null value, whilst it
seems that the member is always non-null when running `dart
--no-preview-dart-2 <script.dart>`.

* test log: https://ci.chromium.org/p/dart/builders/luci.dart.ci.sandbox/front-end-legacy-linux-release-x64/621

Change-Id: I2211bfe0ae75a7aa35e2d698ff5cba27af484d07
Bug: 33425
Reviewed-on: https://dart-review.googlesource.com/69920
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
  • Loading branch information
Daniel Hillerström authored and commit-bot@chromium.org committed Aug 15, 2018
1 parent a517d19 commit b13c4e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/front_end/lib/src/fasta/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,16 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>

// For async functions with declared return types, we need to determine
// whether those types are valid.
// TODO(hillerstrom): currently we need to check whether strongMode is
// enabled (or rather that we are not running in 'legacy mode') otherwise
// [_typeInferrer.typeSchemaEnvironment] might be null. We should remove this
// check once Dart 1 supported has been dropped.
if (library.loader.target.strongMode &&

// TODO(hillerstrom): currently, we need to check whether [strongMode] is
// enabled for two reasons:
// 1) the [isSubtypeOf] predicate produces false-negatives when [strongMode]
// is false.
// 2) the member [_typeInferrer.typeSchemaEnvironment] might be null when
// [strongMode] is false. This particular behaviour can be observed when
// running the fasta perf benchmarks.
bool strongMode = library.loader.target.strongMode;
if (strongMode &&
builder.returnType != null &&
asyncModifier == AsyncMarker.Async) {
DartType returnType = builder.function.returnType;
Expand All @@ -726,7 +731,8 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
// TODO(hillerstrom): once types get annotated with location
// information, we can improve the quality of the error message by
// using the offset of [returnType].
addProblem(fasta.messageIllegalAsyncReturnType, member.charOffset, 0);
addProblem(fasta.messageIllegalAsyncReturnType, member.charOffset,
member.name.length);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/language_2/language_2_kernel.status
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,9 @@ async_congruence_local_test/02: MissingCompileTimeError
async_congruence_method_test/01: MissingCompileTimeError
async_congruence_unnamed_test/01: MissingCompileTimeError
async_congruence_unnamed_test/02: MissingCompileTimeError
async_or_generator_return_type_stacktrace_test/01: MissingCompileTimeError
async_return_types_test/tooManyTypeParameters: MissingCompileTimeError
async_return_types_test/wrongReturnType: MissingCompileTimeError
async_return_types_test/wrongTypeParameter: MissingCompileTimeError
bad_named_parameters2_test/01: MissingCompileTimeError
bad_named_parameters_test/01: MissingCompileTimeError
Expand Down

0 comments on commit b13c4e4

Please sign in to comment.