Index: gcc/fortran/match.c
===================================================================
*** gcc/fortran/match.c	(revision 194770)
--- gcc/fortran/match.c	(working copy)
*************** copy_ts_from_selector_to_associate (gfc_
*** 5144,5155 ****
  {
    gfc_ref *ref;
    gfc_symbol *assoc_sym;
  
    assoc_sym = associate->symtree->n.sym;
  
-   /* Ensure that any array reference is resolved.  */
-   gfc_resolve_expr (selector);
- 
    /* At this stage the expression rank and arrayspec dimensions have
       not been completely sorted out. We must get the expr2->rank
       right here, so that the correct class container is obtained.  */
--- 5144,5153 ----
  {
    gfc_ref *ref;
    gfc_symbol *assoc_sym;
+   int i;
  
    assoc_sym = associate->symtree->n.sym;
  
    /* At this stage the expression rank and arrayspec dimensions have
       not been completely sorted out. We must get the expr2->rank
       right here, so that the correct class container is obtained.  */
*************** copy_ts_from_selector_to_associate (gfc_
*** 5161,5166 ****
--- 5159,5177 ----
  	&& CLASS_DATA (selector)->as
  	&& ref && ref->type == REF_ARRAY)
      {
+       /* Ensure that the array reference type is set.  */
+       if (ref->u.ar.type == AR_UNKNOWN)
+ 	{
+ 	  ref->u.ar.type = AR_ELEMENT;
+ 	  for (i = 0; i < ref->u.ar.dimen; i++)
+ 	    if (ref->u.ar.dimen_type[i] == DIMEN_RANGE
+ 		|| ref->u.ar.dimen_type[i] == DIMEN_VECTOR)
+ 	      {
+ 		ref->u.ar.type = AR_SECTION;
+ 		break;
+ 	      }
+ 	}
+ 
        if (ref->u.ar.type == AR_FULL)
  	selector->rank = CLASS_DATA (selector)->as->rank;
        else if (ref->u.ar.type == AR_SECTION)
Index: gcc/testsuite/gfortran.dg/select_type_31.f03
===================================================================
*** gcc/testsuite/gfortran.dg/select_type_31.f03	(revision 0)
--- gcc/testsuite/gfortran.dg/select_type_31.f03	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ ! { dg-do compile }
+ ! Test the fix for PR55172.
+ !
+ ! Contributed by Arjen Markus  <arjen.markus@deltares.nl>
+ !
+ module gn
+   type :: ncb
+   end type ncb
+   type, public :: tn
+      class(ncb), allocatable, dimension(:) :: cb
+   end type tn
+ contains
+   integer function name(self)
+     implicit none
+     class (tn), intent(in) :: self
+     select type (component => self%cb(i)) ! { dg-error "has no IMPLICIT type" }
+     end select
+   end function name
+ end module gn
