typeLinkingExpr db imps su (NewArray tp exprd _) = if (not . null $ typeIdx) && (not . null $ castConversion db (head typeIdx) TypeInt)
                                                      then if isPrimitive tp then [Array tp] else
                                                          case [Object (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                          [] -> typeLinkingFailure $ "NewArray: []" ++ (show tp) ++ (show $ lookUpDB db imps su (typeToName tp))
                                                          [tp] -> [Array tp]
                                                          tps' -> typeLinkingFailure (show tps')
                                                      else typeLinkingFailure "Array: index is not an integer"
    where
        typeIdx = case typeLinkingExpr db imps su exprd of
                        [] -> typeLinkingFailure $ "Array Index type []: " ++ (show exprd)
                        [tp] -> [tp]
                        tps -> typeLinkingFailure $ "Array Index multi: " ++ (show exprd) ++ (show tps)
typeLinkingExpr db imps su (NewArray tp exprd _) = if (not . null $ typeIdx) && (not . null $ castConversion db (head typeIdx) TypeInt)
                                                      then if isPrimitive tp then [Array tp] else
                                                          case [Object (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                          [] -> typeLinkingFailure $ "NewArray: []" ++ (show tp) ++ (show $ lookUpDB db imps su (typeToName tp))
                                                          [tp] -> [Array tp]
                                                          tps' -> typeLinkingFailure (show tps')
                                                      else typeLinkingFailure "Array: index is not an integer"
    where
        typeIdx = case typeLinkingExpr db imps su exprd of
                        [] -> typeLinkingFailure $ "Array Index type []: " ++ (show exprd)
                        [tp] -> [tp]
                        tps -> typeLinkingFailure $ "Array Index multi: " ++ (show exprd) ++ (show tps)
typeLinkingExpr db imps su (NewArray tp exprd _) = if (not . null $ typeIdx) && (not . null $ castConversion db (head typeIdx) TypeInt)
                                                      then if isPrimitive tp then [Array tp] else
                                                          case [Object (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                          [] -> typeLinkingFailure $ "NewArray: []" ++ (show tp) ++ (show $ lookUpDB db imps su (typeToName tp))
                                                          [tp] -> [Array tp]
                                                          tps' -> typeLinkingFailure (show tps')
                                                      else typeLinkingFailure "Array: index is not an integer"
    where
        typeIdx = case typeLinkingExpr db imps su exprd of
                        [] -> typeLinkingFailure $ "Array Index type []: " ++ (show exprd)
                        [tp] -> [tp]
                        tps -> typeLinkingFailure $ "Array Index multi: " ++ (show exprd) ++ (show tps)