dart-sdk/tests/language_2/implements_futureor_test.dart
Daniel Hillerström 8b92fe3bbd Checks whether a class extends or implements FutureOr.
According to the specification (§10.9) it is a compile-time error to
extend, implement, or use FutureOr as a mixin.

Expands the "multiple implements" check to include a test for whether
a class attempts to extend or implement the 'FutureOr' class.

The mixin case is indirectly caught by another syntactic check for
mixed in types (c.f. checkSemantics method in source_loader.dart). It
verifies whether a mixin has zero constructors. Since FutureOr has a
constructor the check fails. This is technically enough to meet the
specification, but it leads to a confusing error message for this
particular case. To improve the quality of the error message, we may
want to merge some of the mixed in check into checkSupertypes in
kernel_class_builder.dart.

Closes https://github.com/dart-lang/sdk/issues/33744

Change-Id: I887ea9431fd50059399937f4236523ed917e3673
Reviewed-on: https://dart-review.googlesource.com/71141
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-08-27 08:31:15 +00:00

14 lines
338 B
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
class A<T>
implements FutureOr<T> //# 01: compile-time error
{}
void main() {
A a = new A();
}