code: func selectRef(tpe types.Type, ref Ref) types.Type {
  
  	if tpe == nil || len(ref) == 0 {
  		return tpe
  	}
  
  	head, tail := ref[0], ref[1:]
  
  	switch head.Value.(type) {
  	case Var, Ref, Array, Object, Set:
  		return selectRef(types.Values(tpe), tail)
  	default:
  		return selectRef(selectConstant(tpe, head), tail)
  	}
  }
docs: // selectRef returns the type of the nested attribute referred to by ref. If
  // the attribute type cannot be determined, nil is returned. If the ref
  // contains vars or refs, then the returned type will be a union of the
  // possible types.