<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/142414>142414</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Another variation of defined assignment error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DanielCChen
      </td>
    </tr>
</table>

<pre>
    Consider the following code:
```
module m

   type base
      integer :: i
 contains
         procedure :: bassgn
         generic :: assignment(=) => bassgn
   end type

   type, extends(base) :: child
      integer :: j
 contains
         procedure :: cassgn
         generic :: assignment(=) => cassgn
   end type

   type container
      class(child), allocatable :: c1(:)
   end type

   contains

      impure elemental subroutine bassgn ( a, b )
         class(base), intent(out) :: a
         type(base), intent(in)   :: b

         print*, " in bassgn."
         a%i = b%i + 1

         select type ( a )
            type is ( child )
 a%j = b%i + 2
         end select

      end subroutine

      impure elemental subroutine cassgn ( a, b )
         class(child), intent(out) :: a
         type(child), intent(in)   :: b

         print*, " in cassgn."
         a%i = b%i + 2
         a%j = b%j + 2

      end subroutine

end module

program genericAssignmentDtIntrinAssgn029
   use m

   type(container) :: c1

   allocate ( c1%c1(-100:-98) )

   c1 = container( (/ child(4,5), child(6,7), child(8,9) /) )

end program
```

Expected output:
```
  in cassgn.
  in cassgn.
  in cassgn.
```

Flang outputs:
```
  in bassgn.
  in bassgn.
  in bassgn.
```

The component `c1` of type `container` has declare type of `child`. The defined assignment subroutine `cassgn` should be called instead of the one of type `base`.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVk2P4ygQ_TX4UuoI4484Bx88yUTa-_4BDGWbFoEI8OzMv1-BncTJ9Oz0aKWW0pBXVe-9okrh3qvRILak-kKqU8bnMFnXnrhRqI_HCU3WW_mjPVrjlUQHYUIYrNb2H2VGEFYiKTpCO1LT9Y92FytnjXCJ17QDgPD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