swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.4k stars 10.34k forks source link

[SR-4627] NSUndoManager compile error inside UIView (whole module optimization) #47204

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-4627
Radar None
Original Reporter gugmaster (JIRA User)
Type Bug

Attachment: Download

Environment iOS 9 / iOS 10
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, OptimizedOnly | |Assignee | None | |Priority | Medium | md5: 24cb7965aaaad6cc4a5fe90eeb3b5999

Issue Description:

When I'm calling prepare: withInvocationTarget on NSUndoManager inside UIView I get a compile error (when archiving - building with whole module optimization). If I build and run (fast single file optimization) it compiles without any problem.

belkadan commented 7 years ago
   TestViewCollectionViewCell.swift:18:53: error: value of type 'AnyObject' has no member 'specialMethod'
                (undoManager?.prepare(withInvocationTarget: self) as AnyObject).specialMethod(test: "test")
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ ~~~~~~~~~~~~~

Interesting. I guess we're not collecting all valid Objective-C methods correctly with WMO.

belkadan commented 7 years ago

@DougGregor, have you ever seen this before?

DougGregor commented 7 years ago

No, I haven't seen this before, but it seems plausible in a multi-file scenario that we aren't going through and exhaustively checking every class/protocol in the module for a member with that name.