Skip to content

Fix Darwin collision of Point/Rect/Size types#18977

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
Rightpoint:objc-collision-fix
Dec 2, 2020
Merged

Fix Darwin collision of Point/Rect/Size types#18977
opencv-pushbot merged 1 commit intoopencv:masterfrom
Rightpoint:objc-collision-fix

Conversation

@chrisballinger
Copy link
Copy Markdown
Contributor

@chrisballinger chrisballinger commented Dec 1, 2020

Splitting this out into a standalone PR, based on the initial work here: #18925

This patch prevents a symbol conflict between types Point/Rect/Size and those provided by Darwin:

/Users/chrisbal/Documents/opencv/.build/x86_64-apple-macosx/debug/opencv2.framework/Modules/opencv2.swiftmodule/x86_64-apple-macos.swiftinterface:676:81: error: ambiguous type name 'Rect' in module 'opencv2'
  public func detectMultiScale(img: opencv2.Mat, foundLocations: inout [opencv2.Rect], foundWeights: inout [Swift.Double], hitThreshold: Swift.Double)
                                                                        ~~~~~~~ ^
opencv2.Rect:1:12: note: found candidate with type 'Rect'
open class Rect : NSObject {
           ^
Darwin.Rect:1:15: note: found candidate with type 'Rect'
public struct Rect {

I provided backwards compatibility typealiases, which are used by the existing test suite.

This doesn't attempt to solve #18843, which is still a problem, but would be a bigger undertaking.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
force_builders_only=docs,ios,Custom Mac
buildworker:Mac=macosx-1
buildworker:iOS=macosx-2
build_image:Custom Mac=osx_framework-test
buildworker:Custom Mac=macosx-1

@chrisballinger chrisballinger mentioned this pull request Dec 1, 2020
9 tasks
@asmorkalov asmorkalov requested a review from vpisarev December 1, 2020 08:33
@asmorkalov
Copy link
Copy Markdown
Contributor

@vpisarev Could you take a look?

@alalek
Copy link
Copy Markdown
Member

alalek commented Dec 1, 2020

/cc @komakai

@komakai
Copy link
Copy Markdown
Contributor

komakai commented Dec 1, 2020

As per my previous comment on #18843 my preferred way to solve this is to mark the Swift extensions that use these types as @nonobjc
like this:
komakai@aa949df

Note - there is no name clash in Swift, only in Objective-C

Copy link
Copy Markdown
Contributor

@komakai komakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Please consider a non-breaking change like in: komakai@aa949df

@chrisballinger
Copy link
Copy Markdown
Contributor Author

@komakai I've removed the other changes from this PR and cherry-picked komakai@aa949df as you suggested.

@komakai
Copy link
Copy Markdown
Contributor

komakai commented Dec 1, 2020

@komakai I've removed the other changes from this PR and cherry-picked komakai@aa949df as you suggested.

Thanks!

@opencv-pushbot opencv-pushbot merged commit e98c845 into opencv:master Dec 2, 2020
@chrisballinger chrisballinger deleted the objc-collision-fix branch December 2, 2020 21:41
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants