Skip to content

Commit 07545b9

Browse files
committed
[Test] Add typechecker test cases for unresolved member expr
Some uncommon cases including: * Closure static properties * Nested types
1 parent f40c3b1 commit 07545b9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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()

test/expr/delayed-ident/static_var.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,16 @@ struct Foo {
3535
func & (x: Foo, y: Foo) -> Foo { }
3636

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

0 commit comments

Comments
 (0)