Skip to content

Commit 895413f

Browse files
srujzsCommit Queue
authored andcommitted
[analyzer] Add special case for bool.fromEnvironment('dart.library.js_interop')
#50045 Treats this value as unknown in the meantime while issue 50045 gets resolved to unblock Flutter (much like we did with js_util). Change-Id: I3dbf01a2eba1b8b3835a2cdc46bb23c2957dca8b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439820 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Srujan Gaddam <[email protected]>
1 parent 5ce3cd2 commit 895413f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,9 @@ class _InstanceCreationEvaluator {
29052905
String? variableName =
29062906
argumentCount < 1 ? null : firstArgument?.toStringValue();
29072907
if (definingClass == typeProvider.boolElement) {
2908-
// Special case: https://github.com/dart-lang/sdk/issues/50045
2909-
if (variableName == 'dart.library.js_util') {
2908+
// Special cases: https://github.com/dart-lang/sdk/issues/50045
2909+
if (variableName == 'dart.library.js_util' ||
2910+
variableName == 'dart.library.js_interop') {
29102911
return DartObjectImpl(
29112912
typeSystem,
29122913
typeProvider.boolType,

pkg/analyzer/test/src/dart/constant/evaluation_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6050,6 +6050,18 @@ bool true
60506050
''');
60516051
}
60526052

6053+
/// See https://github.com/dart-lang/sdk/issues/50045
6054+
test_bool_fromEnvironment_dartLibraryJsInterop() async {
6055+
await assertNoErrorsInCode('''
6056+
const a = bool.fromEnvironment('dart.library.js_interop');
6057+
''');
6058+
var result = _topLevelVar('a');
6059+
assertDartObjectText(result, '''
6060+
<unknown> bool
6061+
variable: <testLibrary>::@topLevelVariable::a
6062+
''');
6063+
}
6064+
60536065
/// See https://github.com/dart-lang/sdk/issues/50045
60546066
test_bool_fromEnvironment_dartLibraryJsUtil() async {
60556067
await assertNoErrorsInCode('''

0 commit comments

Comments
 (0)