mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
61 lines
1.3 KiB
Swift
61 lines
1.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-swift-frontend -typecheck -I %t/Inputs -cxx-interoperability-mode=default -verify %t/test.swift
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
//--- Inputs/header.h
|
|
|
|
class Trivial {
|
|
public:
|
|
int x;
|
|
};
|
|
|
|
class NonTrivial {
|
|
public:
|
|
NonTrivial(const NonTrivial &other) : x(other.x) {}
|
|
~NonTrivial() { }
|
|
|
|
private:
|
|
int x;
|
|
};
|
|
|
|
struct NonTrivialDestrOnly {
|
|
~NonTrivialDestrOnly() { }
|
|
|
|
private:
|
|
int x;
|
|
};
|
|
|
|
//--- Inputs/module.modulemap
|
|
|
|
module NonTrivial {
|
|
header "header.h"
|
|
export *
|
|
}
|
|
|
|
//--- test.swift
|
|
|
|
import Foundation
|
|
import NonTrivial
|
|
|
|
@objc
|
|
class ObjCObject: NSObject {
|
|
@objc var prop: NonTrivial // expected-error {{property cannot be marked '@objc' because its type cannot be represented in Objective-C}}
|
|
// expected-note@-1 {{non-trivial C++ classes cannot be represented in Objective-C}}
|
|
|
|
@objc var trivProp: Trivial
|
|
|
|
override init() { fatalError() }
|
|
|
|
@objc func getNonTrivial() -> NonTrivialDestrOnly { // expected-error {{method cannot be marked '@objc' because its result type cannot be represented in Objective-C}}
|
|
// expected-note@-1 {{non-trivial C++ classes cannot be represented in Objective-C}}
|
|
fatalError()
|
|
}
|
|
|
|
@objc func getTrivial() -> Trivial {
|
|
return Trivial(x: 11)
|
|
}
|
|
}
|