Skip to content

"[self alloc]" in a class method not inferred to return an instance of that class #11949

@llvmbot

Description

@llvmbot
Bugzilla Link 11577
Resolution FIXED
Resolved on Feb 18, 2014 19:36
Version trunk
OS MacOS X
Attachments test case
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic,@tkremenek,@seanm

Extended Description

The result of +alloc should be inferred to be an instance of the receiving "self" class here, but is apparently just being typed as "id". This cause clang to think the -initWithContentsOfFile: and -initWithContentsOfURL: are possibly the deprecated methods in Foundation.

/Users/bungi/Source/LLVM/llvm/Release+Asserts/bin/clang -c incorrect-type-inferrence-vs-deprecation.m

incorrect-type-inferrence-vs-deprecation.m:32:14: warning: 'initWithContentsOfFile:' is deprecated [-Wdeprecated-declarations]
return [[[self alloc] initWithContentsOfFile:path] autorelease];
^
incorrect-type-inferrence-vs-deprecation.m:37:14: warning: 'initWithContentsOfURL:' is deprecated [-Wdeprecated-declarations]
return [[[self alloc] initWithContentsOfURL:url] autorelease];
^
2 warnings generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions