@@ -293,9 +293,13 @@ class FixReason_NullCheckHint implements SimpleFixReasonInfo {
293293
294294/// Implementation of [MigrationResolutionHooks] that interfaces with
295295/// [FixBuilder] .
296- class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
296+ class MigrationResolutionHooksImpl
297+ with ResolutionUtils
298+ implements MigrationResolutionHooks {
297299 FixBuilder _fixBuilder;
298300
301+ TypeProvider get typeProvider => _fixBuilder.typeProvider;
302+
299303 final Expando <List <CollectionElement >> _collectionElements = Expando ();
300304
301305 final Expando <bool > _shouldStayNullAware = Expando ();
@@ -583,8 +587,18 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
583587 return type;
584588 }
585589
590+ Element get _elementToString =>
591+ _fixBuilder.typeProvider.objectType.getMethod ('toString' );
592+ Element get _elementHashCode =>
593+ _fixBuilder.typeProvider.objectType.getGetter ('hashCode' );
594+ Element get _elementRuntimeType =>
595+ _fixBuilder.typeProvider.objectType.getMethod ('runtimeType' );
596+ Element get _elementNoSuchMethod =>
597+ _fixBuilder.typeProvider.objectType.getGetter ('noSuchMethod' );
598+
586599 bool _needsNullCheckDueToStructure (Expression node) {
587600 var parent = node.parent;
601+
588602 if (parent is BinaryExpression ) {
589603 if (identical (node, parent.leftOperand)) {
590604 var operatorType = parent.operator .type;
@@ -597,16 +611,22 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
597611 }
598612 }
599613 } else if (parent is PrefixedIdentifier ) {
600- // TODO(paulberry): ok for toString etc. if the shape is correct
614+ if (isDeclaredOnObject (parent.identifier.name)) {
615+ return false ;
616+ }
601617 return identical (node, parent.prefix);
602618 } else if (parent is PropertyAccess ) {
619+ if (isDeclaredOnObject (parent.propertyName.name)) {
620+ return false ;
621+ }
603622 // TODO(paulberry): what about cascaded?
604- // TODO(paulberry): ok for toString etc. if the shape is correct
605623 return parent.operator .type == TokenType .PERIOD &&
606624 identical (node, parent.target);
607625 } else if (parent is MethodInvocation ) {
626+ if (isDeclaredOnObject (parent.methodName.name)) {
627+ return false ;
628+ }
608629 // TODO(paulberry): what about cascaded?
609- // TODO(paulberry): ok for toString etc. if the shape is correct
610630 return parent.operator .type == TokenType .PERIOD &&
611631 identical (node, parent.target);
612632 } else if (parent is IndexExpression ) {
0 commit comments