From 4190705bbdff4bb8400d32c2ebccf382fdcf6d3b Mon Sep 17 00:00:00 2001 From: Brian Wilkerson Date: Mon, 23 Jul 2018 20:05:40 +0000 Subject: [PATCH] Update the failing tests in StaticTypeWarningCodeTest_Kernel Change-Id: Idb963897413a34b8bdd11d53fee84fd9fd956f57 Reviewed-on: https://dart-review.googlesource.com/66222 Reviewed-by: Konstantin Shcheglov Reviewed-by: Paul Berry Commit-Queue: Brian Wilkerson --- .../static_type_warning_code_kernel_test.dart | 504 +-------------- .../static_type_warning_code_test.dart | 577 ++++++++++++++---- 2 files changed, 446 insertions(+), 635 deletions(-) diff --git a/pkg/analyzer/test/generated/static_type_warning_code_kernel_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_kernel_test.dart index 65037ea5ed3..e3cb408c8c6 100644 --- a/pkg/analyzer/test/generated/static_type_warning_code_kernel_test.dart +++ b/pkg/analyzer/test/generated/static_type_warning_code_kernel_test.dart @@ -30,87 +30,69 @@ class StaticTypeWarningCodeTest_Kernel @override bool get usingFastaParser => true; - @override - @failingTest - test_ambiguousImport_function() async { - // Bad state: No reference information for f at 53 - await super.test_ambiguousImport_function(); - } - @override @failingTest test_assert_message_suppresses_type_promotion() async { - // Bad state: No reference information for () {x = new C(); return 'msg';}() at 89 await super.test_assert_message_suppresses_type_promotion(); } @override @failingTest test_illegalAsyncGeneratorReturnType_function_nonStream() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalAsyncGeneratorReturnType_function_nonStream(); } @override @failingTest test_illegalAsyncGeneratorReturnType_function_subtypeOfStream() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalAsyncGeneratorReturnType_function_subtypeOfStream(); } @override @failingTest test_illegalAsyncGeneratorReturnType_method_nonStream() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalAsyncGeneratorReturnType_method_nonStream(); } @override @failingTest test_illegalAsyncGeneratorReturnType_method_subtypeOfStream() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalAsyncGeneratorReturnType_method_subtypeOfStream(); } @override @failingTest test_illegalAsyncReturnType_function_nonFuture() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, found 0 await super.test_illegalAsyncReturnType_function_nonFuture(); } @override @failingTest test_illegalAsyncReturnType_function_subtypeOfFuture() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, found 0 await super.test_illegalAsyncReturnType_function_subtypeOfFuture(); } @override @failingTest test_illegalAsyncReturnType_method_nonFuture() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, found 0 await super.test_illegalAsyncReturnType_method_nonFuture(); } @override @failingTest test_illegalAsyncReturnType_method_subtypeOfFuture() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, found 0 await super.test_illegalAsyncReturnType_method_subtypeOfFuture(); } @override @failingTest test_illegalSyncGeneratorReturnType_function_nonIterator() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalSyncGeneratorReturnType_function_nonIterator(); } @override @failingTest test_illegalSyncGeneratorReturnType_function_subclassOfIterator() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super .test_illegalSyncGeneratorReturnType_function_subclassOfIterator(); } @@ -118,327 +100,84 @@ class StaticTypeWarningCodeTest_Kernel @override @failingTest test_illegalSyncGeneratorReturnType_method_nonIterator() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalSyncGeneratorReturnType_method_nonIterator(); } @override @failingTest test_illegalSyncGeneratorReturnType_method_subclassOfIterator() async { - // Expected 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_illegalSyncGeneratorReturnType_method_subclassOfIterator(); } - @override - @failingTest - test_inconsistentMethodInheritance_paramCount() async { - // Expected 1 errors of type StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, found 0 - await super.test_inconsistentMethodInheritance_paramCount(); - } - - @override - @failingTest - test_inconsistentMethodInheritance_paramType() async { - // Expected 1 errors of type StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, found 0 - await super.test_inconsistentMethodInheritance_paramType(); - } - - @override - @failingTest - test_inconsistentMethodInheritance_returnType() async { - // Expected 1 errors of type StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, found 0 - await super.test_inconsistentMethodInheritance_returnType(); - } - @override @failingTest test_instanceAccessToStaticMember_method_invocation() async { - // Expected 1 errors of type StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, found 0 await super.test_instanceAccessToStaticMember_method_invocation(); } @override @failingTest test_instanceAccessToStaticMember_method_reference() async { - // Expected 1 errors of type StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, found 0 await super.test_instanceAccessToStaticMember_method_reference(); } @override @failingTest test_instanceAccessToStaticMember_propertyAccess_field() async { - // Expected 1 errors of type StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, found 0 await super.test_instanceAccessToStaticMember_propertyAccess_field(); } @override @failingTest test_instanceAccessToStaticMember_propertyAccess_getter() async { - // Expected 1 errors of type StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, found 0 await super.test_instanceAccessToStaticMember_propertyAccess_getter(); } @override @failingTest test_instanceAccessToStaticMember_propertyAccess_setter() async { - // Expected 1 errors of type StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, found 0 await super.test_instanceAccessToStaticMember_propertyAccess_setter(); } @override @failingTest test_invalidAssignment_dynamic() async { - // Bad state: No reference information for dynamic at 11 await super.test_invalidAssignment_dynamic(); } - @override - @failingTest - test_invocationOfNonFunction_localObject() async { - // Expected 1 errors of type StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, found 0 - await super.test_invocationOfNonFunction_localObject(); - } - - @override - @failingTest - test_invocationOfNonFunction_localVariable() async { - // Expected 1 errors of type StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, found 0 - await super.test_invocationOfNonFunction_localVariable(); - } - - @override - @failingTest - test_invocationOfNonFunction_ordinaryInvocation() async { - // Expected 1 errors of type StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, found 0 - await super.test_invocationOfNonFunction_ordinaryInvocation(); - } - - @override - @failingTest - test_invocationOfNonFunction_staticInvocation() async { - // Expected 1 errors of type StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, found 0 - await super.test_invocationOfNonFunction_staticInvocation(); - } - - @override - @failingTest - test_invocationOfNonFunction_superExpression() async { - // Expected 1 errors of type StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, found 0 - await super.test_invocationOfNonFunction_superExpression(); - } - - @override - @failingTest - test_invocationOfNonFunctionExpression_literal() async { - // Bad state: Expected a type for 5 at 10; got one for kernel offset 9 - await super.test_invocationOfNonFunctionExpression_literal(); - } - - @override - @failingTest - test_nonBoolCondition_conditional() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_CONDITION, found 0 - await super.test_nonBoolCondition_conditional(); - } - - @override - @failingTest - test_nonBoolCondition_do() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_CONDITION, found 0 - await super.test_nonBoolCondition_do(); - } - - @override - @failingTest - test_nonBoolCondition_for() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_CONDITION, found 0 - await super.test_nonBoolCondition_for(); - } - - @override - @failingTest - test_nonBoolCondition_if() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_CONDITION, found 0 - await super.test_nonBoolCondition_if(); - } - - @override - @failingTest - test_nonBoolCondition_while() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_CONDITION, found 0 - await super.test_nonBoolCondition_while(); - } - - @override - @failingTest - test_nonBoolExpression_functionType_bool() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_EXPRESSION, found 0 - await super.test_nonBoolExpression_functionType_bool(); - } - - @override - @failingTest - test_nonBoolExpression_functionType_int() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_EXPRESSION, found 0 - await super.test_nonBoolExpression_functionType_int(); - } - - @override - @failingTest - test_nonBoolExpression_interfaceType() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_EXPRESSION, found 0 - await super.test_nonBoolExpression_interfaceType(); - } - - @override - @failingTest - test_nonBoolNegationExpression() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION, found 0 - await super.test_nonBoolNegationExpression(); - } - - @override - @failingTest - test_nonBoolOperand_and_left() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_OPERAND, found 0 - await super.test_nonBoolOperand_and_left(); - } - - @override - @failingTest - test_nonBoolOperand_and_right() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_OPERAND, found 0 - await super.test_nonBoolOperand_and_right(); - } - - @override - @failingTest - test_nonBoolOperand_or_left() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_OPERAND, found 0 - await super.test_nonBoolOperand_or_left(); - } - - @override - @failingTest - test_nonBoolOperand_or_right() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_BOOL_OPERAND, found 0 - await super.test_nonBoolOperand_or_right(); - } - @override @failingTest test_nonTypeAsTypeArgument_notAType() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, found 0 await super.test_nonTypeAsTypeArgument_notAType(); } - @override - @failingTest - test_nonTypeAsTypeArgument_undefinedIdentifier() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, found 0 - await super.test_nonTypeAsTypeArgument_undefinedIdentifier(); - } - - @override - @failingTest - test_returnOfInvalidType_async_future_future_int_mismatches_future_int() { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, - // found 0; 0 errors of type StaticTypeWarningCode.INVALID_ASSIGNMENT, found - // 1 (54) - return super - .test_returnOfInvalidType_async_future_future_int_mismatches_future_int(); - } - - @override - @failingTest - test_returnOfInvalidType_async_future_int_mismatches_future_string() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super - .test_returnOfInvalidType_async_future_int_mismatches_future_string(); - } - @override @failingTest test_returnOfInvalidType_async_future_int_mismatches_int() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0; - // 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, found 0 await super.test_returnOfInvalidType_async_future_int_mismatches_int(); } @override @failingTest - test_returnOfInvalidType_expressionFunctionBody_function() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_expressionFunctionBody_function(); - } - - @override - @failingTest - test_returnOfInvalidType_expressionFunctionBody_getter() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_expressionFunctionBody_getter(); - } - - @override - @failingTest - test_returnOfInvalidType_expressionFunctionBody_localFunction() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_expressionFunctionBody_localFunction(); - } - - @override - @failingTest - test_returnOfInvalidType_expressionFunctionBody_method() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_expressionFunctionBody_method(); - } - - @override - @failingTest - test_returnOfInvalidType_function() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_function(); - } - - @override - @failingTest - test_returnOfInvalidType_getter() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_getter(); - } - - @override - @failingTest - test_returnOfInvalidType_localFunction() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_localFunction(); - } - - @override - @failingTest - test_returnOfInvalidType_method() async { - // Expected 1 errors of type StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, found 0 - await super.test_returnOfInvalidType_method(); + test_returnOfInvalidType_void() async { + await super.test_returnOfInvalidType_void(); } @override @failingTest test_typeArgumentNotMatchingBounds_classTypeAlias() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_classTypeAlias(); } @override @failingTest test_typeArgumentNotMatchingBounds_extends() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_extends(); } @override @failingTest test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super .test_typeArgumentNotMatchingBounds_extends_regressionInIssue18468Fix(); } @@ -446,28 +185,24 @@ class StaticTypeWarningCodeTest_Kernel @override @failingTest test_typeArgumentNotMatchingBounds_fieldFormalParameter() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_fieldFormalParameter(); } @override @failingTest test_typeArgumentNotMatchingBounds_functionReturnType() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_functionReturnType(); } @override @failingTest test_typeArgumentNotMatchingBounds_functionTypeAlias() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_functionTypeAlias(); } @override @failingTest test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super .test_typeArgumentNotMatchingBounds_functionTypedFormalParameter(); } @@ -475,21 +210,18 @@ class StaticTypeWarningCodeTest_Kernel @override @failingTest test_typeArgumentNotMatchingBounds_implements() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_implements(); } @override @failingTest test_typeArgumentNotMatchingBounds_is() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_is(); } @override @failingTest test_typeArgumentNotMatchingBounds_methodInvocation_localFunction() async { - // 'package:analyzer/src/fasta/resolution_applier.dart': Failed assertion: line 236 pos 18: 'typeParameter.bound == null': is not true. await super .test_typeArgumentNotMatchingBounds_methodInvocation_localFunction(); } @@ -497,14 +229,12 @@ class StaticTypeWarningCodeTest_Kernel @override @failingTest test_typeArgumentNotMatchingBounds_methodInvocation_method() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_methodInvocation_method(); } @override @failingTest test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super .test_typeArgumentNotMatchingBounds_methodInvocation_topLevelFunction(); } @@ -512,379 +242,150 @@ class StaticTypeWarningCodeTest_Kernel @override @failingTest test_typeArgumentNotMatchingBounds_methodReturnType() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_methodReturnType(); } @override @failingTest test_typeArgumentNotMatchingBounds_new() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_new(); } @override @failingTest test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound(); } @override @failingTest test_typeArgumentNotMatchingBounds_parameter() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_parameter(); } @override @failingTest test_typeArgumentNotMatchingBounds_redirectingConstructor() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0; - // 1 errors of type StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE, found 0 await super.test_typeArgumentNotMatchingBounds_redirectingConstructor(); } @override @failingTest test_typeArgumentNotMatchingBounds_typeArgumentList() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_typeArgumentList(); } @override @failingTest test_typeArgumentNotMatchingBounds_typeParameter() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_typeParameter(); } @override @failingTest test_typeArgumentNotMatchingBounds_variableDeclaration() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_variableDeclaration(); } @override @failingTest test_typeArgumentNotMatchingBounds_with() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, found 0 await super.test_typeArgumentNotMatchingBounds_with(); } @override @failingTest test_typeParameterSupertypeOfItsBound() async { - // Expected 1 errors of type StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND, found 0 await super.test_typeParameterSupertypeOfItsBound(); } @override @failingTest test_typePromotion_booleanAnd_useInRight_mutatedInLeft() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_GETTER, found 0 await super.test_typePromotion_booleanAnd_useInRight_mutatedInLeft(); } @override @failingTest test_typePromotion_if_and_right_hasAssignment() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_GETTER, found 0 await super.test_typePromotion_if_and_right_hasAssignment(); } - @override - @failingTest - test_undefinedFunction() async { - // Bad state: No reference information for g at 13 - await super.test_undefinedFunction(); - } - - @override - @failingTest - test_undefinedFunction_inCatch() async { - // Bad state: No reference information for g at 39 - await super.test_undefinedFunction_inCatch(); - } - - @override - @failingTest - test_undefinedFunction_inImportedLib() async { - // Bad state: No reference information for f at 40 - await super.test_undefinedFunction_inImportedLib(); - } - - @override - @failingTest - test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() async { - // AnalysisException: Element mismatch in /test.dart at main(A a) → dynamic - await super.test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle(); - } - - @override - @failingTest - test_undefinedGetter_wrongNumberOfTypeArguments_tooMany() async { - // AnalysisException: Element mismatch in /test.dart at main(A a) → dynamic - await super.test_undefinedGetter_wrongNumberOfTypeArguments_tooMany(); - } - - @override - @failingTest - test_undefinedGetter_wrongOfTypeArgument() async { - // Expected 1 errors of type StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, found 0 - await super.test_undefinedGetter_wrongOfTypeArgument(); - } - - @override - @failingTest - @FastaProblem('https://github.com/dart-lang/sdk/issues/33679') - test_undefinedMethod() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 2 - await super.test_undefinedMethod(); - } - @override @failingTest test_undefinedMethod_generic_function_call() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_generic_function_call(); } @override @failingTest test_undefinedMethod_ignoreTypePropagation() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_ignoreTypePropagation(); } @override @failingTest test_undefinedMethod_leastUpperBoundWithNull() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_leastUpperBoundWithNull(); } @override @failingTest test_undefinedMethod_object_call() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_object_call(); } @override @failingTest test_undefinedMethod_ofNull() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_ofNull(); } - @override - @failingTest - @FastaProblem('https://github.com/dart-lang/sdk/issues/33679') - test_undefinedMethod_private() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 2 - await super.test_undefinedMethod_private(); - } - @override @failingTest test_undefinedMethod_proxy_annotation_fakeProxy() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_proxy_annotation_fakeProxy(); } @override @failingTest test_undefinedMethod_typeLiteral_cascadeTarget() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_METHOD, found 0 await super.test_undefinedMethod_typeLiteral_cascadeTarget(); } - @override - @failingTest - test_undefinedOperator_indexBoth() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_indexBoth(); - } - - @override - @failingTest - test_undefinedOperator_indexGetter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_indexGetter(); - } - - @override - @failingTest - test_undefinedOperator_indexSetter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_indexSetter(); - } - - @override - @failingTest - test_undefinedOperator_plus() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_plus(); - } - - @override - @failingTest - test_undefinedOperator_postfixExpression() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_postfixExpression(); - } - - @override - @failingTest - test_undefinedOperator_prefixExpression() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_OPERATOR, found 0 - await super.test_undefinedOperator_prefixExpression(); - } - @override @failingTest test_undefinedSuperMethod() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, found 0 await super.test_undefinedSuperMethod(); } - @override - @failingTest - test_undefinedSuperOperator_binaryExpression() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, found 0 - await super.test_undefinedSuperOperator_binaryExpression(); - } - - @override - @failingTest - test_undefinedSuperOperator_indexBoth() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, found 0 - await super.test_undefinedSuperOperator_indexBoth(); - } - - @override - @failingTest - test_undefinedSuperOperator_indexGetter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, found 0 - await super.test_undefinedSuperOperator_indexGetter(); - } - - @override - @failingTest - test_undefinedSuperOperator_indexSetter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, found 0 - await super.test_undefinedSuperOperator_indexSetter(); - } - - @override - @failingTest - test_unqualifiedReferenceToNonLocalStaticMember_getter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER, found 0 - await super.test_unqualifiedReferenceToNonLocalStaticMember_getter(); - } - - @override - @failingTest - test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget() async { - // Bad state: No reference information for foo at 72 - await super - .test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget(); - } - - @override - @failingTest - test_unqualifiedReferenceToNonLocalStaticMember_method() async { - // Expected 1 errors of type StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER, found 0 - await super.test_unqualifiedReferenceToNonLocalStaticMember_method(); - } - - @override - @failingTest - test_unqualifiedReferenceToNonLocalStaticMember_setter() async { - // Expected 1 errors of type StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER, found 0 - await super.test_unqualifiedReferenceToNonLocalStaticMember_setter(); - } - @override @failingTest test_wrongNumberOfTypeArguments_classAlias() async { - // AnalysisException: Element mismatch in /test.dart at /test.dart await super.test_wrongNumberOfTypeArguments_classAlias(); } @override @failingTest test_yield_async_to_basic_type() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0; - // 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_yield_async_to_basic_type(); } @override @failingTest test_yield_async_to_iterable() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0; - // 1 errors of type StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_yield_async_to_iterable(); } - @override - @failingTest - test_yield_async_to_mistyped_stream() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_async_to_mistyped_stream(); - } - - @override - @failingTest - test_yield_each_async_non_stream() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_each_async_non_stream(); - } - - @override - @failingTest - test_yield_each_async_to_mistyped_stream() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_each_async_to_mistyped_stream(); - } - - @override - @failingTest - test_yield_each_sync_non_iterable() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_each_sync_non_iterable(); - } - - @override - @failingTest - test_yield_each_sync_to_mistyped_iterable() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_each_sync_to_mistyped_iterable(); - } - @override @failingTest test_yield_sync_to_basic_type() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0; - // 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_yield_sync_to_basic_type(); } - @override - @failingTest - test_yield_sync_to_mistyped_iterable() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0 - await super.test_yield_sync_to_mistyped_iterable(); - } - @override @failingTest test_yield_sync_to_stream() async { - // Expected 1 errors of type StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, found 0; - // 1 errors of type StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, found 0 await super.test_yield_sync_to_stream(); } } @@ -904,7 +405,6 @@ class StrongModeStaticTypeWarningCodeTest_Kernel @override @failingTest test_genericMethodWrongNumberOfTypeArguments() async { - // Bad state: Found 0 argument types for 1 type arguments await super.test_genericMethodWrongNumberOfTypeArguments(); } } diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart index 8c6e5b1e860..56d18eb9dae 100644 --- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart +++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart @@ -118,7 +118,15 @@ f() {}'''); library lib2; f() {}'''); await computeAnalysisResult(source); - assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); + if (useCFE) { + assertErrors(source, [ + StaticTypeWarningCode.UNDEFINED_METHOD, + HintCode.UNUSED_IMPORT, + HintCode.UNUSED_IMPORT + ]); + } else { + assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); + } } test_assert_message_suppresses_type_promotion() async { @@ -534,7 +542,8 @@ class C { } test_inconsistentMethodInheritance_paramCount() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' abstract class A { int x(); } @@ -542,11 +551,15 @@ abstract class B { int x(int y); } class C implements A, B { -}''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); +}''', + useCFE + ? [StaticWarningCode.INVALID_OVERRIDE_REQUIRED] + : [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); } test_inconsistentMethodInheritance_paramType() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' abstract class A { x(int i); } @@ -554,11 +567,15 @@ abstract class B { x(String s); } abstract class C implements A, B {} -''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); +''', + useCFE + ? [StrongModeCode.INVALID_METHOD_OVERRIDE] + : [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); } test_inconsistentMethodInheritance_returnType() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' abstract class A { int x(); } @@ -566,57 +583,80 @@ abstract class B { String x(); } abstract class C implements A, B {} -''', [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); +''', + useCFE + ? [StrongModeCode.INVALID_METHOD_OVERRIDE] + : [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); } test_instanceAccessToStaticMember_method_invocation() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static m() {} } main(A a) { a.m(); -}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); } test_instanceAccessToStaticMember_method_reference() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static m() {} } main(A a) { a.m; -}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_GETTER] + : [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); } test_instanceAccessToStaticMember_propertyAccess_field() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static var f; } main(A a) { a.f; -}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_GETTER] + : [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); } test_instanceAccessToStaticMember_propertyAccess_getter() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static get f => 42; } main(A a) { a.f; -}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_GETTER] + : [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); } test_instanceAccessToStaticMember_propertyAccess_setter() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static set f(x) {} } main(A a) { a.f = 42; -}''', [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_SETTER] + : [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); } test_invalidAssignment_compoundAssignment() async { @@ -749,22 +789,31 @@ f(Function f) { } test_invocationOfNonFunction_localObject() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' f(Object o) { return o(); -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); } test_invocationOfNonFunction_localVariable() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { int x; return x(); -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); } test_invocationOfNonFunction_ordinaryInvocation() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static int x; } @@ -772,23 +821,31 @@ class B { m() { A.x(); } -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); // A call to verify(source) fails as A.x() cannot be resolved. } test_invocationOfNonFunction_staticInvocation() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static int get g => 0; f() { A.g(); } -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); // A call to verify(source) fails as g() cannot be resolved. } test_invocationOfNonFunction_superExpression() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { int get g => 0; } @@ -796,48 +853,74 @@ class B extends A { m() { var v = super.g(); } -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); } test_invocationOfNonFunctionExpression_literal() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { 3(5); -}''', [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]); } test_nonBoolCondition_conditional() async { - await assertErrorsInCode("f() { return 3 ? 2 : 1; }", - [StaticTypeWarningCode.NON_BOOL_CONDITION]); + await assertErrorsInCode( + "f() { return 3 ? 2 : 1; }", + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_CONDITION]); } test_nonBoolCondition_do() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { do {} while (3); -}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_CONDITION]); } test_nonBoolCondition_for() async { // https://github.com/dart-lang/sdk/issues/24713 - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { for (;3;) {} -}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_CONDITION]); } test_nonBoolCondition_if() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { if (3) return 2; else return 1; -}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_CONDITION]); } test_nonBoolCondition_while() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { while (3) {} -}''', [StaticTypeWarningCode.NON_BOOL_CONDITION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_CONDITION]); } test_nonBoolExpression_functionType_bool() async { @@ -847,58 +930,90 @@ f() { assert(makeAssertion); }'''); await computeAnalysisResult(source); - assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); + if (useCFE) { + assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); + } else { + assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); + } verify([source]); } test_nonBoolExpression_functionType_int() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' int makeAssertion() => 1; f() { assert(makeAssertion); -}''', [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); } test_nonBoolExpression_interfaceType() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { assert(0); -}''', [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); } test_nonBoolNegationExpression() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' f() { !42; -}''', [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]); } test_nonBoolOperand_and_left() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' bool f(int left, bool right) { return left && right; -}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_OPERAND]); } test_nonBoolOperand_and_right() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' bool f(bool left, String right) { return left && right; -}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_OPERAND]); } test_nonBoolOperand_or_left() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' bool f(List left, bool right) { return left || right; -}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_OPERAND]); } test_nonBoolOperand_or_right() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' bool f(bool left, double right) { return left || right; -}''', [StaticTypeWarningCode.NON_BOOL_OPERAND]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.NON_BOOL_OPERAND]); } test_nonTypeAsTypeArgument_notAType() async { @@ -909,28 +1024,43 @@ f(B b) {}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); } test_nonTypeAsTypeArgument_undefinedIdentifier() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class B {} -f(B b) {}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); +f(B b) {}''', + useCFE + ? [ + StaticWarningCode.NOT_A_TYPE, + CompileTimeErrorCode.UNDEFINED_CLASS + ] + : [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); } test_returnOfInvalidType_async_future_future_int_mismatches_future_int() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' import 'dart:async'; Future f() async { return g(); } Future> g() => null; -''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_async_future_int_mismatches_future_string() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' import 'dart:async'; Future f() async { return 5; } -''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_async_future_int_mismatches_int() async { @@ -946,56 +1076,84 @@ int f() async { test_returnOfInvalidType_expressionFunctionBody_function() async { await assertErrorsInCode( - "int f() => '0';", [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); + "int f() => '0';", + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_expressionFunctionBody_getter() async { await assertErrorsInCode( - "int get g => '0';", [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); + "int get g => '0';", + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_expressionFunctionBody_localFunction() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { String m() { int f() => '0'; return '0'; } -}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_expressionFunctionBody_method() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { int f() => '0'; -}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_function() async { - await assertErrorsInCode("int f() { return '0'; }", - [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); + await assertErrorsInCode( + "int f() { return '0'; }", + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_getter() async { - await assertErrorsInCode("int get g { return '0'; }", - [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); + await assertErrorsInCode( + "int get g { return '0'; }", + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_localFunction() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { String m() { int f() { return '0'; } return '0'; } -}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_method() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { int f() { return '0'; } -}''', [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); +}''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); } test_returnOfInvalidType_not_issued_for_expressionFunctionBody_void() async { @@ -1443,20 +1601,28 @@ main(A p) { } test_undefinedFunction() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' void f() { g(); -}''', [StaticTypeWarningCode.UNDEFINED_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_FUNCTION]); } test_undefinedFunction_inCatch() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' void f() { try { } on Object { g(); } -}''', [StaticTypeWarningCode.UNDEFINED_FUNCTION]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_FUNCTION]); } test_undefinedFunction_inImportedLib() async { @@ -1467,7 +1633,11 @@ main() { return f.g(); }'''); library lib; h() {}'''); await computeAnalysisResult(source); - assertErrors(source, [StaticTypeWarningCode.UNDEFINED_FUNCTION]); + if (useCFE) { + assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); + } else { + assertErrors(source, [StaticTypeWarningCode.UNDEFINED_FUNCTION]); + } } test_undefinedGetter() async { @@ -1536,42 +1706,71 @@ f() => A?.hashCode; } test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { K element; } main(A a) { a.element.anyGetterExistsInDynamic; -}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_GETTER, + StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS + ] + : [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); } test_undefinedGetter_wrongNumberOfTypeArguments_tooMany() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { E element; } main(A a) { a.element.anyGetterExistsInDynamic; -}''', [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_GETTER, + StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS + ] + : [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); } test_undefinedGetter_wrongOfTypeArgument() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { E element; } main(A a) { a.element.anyGetterExistsInDynamic; -}''', [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_GETTER, + StaticWarningCode.NOT_A_TYPE, + CompileTimeErrorCode.UNDEFINED_CLASS + ] + : [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); } test_undefinedMethod() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { void m() { n(); } -}''', [StaticTypeWarningCode.UNDEFINED_METHOD]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_METHOD, + StaticTypeWarningCode.UNDEFINED_METHOD + ] + : [StaticTypeWarningCode.UNDEFINED_METHOD]); } test_undefinedMethod_assignmentExpression() async { @@ -1640,13 +1839,20 @@ library lib; class A { _foo() {} }'''); - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' import 'lib.dart'; class B extends A { test() { _foo(); } -}''', [StaticTypeWarningCode.UNDEFINED_METHOD]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_METHOD, + StaticTypeWarningCode.UNDEFINED_METHOD + ] + : [StaticTypeWarningCode.UNDEFINED_METHOD]); } test_undefinedMethod_proxy_annotation_fakeProxy() async { @@ -1700,51 +1906,78 @@ f() { } test_undefinedOperator_indexBoth() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} f(A a) { a[0]++; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_METHOD, + StaticTypeWarningCode.UNDEFINED_METHOD + ] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedOperator_indexGetter() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} f(A a) { a[0]; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedOperator_indexSetter() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} f(A a) { a[0] = 1; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedOperator_plus() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} f(A a) { a + 1; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedOperator_postfixExpression() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A {} f(A a) { a++; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedOperator_prefixExpression() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A {} f(A a) { ++a; -}''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_METHOD] + : [StaticTypeWarningCode.UNDEFINED_OPERATOR]); } test_undefinedSetter() async { @@ -1788,33 +2021,48 @@ class B extends A { } test_undefinedSuperOperator_binaryExpression() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} class B extends A { operator +(value) { return super + value; } -}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD] + : [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); } test_undefinedSuperOperator_indexBoth() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} class B extends A { operator [](index) { return super[index]++; } -}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, + StaticTypeWarningCode.UNDEFINED_SUPER_METHOD + ] + : [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); } test_undefinedSuperOperator_indexGetter() async { - await assertErrorsInUnverifiedCode(r''' + await assertErrorsInUnverifiedCode( + r''' class A {} class B extends A { operator [](index) { return super[index + 1]; } -}''', [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); +}''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD] + : [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); } test_undefinedSuperOperator_indexSetter() async { @@ -1826,12 +2074,14 @@ class B extends A { return super[index] = 0; } }''', - previewDart2 - ? [ - StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, - StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR - ] - : [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR]); + useCFE + ? [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD] + : (previewDart2 + ? [ + StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, + StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR + ] + : [StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR])); } test_undefinedSuperSetter() async { @@ -1845,7 +2095,8 @@ class B extends A { } test_unqualifiedReferenceToNonLocalStaticMember_getter() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static int get a => 0; } @@ -1853,11 +2104,21 @@ class B extends A { int b() { return a; } -}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_GETTER, + StaticTypeWarningCode.UNDEFINED_GETTER + ] + : [ + StaticTypeWarningCode + .UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER + ]); } test_unqualifiedReferenceToNonLocalStaticMember_getter_invokeTarget() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static int foo; } @@ -1867,11 +2128,18 @@ class B extends A { foo.abs(); } } -''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]); +''', + useCFE + ? [StaticTypeWarningCode.UNDEFINED_GETTER] + : [ + StaticTypeWarningCode + .UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER + ]); } test_unqualifiedReferenceToNonLocalStaticMember_method() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static void a() {} } @@ -1879,11 +2147,21 @@ class B extends A { void b() { a(); } -}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_METHOD, + StaticTypeWarningCode.UNDEFINED_METHOD + ] + : [ + StaticTypeWarningCode + .UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER + ]); } test_unqualifiedReferenceToNonLocalStaticMember_setter() async { - await assertErrorsInCode(r''' + await assertErrorsInCode( + r''' class A { static set a(x) {} } @@ -1891,7 +2169,16 @@ class B extends A { b(y) { a = y; } -}''', [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER]); +}''', + useCFE + ? [ + StaticTypeWarningCode.UNDEFINED_SETTER, + StaticTypeWarningCode.UNDEFINED_SETTER + ] + : [ + StaticTypeWarningCode + .UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER + ]); } test_wrongNumberOfTypeArguments_classAlias() async { @@ -1955,47 +2242,67 @@ Iterable f() async* { } test_yield_async_to_mistyped_stream() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' import 'dart:async'; Stream f() async* { yield "foo"; } -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_each_async_non_stream() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' f() async* { yield* 0; } -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_each_async_to_mistyped_stream() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' import 'dart:async'; Stream f() async* { yield* g(); } Stream g() => null; -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_each_sync_non_iterable() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' f() sync* { yield* 0; } -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_each_sync_to_mistyped_iterable() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' Iterable f() sync* { yield* g(); } Iterable g() => null; -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_sync_to_basic_type() async { @@ -2010,11 +2317,15 @@ int f() sync* { } test_yield_sync_to_mistyped_iterable() async { - await assertErrorsInCode(''' + await assertErrorsInCode( + ''' Iterable f() sync* { yield "foo"; } -''', [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); +''', + useCFE + ? [StaticTypeWarningCode.INVALID_ASSIGNMENT] + : [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]); } test_yield_sync_to_stream() async {