Skip to content

Commit

Permalink
Version 3.3.0-262.0.dev
Browse files Browse the repository at this point in the history
Merge 7e5ce1f into dev
  • Loading branch information
Dart CI committed Dec 27, 2023
2 parents add161c + 7e5ce1f commit 5084fdc
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/analyzer/lib/src/dart/constant/value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1175,13 +1175,20 @@ class DoubleState extends NumState {

@override
BoolState isIdentical(TypeSystemImpl typeSystem, InstanceState rightOperand) {
final value = this.value;
if (value == null) {
return BoolState.UNKNOWN_VALUE;
} else if (value.isNaN) {
// `double.nan` equality will always be `false`.
return BoolState.FALSE_STATE;
}
if (rightOperand is DoubleState) {
var rightValue = rightOperand.value;
if (rightValue == null) {
return BoolState.UNKNOWN_VALUE;
} else if (rightValue.isNaN) {
// `double.nan` equality will always be `false`.
return BoolState.FALSE_STATE;
}
return BoolState.from(identical(value, rightValue));
} else if (rightOperand is IntState) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ class InterfaceLeastUpperBoundHelper {
return type.nullabilitySuffix == NullabilitySuffix.none ? 1 : 0;
}
}

// Extension type without interfaces, implicit `Object?`
if (element is ExtensionTypeElement) {
if (element.interfaces.isEmpty) {
return 1;
}
}

int longestPath = 0;
try {
visitedElements.add(element);
Expand Down
30 changes: 30 additions & 0 deletions pkg/analyzer/test/src/dart/constant/evaluation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3563,6 +3563,36 @@ double Infinity
''');
}

test_visitBinaryExpression_eqeq_double_double_nan_left() async {
await assertErrorsInCode('''
const c = double.nan == 2.3;
''', [
error(WarningCode.UNNECESSARY_NAN_COMPARISON_FALSE, 10, 13),
]);
// This test case produces an warning, but the value of the constant should
// be `false`.
final result = _topLevelVar('c');
assertDartObjectText(result, r'''
bool false
variable: self::@variable::c
''');
}

test_visitBinaryExpression_eqeq_double_double_nan_right() async {
await assertErrorsInCode('''
const c = 2.3 == double.nan;
''', [
error(WarningCode.UNNECESSARY_NAN_COMPARISON_FALSE, 14, 13),
]);
// This test case produces an warning, but the value of the constant should
// be `false`.
final result = _topLevelVar('c');
assertDartObjectText(result, r'''
bool false
variable: self::@variable::c
''');
}

test_visitBinaryExpression_minus_double_double() async {
await assertNoErrorsInCode('''
const c = 3.2 - 2.3;
Expand Down
32 changes: 32 additions & 0 deletions pkg/analyzer/test/src/dart/element/upper_lower_bound_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,38 @@ class UpperBoundTest extends _BoundsTestBase {
);
}

void test_extensionType_implementExtensionType_implicitObjectQuestion() {
// extension type A(Object?) {}
// extension type B(Object?) implements A {}
// extension type C(Object?) implements A {}

final A_none = interfaceTypeNone(
extensionType(
'A',
representationType: objectQuestion,
interfaces: [],
),
);

_checkLeastUpperBound(
interfaceTypeNone(
extensionType(
'B',
representationType: objectQuestion,
interfaces: [A_none],
),
),
interfaceTypeNone(
extensionType(
'C',
representationType: objectQuestion,
interfaces: [A_none],
),
),
A_none,
);
}

void test_extensionType_noTypeParameters_interfaces() {
// extension type A(int) implements int {}
// extension type B(double) implements double {}
Expand Down
3 changes: 3 additions & 0 deletions pkg/compiler/lib/src/ir/scope_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ class ScopeModelBuilder extends ir.VisitorDefault<EvaluationComplexity>
@override
EvaluationComplexity visitStructuralParameter(
ir.StructuralParameter typeParameter) {
// Visit the default type to register any necessary type parameters that RTI
// might need if the associated function is used as a generic tear off.
visitNode(typeParameter.defaultType);
return const EvaluationComplexity.constant();
}

Expand Down
25 changes: 25 additions & 0 deletions tests/web/regress/issue/54451_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2023, 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.

// Tests that the bounds for structural parameters of a Function type are
// visited and any type variables RTI might need are registered.

class A<T> {
void foo1() {
void bar1<Z extends void Function<Y extends T>()>() {}
print(bar1.runtimeType); // Crashes compiler if A.T is not accessible.
}
}

extension<T> on T {
void foo2() {
void bar2<Z extends void Function<Y extends T>()>() {}
print(bar2.runtimeType); // Crashes compiler if T is not accessible.
}
}

void main() {
A<int>().foo1();
1.foo2();
}
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 3
PATCH 0
PRERELEASE 261
PRERELEASE 262
PRERELEASE_PATCH 0

0 comments on commit 5084fdc

Please sign in to comment.