mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
26
test/Serialization/objc_method_table.swift
Normal file
26
test/Serialization/objc_method_table.swift
Normal 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
|
||||
Reference in New Issue
Block a user