Skip to content

[API Notes] Add tests for API notes that change types of Clang declarations #5733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ Classes:
- Name: accessorsOnlyForClassExceptInVersion3
PropertyKind: Class
SwiftImportAsAccessors: true
- Name: accessorsOnlyWithNewType
PropertyKind: Instance
SwiftImportAsAccessors: true
Type: '__kindof Base * _Nonnull'
- Name: TypeChanges
Methods:
- Selector: 'methodWithA:'
MethodKind: Instance
ResultType: 'A * _Nonnull'
Parameters:
- Position: 0
Type: 'A * _Nullable'
Functions:
- Name: jumpToLocation
SwiftName: 'jumpTo(x:y:z:)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@ void jumpToLocation(double x, double y, double z);
void acceptDoublePointer(double* _Nonnull ptr) __attribute__((swift_name("accept(_:)")));

#ifdef __OBJC__

__attribute__((objc_root_class))
@interface A
@end

__attribute__((objc_root_class))
@interface TypeChanges
-(nonnull id)methodWithA:(nonnull id)a;
@end

#import <APINotesFrameworkTest/Properties.h>
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ __attribute__((objc_root_class))
@property (nonatomic, readwrite, retain, class) id accessorsOnlyForClass;
@end

@interface TestProperties (Retyped)
@property (nonatomic, readwrite, retain) id accessorsOnlyWithNewType;
@end

#pragma clang assume_nonnull end
5 changes: 5 additions & 0 deletions test/APINotes/properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@
// CHECK-BOTH-DAG: class func accessorsOnlyForClass() -> Any
// CHECK-BOTH-DAG: class func setAccessorsOnlyForClass(_ accessorsOnlyForClass: Any)
// CHECK-BOTH: {{^}$}}

// CHECK-BOTH-DAG: func accessorsOnlyWithNewType() -> Base
// CHECK-BOTH-DAG: func setAccessorsOnlyWithNewType(_ accessorsOnlyWithNewType: Base)

// CHECK-BOTH: {{^}$}}
12 changes: 12 additions & 0 deletions test/APINotes/type_changes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %target-parse-verify-swift -I %S/Inputs/custom-modules -F %S/Inputs/custom-frameworks

// REQUIRES: objc_interop

import APINotesTest
import APINotesFrameworkTest


func testChangedTypes(tc: TypeChanges, a: A, i: Int) {
_ = tc.method(with: i) // expected-error{{cannot convert value of type 'Int' to expected argument type 'A?'}}
let _: Int = tc.method(with: a) // expected-error{{cannot convert value of type 'A' to specified type 'Int'}}
}