Skip to content

Commit af5a466

Browse files
fishythefishcommit-bot@chromium.org
authored andcommitted
[dart2js] (Old RTI) Check function subtypes after checking for FutureOr.
Change-Id: I7d2feab60295304377e48fddce901aea1c79ce19 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112481 Reviewed-by: Stephen Adams <[email protected]>
1 parent a6b0cd8 commit af5a466

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

sdk/lib/_internal/js_runtime/lib/js_rti.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,16 +713,6 @@ bool _isSubtype(var s, var sEnv, var t, var tEnv) {
713713

714714
if (isNullType(s)) return true;
715715

716-
if (isDartFunctionType(t)) {
717-
return _isFunctionSubtype(s, sEnv, t, tEnv);
718-
}
719-
720-
if (isDartFunctionType(s)) {
721-
// Check function types against the `Function` class (`Object` is also a
722-
// supertype, but is tested above with other 'top' types.).
723-
return isDartFunctionTypeRti(t);
724-
}
725-
726716
// Get the object describing the class and check for the subtyping flag
727717
// constructed from the type of [s].
728718
var typeOfS = isJsArray(s) ? getIndex(s, 0) : s;
@@ -755,6 +745,16 @@ bool _isSubtype(var s, var sEnv, var t, var tEnv) {
755745
}
756746
}
757747

748+
if (isDartFunctionType(t)) {
749+
return _isFunctionSubtype(s, sEnv, t, tEnv);
750+
}
751+
752+
if (isDartFunctionType(s)) {
753+
// Check function types against the `Function` class (`Object` is also a
754+
// supertype, but is tested above with other 'top' types.).
755+
return isDartFunctionTypeRti(t);
756+
}
757+
758758
// Get the object describing the class and check for the subtyping flag
759759
// constructed from the type of [t].
760760
var typeOfT = isJsArray(t) ? getIndex(t, 0) : t;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
import 'package:expect/expect.dart';
7+
8+
main() {
9+
Expect.subtype<void Function(), FutureOr<void Function()>>();
10+
}

0 commit comments

Comments
 (0)