27446b463e
+ use the inferred return type in error reporting when no return type is declared. This turned up in this particular case where we report an error between the returned value and the inferred return type. Closes #42546 Change-Id: I48da24047f2e92ca91a514dfcb43c2ba6f65ee46 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153610 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
42 lines
1.7 KiB
Dart
42 lines
1.7 KiB
Dart
// Copyright (c) 2015, 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 Derived<T> implements Future<T> {
|
|
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
|
}
|
|
|
|
class FixedPoint<T> implements Future<FixedPoint<T>> {
|
|
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
|
}
|
|
|
|
class Divergent<T> implements Future<Divergent<Divergent<T>>> {
|
|
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
|
}
|
|
|
|
test() async {
|
|
// flatten(Derived<int>) = int
|
|
int x = await new Derived<int>(); //# 01: runtime error
|
|
Future<int> f() async => new Derived<int>(); //# 02: ok
|
|
Future<int> f() async { return new Derived<int>(); } //# 03: ok
|
|
Future<int> x = (() async => new Derived<int>())(); //# 04: runtime error
|
|
|
|
// flatten(FixedPoint<int>) = FixedPoint<int>
|
|
FixedPoint<int> x = await new FixedPoint<int>(); //# 05: runtime error
|
|
Future<FixedPoint<int>> f() async => new FixedPoint<int>(); //# 06: ok
|
|
Future<FixedPoint<int>> f() async { return new FixedPoint<int>(); } //# 07: ok
|
|
Future<FixedPoint<int>> x = (() async => new FixedPoint<int>())(); //# 08: runtime error
|
|
|
|
// flatten(Divergent<int>) = Divergent<Divergent<int>>
|
|
Divergent<Divergent<int>> x = await new Divergent<int>(); //# 09: runtime error
|
|
Future<Divergent<Divergent<int>>> f() async => new Divergent<int>(); //# 10: ok
|
|
Future<Divergent<Divergent<int>>> f() async { return new Divergent<int>(); } //# 11: ok
|
|
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())(); //# 12: compile-time error
|
|
}
|
|
|
|
main() {
|
|
test();
|
|
}
|