@@ -494,7 +494,6 @@ class TypeInferrerImpl implements TypeInferrer {
494
494
DartType ? declaredContextType,
495
495
DartType ? runtimeCheckedType,
496
496
bool isVoidAllowed: false ,
497
- bool coerceExpression: true ,
498
497
Template <Message Function (DartType , DartType , bool )>? errorTemplate,
499
498
Template <Message Function (DartType , DartType , bool )>?
500
499
nullabilityErrorTemplate,
@@ -510,7 +509,6 @@ class TypeInferrerImpl implements TypeInferrer {
510
509
declaredContextType: declaredContextType,
511
510
runtimeCheckedType: runtimeCheckedType,
512
511
isVoidAllowed: isVoidAllowed,
513
- coerceExpression: coerceExpression,
514
512
errorTemplate: errorTemplate,
515
513
nullabilityErrorTemplate: nullabilityErrorTemplate,
516
514
nullabilityNullErrorTemplate: nullabilityNullErrorTemplate,
@@ -529,7 +527,6 @@ class TypeInferrerImpl implements TypeInferrer {
529
527
DartType ? declaredContextType,
530
528
DartType ? runtimeCheckedType,
531
529
bool isVoidAllowed: false ,
532
- bool coerceExpression: true ,
533
530
Template <Message Function (DartType , DartType , bool )>? errorTemplate,
534
531
Template <Message Function (DartType , DartType , bool )>?
535
532
nullabilityErrorTemplate,
@@ -581,8 +578,7 @@ class TypeInferrerImpl implements TypeInferrer {
581
578
contextType, inferenceResult.inferredType,
582
579
isNonNullableByDefault: isNonNullableByDefault,
583
580
isVoidAllowed: isVoidAllowed,
584
- isExpressionTypePrecise: preciseTypeErrorTemplate != null ,
585
- coerceExpression: coerceExpression);
581
+ isExpressionTypePrecise: preciseTypeErrorTemplate != null );
586
582
587
583
if (assignabilityResult.needsTearOff) {
588
584
TypedTearoff typedTearoff = _tearOffCall (inferenceResult.expression,
@@ -786,8 +782,7 @@ class TypeInferrerImpl implements TypeInferrer {
786
782
DartType contextType, DartType expressionType,
787
783
{required bool isNonNullableByDefault,
788
784
required bool isVoidAllowed,
789
- required bool isExpressionTypePrecise,
790
- required bool coerceExpression}) {
785
+ required bool isExpressionTypePrecise}) {
791
786
// ignore: unnecessary_null_comparison
792
787
assert (isNonNullableByDefault != null );
793
788
// ignore: unnecessary_null_comparison
@@ -799,7 +794,7 @@ class TypeInferrerImpl implements TypeInferrer {
799
794
// should tear off `.call`.
800
795
// TODO(paulberry): use resolveTypeParameter. See findInterfaceMember.
801
796
bool needsTearoff = false ;
802
- if (coerceExpression && expressionType is InterfaceType ) {
797
+ if (expressionType is InterfaceType ) {
803
798
Class classNode = expressionType.classNode;
804
799
Member ? callMember =
805
800
classHierarchy.getInterfaceMember (classNode, callName);
@@ -818,7 +813,7 @@ class TypeInferrerImpl implements TypeInferrer {
818
813
}
819
814
}
820
815
ImplicitInstantiation ? implicitInstantiation;
821
- if (coerceExpression && libraryBuilder.enableConstructorTearOffsInLibrary) {
816
+ if (libraryBuilder.enableConstructorTearOffsInLibrary) {
822
817
implicitInstantiation =
823
818
computeImplicitInstantiation (expressionType, contextType);
824
819
if (implicitInstantiation != null ) {
@@ -872,15 +867,8 @@ class TypeInferrerImpl implements TypeInferrer {
872
867
return const AssignabilityResult (AssignabilityKind .unassignablePrecise,
873
868
needsTearOff: false );
874
869
}
875
-
876
- if (coerceExpression) {
877
- // Insert an implicit downcast.
878
- return new AssignabilityResult (AssignabilityKind .assignableCast,
879
- needsTearOff: needsTearoff,
880
- implicitInstantiation: implicitInstantiation);
881
- }
882
-
883
- return new AssignabilityResult (AssignabilityKind .unassignable,
870
+ // Insert an implicit downcast.
871
+ return new AssignabilityResult (AssignabilityKind .assignableCast,
884
872
needsTearOff: needsTearoff,
885
873
implicitInstantiation: implicitInstantiation);
886
874
}
@@ -2630,23 +2618,17 @@ class TypeInferrerImpl implements TypeInferrer {
2630
2618
DartType actualType = actualTypes! [i];
2631
2619
Expression expression;
2632
2620
NamedExpression ? namedExpression;
2633
- bool coerceExpression;
2634
2621
if (i < numPositionalArgs) {
2635
2622
expression = arguments.positional[positionalShift + i];
2636
2623
positionalArgumentTypes.add (actualType);
2637
- coerceExpression = ! arguments.positionalAreSuperParameters;
2638
2624
} else {
2639
2625
namedExpression = arguments.named[i - numPositionalArgs];
2640
2626
expression = namedExpression.value;
2641
2627
namedArgumentTypes
2642
2628
.add (new NamedType (namedExpression.name, actualType));
2643
- coerceExpression = ! (arguments.namedSuperParameterNames
2644
- ? .contains (namedExpression.name) ??
2645
- false );
2646
2629
}
2647
2630
expression = ensureAssignable (expectedType, actualType, expression,
2648
2631
isVoidAllowed: expectedType is VoidType ,
2649
- coerceExpression: coerceExpression,
2650
2632
// TODO(johnniwinther): Specialize message for operator
2651
2633
// invocations.
2652
2634
errorTemplate: templateArgumentTypeNotAssignable,
0 commit comments