Files
swift-mirror/test/Constraints/inout_conversion.swift
Joe Groff 93f319c706 Sema: Set up constraints for inout conversions.
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
2014-03-29 02:50:24 +00:00

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}}