View | Details | Raw Unified | Return to bug 16490 | Differences between
and this patch

Collapse All | Expand All

(-)src/library/methods/R/RClassUtils.R (-16 / +14 lines)
Lines 981-1012 Link Here
981
        return(FALSE)
981
        return(FALSE)
982
    ## else
982
    ## else
983
    ext <- ClassDef1@contains
983
    ext <- ClassDef1@contains
984
    nm1 <- names(ext)
984
    contained <- ext[[class2]]
985
    i <- match(class2, nm1)
985
    if(!is.null(contained)) {
986
    if(is.na(i)) {
986
        return(contained)
987
    } else if (is.null(ClassDef2)) {
988
          return(FALSE)
989
    } else {
987
        ## look for class1 in the known subclasses of class2
990
        ## look for class1 in the known subclasses of class2
988
        if(!is.null(ClassDef2)) {
991
          subs <- ClassDef2@subclasses
989
            ext <- ClassDef2@subclasses
990
            ## check for a classUnion definition, not a plain "classRepresentation"
992
            ## check for a classUnion definition, not a plain "classRepresentation"
991
            if(!.identC(class(ClassDef2), "classRepresentation") &&
993
          if(!.identC(class(ClassDef2), "classRepresentation") && isClassUnion(ClassDef2))
992
               isClassUnion(ClassDef2))
993
                ## a simple TRUE iff class1 or one of its superclasses belongs to the union
994
                ## a simple TRUE iff class1 or one of its superclasses belongs to the union
994
                i <- any(c(class1, nm1) %in% names(ext))
995
              return( any(c(class1, names(ext)) %in% names(subs)) )
995
            else {
996
            else {
996
                ## class1 could be multiple classes here.
997
                ## class1 could be multiple classes here.
997
                ## I think we want to know if any extend
998
                ## I think we want to know if any extend
998
                i <- match(class1, names(ext))
999
              i <- match(class1, names(subs))
999
                ii <- i[!is.na(i)]
1000
                ii <- i[!is.na(i)]
1000
                i <- if(length(ii)) ii[1L] else i[1L]
1001
              if(length(ii)) {
1002
                  return( subs[[ ii[1L] ]] )
1003
              } else {
1004
                  return(FALSE)
1001
            }
1005
            }
1002
        }
1006
        }
1003
    }
1007
    }
1004
    if(is.na(i))
1005
        FALSE
1006
    else if(is.logical(i))
1007
        i
1008
    else
1009
        el(ext, i)
1010
}
1008
}
1011
1009
1012
  ## complete the extends information in the class definition, by following
1010
  ## complete the extends information in the class definition, by following

Return to bug 16490