tomaz / appledoc

Objective-c code Apple style documentation set generator.
http://gentlebytes.com
4.19k stars 644 forks source link

Crashed when a property with class Keyword #637

Open Sunny-zhao opened 5 years ago

Sunny-zhao commented 5 years ago

Define A property like
@property (nonatomic, class, readonly) NSString *UUID; In @implementation

Oops, something went wrong... AppledocException: Failed merging @property xxxxxxxx.UUID to +[xxxxxxxx UUIDt]; method type doesn't match! @ 0 CoreFoundation 0x00007fff3ed4d43d exceptionPreprocess + 256 @ 1 libobjc.A.dylib 0x00007fff6ac5a720 objc_exception_throw + 48 @ 2 CoreFoundation 0x00007fff3ed6808e +[NSException raise:format:arguments:] + 98 @ 3 appledoc 0x0000000108f35153 appledoc + 57683 @ 4 appledoc 0x0000000108f4c5a0 appledoc + 152992 @ 5 appledoc 0x0000000108f4c808 appledoc + 153608 @ 6 appledoc 0x0000000108f49335 appledoc + 140085 @ 7 CoreFoundation 0x00007fff3ece29e4 -[NSArrayM enumerateObjectsWithOptions:usingBlock:] + 219 @ 8 appledoc 0x0000000108f49111 appledoc + 139537 @ 9 appledoc 0x0000000108f4e1ef appledoc + 160239 @ 10 appledoc 0x0000000108f40831 appledoc + 104497 @ 11 appledoc 0x0000000108f38dc0 appledoc + 73152 @ 12 appledoc 0x0000000108f3d7a3 appledoc + 92067 @ 13 appledoc 0x0000000108f3b04e appledoc + 81998 @ 14 appledoc 0x0000000108f3816e appledoc + 69998 @ 15 appledoc 0x0000000108f35fa8 appledoc + 61352 @ 16 appledoc 0x0000000108f3767b appledoc + 67195 @ 17 appledoc 0x0000000108f372ed appledoc + 66285 @ 18 appledoc 0x0000000108f374c1 appledoc + 66753 @ 19 appledoc 0x0000000108f36eaf appledoc + 65199 @ 20 appledoc 0x0000000108f358be appledoc + 59582 @ 21 appledoc 0x0000000108f2a640 appledoc + 13888 @ 22 appledoc 0x0000000108f28df6 appledoc + 7670 @ 23 appledoc 0x0000000108f28f53 appledoc + 8019 @ 24 appledoc 0x0000000108f290e7 appledoc + 8423 @ 25 appledoc 0x0000000108f283ec appledoc + 5100

bieberstein commented 3 years ago

I'm having the same issue. Is there any update on this?

ShenYj commented 3 years ago

the same.

ShenYj commented 3 years ago

2018.11 ~ Now...

ShenYj commented 3 years ago
/** Defines different method types. */
enum {
    GBMethodTypeClass,      //< Method data describes a class method.
    GBMethodTypeInstance,   //< Method data describes an instance method.
    GBMethodTypeProperty    //< Method data describes a property.
};
typedef NSUInteger GBMethodType;

crashed in 362 line: [NSException raise:@"Failed merging %@ to %@; method type doesn't match!", source, self];

- (BOOL)validateMergeWith:(GBMethodData *)source {
    // Validates merging with the given method. This method raises exception if merging is not allowed based on method types. It takes into account manual propery accessors and mutators! Note that in case class method is being matched with instance, we prevent merging - this is to allow same selectors (due to how we currently handle class/instance methods (i.e. don't distinguish between them when matching by selectors) we simply need to prevent merging taking place in such case).
    if (source.methodType != self.methodType) {
        GBMethodData *propertyData = nil;
        GBMethodData *manualData = nil;
        if (self.methodType == GBMethodTypeProperty && source.methodType == GBMethodTypeInstance) {
            propertyData = self;
            manualData = source;
        } else if (self.methodType == GBMethodTypeInstance && source.methodType == GBMethodTypeProperty) {
            propertyData = source;
            manualData = self;
        } else if (self.methodType == GBMethodTypeInstance && source.methodType == GBMethodTypeClass) {
            return NO;
        } else if (self.methodType == GBMethodTypeClass && source.methodType == GBMethodTypeInstance) {
            return NO;
        } else if (self.methodType == GBMethodTypeProperty && source.methodType == GBMethodTypeClass) {
            return NO;
        } else {
            [NSException raise:@"Failed merging %@ to %@; method type doesn't match!", source, self];
        }

        // We should allow if the getter or setter matches and if the getter name is shared to an instance method.
        if ([propertyData.propertyGetterSelector isEqualToString:manualData.methodSelector]) return YES;
        if ([propertyData.propertySetterSelector isEqualToString:manualData.methodSelector]) return YES;
        if (![propertyData.propertyType isEqualToString:manualData.methodReturnType]) return YES;
        [NSException raise:@"Failed merging %@ to %@; getter or setter doesn't match", source, self];
    } else {
        // If assertion from code below is present, it breaks cases where category declares a property which is also getter for a property from class declaration. See #184 https://github.com/tomaz/appledoc/issues/184 for details. I'm leaving the code commented for the moment to see if it also affects some other user (don't think so, but just in case).
        //NSParameterAssert([source.methodSelector isEqualToString:self.methodSelector]);
    }
    return YES;
}
b9AobJ commented 2 years ago
        else if (self.methodType == GBMethodTypeClass && source.methodType == GBMethodTypeProperty) {
            propertyData = source;
            manualData = self;
        }  else {
        [NSException raise:@"Failed merging %@ to %@; method type doesn't match!", source, self];
    }

can pass err but no support to docset content about class keyword property