File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ // Nested subclass, typealias Self.
4
+ class Base {
5
+ class Derived : Base {
6
+ init ( x: Int ) { }
7
+ }
8
+ typealias Ident = Base
9
+ }
10
+
11
+ let _: Base = . Derived( x: 12 )
12
+ let _: Base = . Ident( )
13
+
14
+ // Typealias in protocol.
15
+ protocol P {
16
+ typealias Impl1 = ConcreteP
17
+ }
18
+ extension P {
19
+ typealias Impl2 = ConcreteP
20
+ }
21
+ struct ConcreteP : P {
22
+ }
23
+
24
+ let _: P = . Impl1( )
25
+ let _: P = . Impl2( )
26
+ let _: ConcreteP = . Impl1( )
27
+ let _: ConcreteP = . Impl2( )
Original file line number Diff line number Diff line change @@ -35,3 +35,16 @@ struct Foo {
35
35
func & ( x: Foo , y: Foo ) -> Foo { }
36
36
37
37
var fooValue : Foo = . Bar & . Wibble
38
+
39
+ // Static closure variables.
40
+ struct HasClosure {
41
+ static var factoryNormal : ( Int ) -> HasClosure = { _ in . init( ) }
42
+ static var factoryReturnOpt : ( Int ) -> HasClosure ? = { _ in . init( ) }
43
+ static var factoryIUO : ( ( Int ) -> HasClosure ) ! = { _ in . init( ) }
44
+ static var factoryOpt : ( ( Int ) -> HasClosure ) ? = { _ in . init( ) }
45
+ }
46
+ var _: HasClosure = . factoryNormal( 0 )
47
+ var _: HasClosure = . factoryReturnOpt( 1 ) !
48
+ var _: HasClosure = . factoryIUO( 2 )
49
+ var _: HasClosure = . factoryOpt( 3 ) // expected-error {{static property 'factoryOpt' is not a function}}
50
+ var _: HasClosure = . factoryOpt!( 4 ) // expected-error {{type of expression is ambiguous without more context}}
You can’t perform that action at this time.
0 commit comments