@@ -349,12 +349,6 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
349349 bool isVoidAllowed = false ,
350350 bool coerceExpression = true ,
351351 Template <Message Function (DartType , DartType )>? errorTemplate,
352- Template <Message Function (DartType , DartType )>? nullabilityErrorTemplate,
353- Template <Message Function (DartType )>? nullabilityNullErrorTemplate,
354- Template <Message Function (DartType , DartType )>?
355- nullabilityNullTypeErrorTemplate,
356- Template <Message Function (DartType , DartType , DartType , DartType )>?
357- nullabilityPartErrorTemplate,
358352 Map <SharedTypeView , NonPromotionReason > Function ()? whyNotPromoted}) {
359353 return ensureAssignableResult (expectedType,
360354 new ExpressionInferenceResult (expressionType, expression),
@@ -364,10 +358,6 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
364358 isVoidAllowed: isVoidAllowed,
365359 coerceExpression: coerceExpression,
366360 errorTemplate: errorTemplate,
367- nullabilityErrorTemplate: nullabilityErrorTemplate,
368- nullabilityNullErrorTemplate: nullabilityNullErrorTemplate,
369- nullabilityNullTypeErrorTemplate: nullabilityNullTypeErrorTemplate,
370- nullabilityPartErrorTemplate: nullabilityPartErrorTemplate,
371361 whyNotPromoted: whyNotPromoted)
372362 .expression;
373363 }
@@ -463,34 +453,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
463453 bool isVoidAllowed = false ,
464454 bool isCoercionAllowed = true ,
465455 Template <Message Function (DartType , DartType )>? errorTemplate,
466- Template <Message Function (DartType , DartType )>? nullabilityErrorTemplate,
467- Template <Message Function (DartType )>? nullabilityNullErrorTemplate,
468- Template <Message Function (DartType , DartType )>?
469- nullabilityNullTypeErrorTemplate,
470- Template <Message Function (DartType , DartType , DartType , DartType )>?
471- nullabilityPartErrorTemplate,
472456 Map <SharedTypeView , NonPromotionReason > Function ()? whyNotPromoted}) {
473- // [errorTemplate], [nullabilityErrorTemplate], and
474- // [nullabilityPartErrorTemplate] should be provided together.
475- assert ((errorTemplate == null ) == (nullabilityErrorTemplate == null ) &&
476- (nullabilityErrorTemplate == null ) ==
477- (nullabilityPartErrorTemplate == null ));
478- // [nullabilityNullErrorTemplate] and [nullabilityNullTypeErrorTemplate]
479- // should be provided together.
480- assert ((nullabilityNullErrorTemplate == null ) ==
481- (nullabilityNullTypeErrorTemplate == null ));
482457 errorTemplate ?? = templateInvalidAssignmentError;
483- if (nullabilityErrorTemplate == null ) {
484- // Use [templateInvalidAssignmentErrorNullabilityNull] only if no
485- // specific [nullabilityErrorTemplate] template was passed.
486- nullabilityNullErrorTemplate ?? =
487- templateInvalidAssignmentErrorNullabilityNull;
488- }
489- nullabilityNullTypeErrorTemplate ?? = nullabilityErrorTemplate ??
490- templateInvalidAssignmentErrorNullabilityNullType;
491- nullabilityErrorTemplate ?? = templateInvalidAssignmentErrorNullability;
492- nullabilityPartErrorTemplate ?? =
493- templateInvalidAssignmentErrorPartNullability;
494458
495459 fileOffset ?? = inferenceResult.expression.fileOffset;
496460 contextType = computeGreatestClosure (contextType);
@@ -558,47 +522,29 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
558522 break ;
559523 case AssignabilityKind .unassignableNullability:
560524 if (expressionType == assignabilityResult.subtype &&
561- contextType == assignabilityResult.supertype) {
562- if (expression is NullLiteral &&
563- nullabilityNullErrorTemplate != null ) {
564- result = _wrapUnassignableExpression (
565- expression,
566- expressionType,
567- contextType,
568- nullabilityNullErrorTemplate
569- .withArguments (declaredContextType ?? contextType));
570- } else if (expressionType is NullType ) {
571- result = _wrapUnassignableExpression (
572- expression,
573- expressionType,
574- contextType,
575- nullabilityNullTypeErrorTemplate.withArguments (
576- expressionType, declaredContextType ?? contextType));
577- } else {
578- whyNotPromoted ?? = flowAnalysis.whyNotPromoted (expression);
579- result = _wrapUnassignableExpression (
580- expression,
581- expressionType,
582- contextType,
583- nullabilityErrorTemplate.withArguments (
584- expressionType, declaredContextType ?? contextType),
585- context: getWhyNotPromotedContext (
586- whyNotPromoted.call (),
587- expression,
588- // Coverage-ignore(suite): Not run.
589- (type) => typeSchemaEnvironment.isSubtypeOf (type,
590- contextType, SubtypeCheckMode .withNullabilities)));
591- }
525+ contextType == assignabilityResult.supertype &&
526+ expression is ! NullLiteral &&
527+ expressionType is ! NullType ) {
528+ whyNotPromoted ?? = flowAnalysis.whyNotPromoted (expression);
529+ result = _wrapUnassignableExpression (
530+ expression,
531+ expressionType,
532+ contextType,
533+ errorTemplate.withArguments (
534+ expressionType, declaredContextType ?? contextType),
535+ context: getWhyNotPromotedContext (
536+ whyNotPromoted.call (),
537+ expression,
538+ // Coverage-ignore(suite): Not run.
539+ (type) => typeSchemaEnvironment.isSubtypeOf (
540+ type, contextType, SubtypeCheckMode .withNullabilities)));
592541 } else {
593542 result = _wrapUnassignableExpression (
594543 expression,
595544 expressionType,
596545 contextType,
597- nullabilityPartErrorTemplate.withArguments (
598- expressionType,
599- declaredContextType ?? contextType,
600- assignabilityResult.subtype! ,
601- assignabilityResult.supertype! ));
546+ errorTemplate.withArguments (
547+ expressionType, declaredContextType ?? contextType));
602548 }
603549 break ;
604550 }
@@ -623,12 +569,6 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
623569 bool isVoidAllowed = false ,
624570 bool coerceExpression = true ,
625571 Template <Message Function (DartType , DartType )>? errorTemplate,
626- Template <Message Function (DartType , DartType )>? nullabilityErrorTemplate,
627- Template <Message Function (DartType )>? nullabilityNullErrorTemplate,
628- Template <Message Function (DartType , DartType )>?
629- nullabilityNullTypeErrorTemplate,
630- Template <Message Function (DartType , DartType , DartType , DartType )>?
631- nullabilityPartErrorTemplate,
632572 Map <SharedTypeView , NonPromotionReason > Function ()? whyNotPromoted}) {
633573 if (coerceExpression) {
634574 ExpressionInferenceResult ? coercionResult = coerceExpressionForAssignment (
@@ -651,10 +591,6 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
651591 isVoidAllowed: isVoidAllowed,
652592 isCoercionAllowed: coerceExpression,
653593 errorTemplate: errorTemplate,
654- nullabilityErrorTemplate: nullabilityErrorTemplate,
655- nullabilityNullErrorTemplate: nullabilityNullErrorTemplate,
656- nullabilityNullTypeErrorTemplate: nullabilityNullTypeErrorTemplate,
657- nullabilityPartErrorTemplate: nullabilityPartErrorTemplate,
658594 whyNotPromoted: whyNotPromoted);
659595
660596 return inferenceResult;
@@ -2066,15 +2002,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
20662002 expectedType, argumentResultToCheck,
20672003 isVoidAllowed: expectedType is VoidType ,
20682004 isCoercionAllowed: coerceExpression,
2069- errorTemplate: templateArgumentTypeNotAssignable,
2070- nullabilityErrorTemplate:
2071- templateArgumentTypeNotAssignableNullability,
2072- nullabilityPartErrorTemplate:
2073- templateArgumentTypeNotAssignablePartNullability,
2074- nullabilityNullErrorTemplate:
2075- templateArgumentTypeNotAssignableNullabilityNull,
2076- nullabilityNullTypeErrorTemplate:
2077- templateArgumentTypeNotAssignableNullabilityNullType);
2005+ errorTemplate: templateArgumentTypeNotAssignable);
20782006
20792007 argumentExpression = argumentResultToCheck.expression;
20802008 if (namedArgumentExpression == null ) {
0 commit comments