mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[cfe] Infer loadLibrary return a non-nullable future
Closes #41122 Change-Id: I1ca82e27cc73900e19369d152cec4f7a7621777b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140400 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This commit is contained in:
parent
e687aa9a29
commit
4e1954fa08
8 changed files with 98 additions and 2 deletions
|
@ -5684,7 +5684,7 @@ class InferenceVisitor
|
|||
ExpressionInferenceResult visitLoadLibrary(
|
||||
covariant LoadLibraryImpl node, DartType typeContext) {
|
||||
DartType inferredType = inferrer.typeSchemaEnvironment
|
||||
.futureType(const DynamicType(), inferrer.library.nullable);
|
||||
.futureType(const DynamicType(), inferrer.library.nonNullable);
|
||||
if (node.arguments != null) {
|
||||
FunctionType calleeType =
|
||||
new FunctionType([], inferredType, inferrer.library.nonNullable);
|
||||
|
@ -5699,7 +5699,7 @@ class InferenceVisitor
|
|||
DartType inferredType = new FunctionType(
|
||||
[],
|
||||
inferrer.typeSchemaEnvironment
|
||||
.futureType(const DynamicType(), inferrer.library.nullable),
|
||||
.futureType(const DynamicType(), inferrer.library.nonNullable),
|
||||
inferrer.library.nonNullable);
|
||||
Expression replacement = new StaticGet(node.target)
|
||||
..fileOffset = node.fileOffset;
|
||||
|
|
12
pkg/front_end/testcases/nnbd/load_library.dart
Normal file
12
pkg/front_end/testcases/nnbd/load_library.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2020, 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:math" deferred as math;
|
||||
|
||||
main() {
|
||||
var v1 = math.loadLibrary();
|
||||
v1.then((_) {});
|
||||
var v2 = math.loadLibrary;
|
||||
v2().then((_) {});
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
|
||||
import "dart:math" deferred as math;
|
||||
|
||||
static method main() → dynamic
|
||||
;
|
19
pkg/front_end/testcases/nnbd/load_library.dart.strong.expect
Normal file
19
pkg/front_end/testcases/nnbd/load_library.dart.strong.expect
Normal file
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:async" as asy;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "dart:math" deferred as math;
|
||||
|
||||
static method main() → dynamic {
|
||||
asy::Future<dynamic> v1 = LoadLibrary(math);
|
||||
v1.{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
() → asy::Future<dynamic> v2 = #C1;
|
||||
v2.call().{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
}
|
||||
static method _#loadLibrary_math() → asy::Future<dynamic>
|
||||
return LoadLibrary(math);
|
||||
|
||||
constants {
|
||||
#C1 = tearoff self::_#loadLibrary_math
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:async" as asy;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "dart:math" deferred as math;
|
||||
|
||||
static method main() → dynamic {
|
||||
asy::Future<dynamic> v1 = LoadLibrary(math);
|
||||
v1.{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
() → asy::Future<dynamic> v2 = #C1;
|
||||
v2.call().{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
}
|
||||
static method _#loadLibrary_math() → asy::Future<dynamic>
|
||||
return LoadLibrary(math);
|
||||
|
||||
constants {
|
||||
#C1 = tearoff self::_#loadLibrary_math
|
||||
}
|
19
pkg/front_end/testcases/nnbd/load_library.dart.weak.expect
Normal file
19
pkg/front_end/testcases/nnbd/load_library.dart.weak.expect
Normal file
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:async" as asy;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "dart:math" deferred as math;
|
||||
|
||||
static method main() → dynamic {
|
||||
asy::Future<dynamic> v1 = LoadLibrary(math);
|
||||
v1.{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
() → asy::Future<dynamic> v2 = #C1;
|
||||
v2.call().{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
}
|
||||
static method _#loadLibrary_math() → asy::Future<dynamic>
|
||||
return LoadLibrary(math);
|
||||
|
||||
constants {
|
||||
#C1 = tearoff self::_#loadLibrary_math
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:async" as asy;
|
||||
import "dart:core" as core;
|
||||
|
||||
import "dart:math" deferred as math;
|
||||
|
||||
static method main() → dynamic {
|
||||
asy::Future<dynamic> v1 = LoadLibrary(math);
|
||||
v1.{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
() → asy::Future<dynamic> v2 = #C1;
|
||||
v2.call().{asy::Future::then}<core::Null?>((dynamic _) → core::Null? {});
|
||||
}
|
||||
static method _#loadLibrary_math() → asy::Future<dynamic>
|
||||
return LoadLibrary(math);
|
||||
|
||||
constants {
|
||||
#C1 = tearoff self::_#loadLibrary_math
|
||||
}
|
|
@ -1301,6 +1301,7 @@ nnbd/later: TextSerializationFailure
|
|||
nnbd/lhs_of_if_null: TextSerializationFailure
|
||||
nnbd/list_constructor: TextSerializationFailure
|
||||
nnbd/literal_from_opt_in: TextSerializationFailure
|
||||
nnbd/load_library: TextSerializationFailure
|
||||
nnbd/member_inheritance_from_opt_in: TextSerializationFailure
|
||||
nnbd/member_inheritance_from_opt_out: TextSerializationFailure
|
||||
nnbd/messages_with_types_opt_in: TypeCheckError
|
||||
|
|
Loading…
Reference in a new issue