Revert "Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything."
This reverts commit 838c926f64.
Reason for revert: breaks google3. See b/281948666
Original change's description:
> Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
>
> Bug: https://github.com/dart-lang/sdk/issues/35828
> Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: I05ddcf7657069b1e889b5b0019faaf7301f6643b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302781
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
375e83d08c
commit
d3c7e183e9
@@ -374,26 +374,14 @@ f(int expr) {
|
||||
|
||||
Future<void> test_negateCascade() async {
|
||||
await _prepareCompletion('.not', '''
|
||||
void f(bool expr) {
|
||||
f(bool expr) {
|
||||
if (expr..a..b..c.not)
|
||||
}
|
||||
|
||||
extension on bool {
|
||||
void a() {}
|
||||
void b() {}
|
||||
void c() {}
|
||||
}
|
||||
''');
|
||||
_assertHasChange('Expand .not', '''
|
||||
void f(bool expr) {
|
||||
f(bool expr) {
|
||||
if (!expr..a..b..c)
|
||||
}
|
||||
|
||||
extension on bool {
|
||||
void a() {}
|
||||
void b() {}
|
||||
void c() {}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@ class SubtypeHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
// `InvalidType` is treated as a top and a bottom type.
|
||||
if (identical(T0_, InvalidTypeImpl.instance) ||
|
||||
identical(T1_, InvalidTypeImpl.instance)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var T0 = T0_ as TypeImpl;
|
||||
var T1 = T1_ as TypeImpl;
|
||||
|
||||
|
||||
@@ -739,8 +739,6 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
/// [WarningCode.UNNECESSARY_TYPE_CHECK_FALSE].
|
||||
bool _checkAllTypeChecks(IsExpression node) {
|
||||
var leftNode = node.expression;
|
||||
var leftType = leftNode.typeOrThrow;
|
||||
|
||||
var rightNode = node.type;
|
||||
var rightType = rightNode.type as TypeImpl;
|
||||
|
||||
@@ -753,11 +751,6 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
);
|
||||
}
|
||||
|
||||
// `cannotResolve is X` or `cannotResolve is! X`
|
||||
if (leftType is InvalidType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// `is dynamic` or `is! dynamic`
|
||||
if (rightType is DynamicType) {
|
||||
report();
|
||||
@@ -785,6 +778,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
|
||||
if (_isNonNullableByDefault) {
|
||||
var leftType = leftNode.typeOrThrow;
|
||||
if (_typeSystem.isSubtypeOf(leftType, rightType)) {
|
||||
report();
|
||||
return true;
|
||||
|
||||
@@ -22,7 +22,6 @@ mixin StringTypes on AbstractTypeSystemTest {
|
||||
|
||||
void defineStringTypes() {
|
||||
_defineType('dynamic', dynamicType);
|
||||
_defineType('InvalidType', invalidType);
|
||||
_defineType('void', voidNone);
|
||||
|
||||
_defineType('Never', neverNone);
|
||||
|
||||
@@ -2677,11 +2677,6 @@ class SubtypeTest extends _SubtypingTestBase with StringTypes {
|
||||
isNotSubtype(A_num, A_int, strT0: "A<num>", strT1: "A<int>");
|
||||
}
|
||||
|
||||
test_invalidType() {
|
||||
isSubtype2('InvalidType', 'int');
|
||||
isSubtype2('int', 'InvalidType');
|
||||
}
|
||||
|
||||
test_multi_function_nonGeneric_oneArgument() {
|
||||
isSubtype2('num* Function(num*)*', 'num* Function(int*)*');
|
||||
isSubtype2('int* Function(num*)*', 'num* Function(num*)*');
|
||||
|
||||
@@ -527,7 +527,7 @@ BinaryExpression
|
||||
staticType: InvalidType
|
||||
staticElement: dart:core::@class::num::@method::*
|
||||
staticInvokeType: num Function(num)
|
||||
staticType: double
|
||||
staticType: num
|
||||
''');
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ VariableDeclaration
|
||||
staticElement: <null>
|
||||
staticType: InvalidType
|
||||
declaredElement: @99
|
||||
type: InvalidType Function(Object?)
|
||||
type: int Function(Object?)
|
||||
parameter: ParameterMember
|
||||
base: root::@parameter::b
|
||||
substitution: {T: String}
|
||||
staticType: InvalidType Function(Object?)
|
||||
staticType: int Function(Object?)
|
||||
rightParenthesis: )
|
||||
staticInvokeType: String? Function(String Function(), int Function(String))
|
||||
staticType: String?
|
||||
|
||||
@@ -37,18 +37,6 @@ void f(dynamic a) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_argument_invalidType() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void foo<T extends num>(T t) {}
|
||||
|
||||
void f(X x) {
|
||||
foo(x);
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.UNDEFINED_CLASS, 40, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_functionType() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f<X>() {}
|
||||
|
||||
@@ -152,16 +152,6 @@ class UnnecessaryTypeCheckFalseWithoutNullSafetyTest
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckTrueTest extends PubPackageResolutionTest
|
||||
with UnnecessaryTypeCheckTrueTestCases {
|
||||
test_expressionInvalidType() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f(A a) {
|
||||
a is num;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.UNDEFINED_CLASS, 7, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_typeNonNullable_is_same() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f(int a) {
|
||||
|
||||
@@ -10,6 +10,8 @@ class Foo<T> {
|
||||
Foo() {}
|
||||
T make() {
|
||||
return new T();
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_CAST_NEW_EXPR
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CREATION_WITH_NON_TYPE
|
||||
// [cfe] Couldn't find constructor 'T'.
|
||||
|
||||
Reference in New Issue
Block a user