1! { dg-do compile }
2!
3! PR fortran/51809
4!
5! Contributed by Kacper Kowalik
6!
7module foo
8   implicit none
9
10   type foo_t
11   contains
12      procedure :: func_foo
13   end type foo_t
14
15contains
16
17   subroutine func_foo(this)
18      implicit none
19      class(foo_t), intent(in) :: this
20   end subroutine func_foo
21
22end module foo
23
24module bar
25   use foo,   only: foo_t
26
27   implicit none
28
29   type, extends(foo_t) :: bar_t
30   contains
31      procedure :: func_bar
32   end type bar_t
33
34contains
35
36   subroutine func_bar(this)
37      use foo,    only: foo_t     ! <--- removing this line also fixes ICE
38      implicit none
39      class(bar_t), intent(in) :: this
40   end subroutine func_bar
41
42end module bar
43
44module merry_ICE
45   use foo,  only: foo_t   ! <------ change order to prevent ICE
46   use bar,  only: bar_t   ! <------ change order to prevent ICE
47end module merry_ICE
48