Remove hack; test fix for #35441
Change-Id: I9505598e904e4ee39b00cbae87082f5f332f3505
Reviewed-on: https://dart-review.googlesource.com/c/87612
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 1ca5d3f..545cd6c 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -904,11 +904,6 @@
if (type.isUndefined) {
return false;
}
- // TODO(mfairhurst): Remove this once #33441 is solved and we can use
- // inference properly. This is a hack.
- if (obj.type == typeProvider.intType && type == typeProvider.doubleType) {
- return true;
- }
return obj.type.isSubtypeOf(type);
}
diff --git a/pkg/analyzer/lib/src/dart/constant/utilities.dart b/pkg/analyzer/lib/src/dart/constant/utilities.dart
index 233ea04..6a806c3 100644
--- a/pkg/analyzer/lib/src/dart/constant/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/constant/utilities.dart
@@ -78,6 +78,13 @@
}
@override
+ IntegerLiteral visitIntegerLiteral(IntegerLiteral node) {
+ IntegerLiteral integer = super.visitIntegerLiteral(node);
+ integer.staticType = node.staticType;
+ return integer;
+ }
+
+ @override
ListLiteral visitListLiteral(ListLiteral node) {
ListLiteral literal = super.visitListLiteral(node);
literal.staticType = node.staticType;
diff --git a/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart
index 1871a37..87b7388 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_driver_test.dart
@@ -12,17 +12,39 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(NonErrorResolverTest_Driver);
+ defineReflectiveTests(NonConstantValueInInitializer);
});
}
@reflectiveTest
class NonConstantValueInInitializer extends ResolverTestCase {
@override
- List<String> get enabledExperiments => [EnableString.set_literals];
+ List<String> get enabledExperiments => [EnableString.constant_update_2018];
@override
bool get enableNewAnalysisDriver => true;
+ test_intLiteralInDoubleContext_const_exact() async {
+ Source source = addSource(r'''
+const double x = 0;
+class C {
+ const C(double y) : assert(y is double), assert(x is double);
+}
+@C(0)
+@C(-0)
+@C(0x0)
+@C(-0x0)
+void main() {
+ const C(0);
+ const C(-0);
+ const C(0x0);
+ const C(-0x0);
+}''');
+ await computeAnalysisResult(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
test_isCheckInConstAssert() async {
Source source = addSource(r'''
class C {
@@ -52,12 +74,6 @@
@override
@failingTest
- test_intLiteralInDoubleContext_const_exact() {
- return super.test_intLiteralInDoubleContext_const_exact();
- }
-
- @override
- @failingTest
test_null_callOperator() {
return super.test_null_callOperator();
}
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index 2b881c0..5b3be54 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -50,12 +50,6 @@
}
@override
- @failingTest
- test_intLiteralInDoubleContext_const_exact() {
- return super.test_intLiteralInDoubleContext_const_exact();
- }
-
- @override
@failingTest // Fails with the old task model
test_issue_32394() {
return super.test_issue_32394();
@@ -2642,28 +2636,6 @@
verify([source]);
}
- test_intLiteralInDoubleContext_const_exact() async {
- Source source = addSource(r'''
-class C {
- const C(double x)
- : assert("$x" == "0.0")
- , assert(identical(x, 0.0));
-}
-@C(0)
-@C(-0)
-@C(0x0)
-@C(-0x0)
-void main() {
- const C(0);
- const C(-0);
- const C(0x0);
- const C(-0x0);
-}''');
- await computeAnalysisResult(source);
- assertNoErrors(source);
- verify([source]);
- }
-
test_invalidAnnotation_constantVariable_field() async {
Source source = addSource(r'''
@A.C