Files
swift-mirror/test/expr/cast/array_iteration.swift
Doug Gregor 750566b249 Implicitly create type declarations for inferred associated type witnesses.
The type checker (and various other parts of the front end) jump
through many hoops to try to cope with the lack of a proper
declaration for an inferred type witness, causing various annoying
bugs. Additionally, we were creating implicit declarations for
derived/synthesized witnesses, leading to inconsistent AST
representations. This ch

Note that we'll now end up printing the inferred type aliases for type
witnesses, which represents a reversal of the decision that closed
rdar://problem/15168378. This result is more consistent.

Now with a simpler accessibility computation.

Swift SVN r27512
2015-04-21 00:21:55 +00:00

47 lines
788 B
Swift

// RUN: %target-parse-verify-swift
class View {
var subviews: Array<AnyObject>! = []
}
var rootView = View()
var v = [View(), View()]
rootView.subviews = v
rootView.subviews as! [View]
for view in rootView.subviews as! [View] {
println("found subview")
}
// FIXME: Unhelpful diagnostic here.
for view:View in rootView.subviews { // expected-error{{'Array<AnyObject>!' is not convertible to '_BuiltinIntegerLiteralConvertible'}}
println("found subview")
}
(rootView.subviews!) as! [View]
(rootView.subviews) as! [View]
var ao: [AnyObject] = []
ao as! [View] // works
var b = Array<(String, Int)>()
for x in b {
println("hi")
}
var c : Array<(String, Int)>! = Array()
for x in c {
println("hi")
}
var d : Array<(String, Int)>? = Array()
for x in d! {
println("hi")
}