Files
swift-mirror/test/SILGen/polymorphic_inout_aliasing.swift
Joe Groff f1b97a1ead SILGen: Admit inout aliasing of polymorphic properties.
A stored property of a class may be overridden by a computed one, and a property requirement may be witnessed by a computed property, but rejecting inout aliasing in these cases isn't very helpful. Only reject cases that are definitely computed and will always behave incorrectly. Fixes rdar://problem/19633414.

Swift SVN r24986
2015-02-05 01:22:02 +00:00

27 lines
668 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
struct Block {}
class Story {
final var finalStored = [Block]()
var overridableStored = [Block]()
var computed: [Block] {
get { return [] }
set {}
}
func test() {
swap(&self.finalStored[0], &self.finalStored[1])
swap(&self.overridableStored[0], &self.overridableStored[1])
swap(&self.computed[0], &self.computed[1]) // expected-error{{invalid aliasing}} expected-note{{concurrent writeback}}
}
}
protocol StoriedType {
var protocolRequirement: [Block] { get set }
}
func testProtocol<T: StoriedType>(inout x: T) {
swap(&x.protocolRequirement[0], &x.protocolRequirement[1])
}