mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Set up the disjunction system for '&x' expressions that allows them to type-check either as simple lvalue-to-inout conversions, as before, or as address conversions that go through one of the BuiltinInOut*Convertible protocols. The solution side is not yet implemented. Swift SVN r15593
32 lines
1.0 KiB
Swift
32 lines
1.0 KiB
Swift
// RUN: %swift -parse-stdlib -parse -verify %s
|
|
|
|
import Swift
|
|
|
|
// A type that is convertible from an inout parameter.
|
|
struct ArgPointer<T>: BuiltinInOutAddressConvertible {
|
|
typealias _InOutType = T
|
|
static func _convertFromInOutAddress(addr: Builtin.RawPointer) -> ArgPointer {
|
|
return ArgPointer()
|
|
}
|
|
}
|
|
|
|
func takeIntArgPointer(x: ArgPointer<Int>) {}
|
|
func takeStringArgPointer(x: ArgPointer<String>) {}
|
|
|
|
var mutInt = Int()
|
|
var mutStr = String()
|
|
|
|
let immInt = Int()
|
|
let immStr = String()
|
|
|
|
takeIntArgPointer(&mutInt) // expected-error{{not implemented}}
|
|
takeIntArgPointer(&immInt) // expected-error{{not a subtype of '@lvalue}}
|
|
takeIntArgPointer(&mutStr) // expected-error{{does not type-check}}
|
|
takeIntArgPointer(&immStr) // expected-error{{not a subtype of '@lvalue}}
|
|
|
|
takeStringArgPointer(&mutInt) // expected-error{{does not type-check}}
|
|
takeStringArgPointer(&immInt) // expected-error{{not a subtype of '@lvalue}}
|
|
takeStringArgPointer(&mutStr) // expected-error{{not implemented}}
|
|
takeStringArgPointer(&immStr) // expected-error{{not a subtype of '@lvalue}}
|
|
|