Record Objective-C method lookup tables in Swift modules.

Include a mapping from Objective-C selectors to the @objc methods that
produce Objective-c methods with those selectors. Use this to lazily
populate the Objective-C method lookup tables in each class. This makes
@objc override checking work across Swift modules, which is part of
rdar://problem/18391046.

Note that we use a single, unified selector table, both because it is
simpler and because it makes global queries ("is there any method with
the given selector?") easier.

Swift SVN r23214
This commit is contained in:
Doug Gregor
2014-11-11 00:19:03 +00:00
parent 3910c25da1
commit b27e88b70b
16 changed files with 426 additions and 18 deletions

View File

@@ -0,0 +1,26 @@
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: %swift -emit-module -disable-objc-attr-requires-foundation-module -o %t %S/Inputs/objc_method_decls.swift
// RUN: llvm-bcanalyzer %t/objc_method_decls.swiftmodule | FileCheck %s
// RUN: %swift -parse -disable-objc-attr-requires-foundation-module -I=%t %s -verify
import objc_method_decls
class B : A {
@objc func a1() { } // expected-error{{method 'a1()' overrides Objective-C method 'a1' from superclass 'A'}}
@objc init(int: Int) { // expected-error{{initializer 'init(int:)' overrides Objective-C method 'initWithInt:' from superclass 'A'}}
self.foo = int
super.init()
}
@objc var foo: Int // expected-error{{setter for 'foo' overrides Objective-C method 'setFoo:' from superclass 'A'}}
@objc subscript (i: Int) -> AnyObject {
get { return self } // expected-error{{subscript getter overrides Objective-C method 'objectAtIndexedSubscript:' from superclass 'A'}}
set { }
}
}
// Make sure the OBJC_METHODS table is present.
// CHECK: OBJC_METHODS