Skip to content

Commit dbfcdb5

Browse files
committed
NFC: Expand -experimental-lazy-typecheck test coverage.
Add classes and constructors to the APIs vended by the `lazy_typecheck` module.
1 parent 9a993b6 commit dbfcdb5

File tree

4 files changed

+74
-11
lines changed

4 files changed

+74
-11
lines changed

test/Inputs/lazy_typecheck.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,25 @@ protocol InternalProto {
6161
public struct PublicStruct {
6262
// FIXME: Test properties
6363

64+
public init(x: Int) {
65+
_ = DoesNotExist() // expected-error {{cannot find 'DoesNotExist' in scope}}
66+
}
67+
6468
public func publicMethod() -> Int {
6569
return true // expected-error {{cannot convert return expression of type 'Bool' to return type 'Int'}}
6670
}
6771

72+
public static func publicStaticMethod() {
73+
_ = DoesNotExist() // expected-error {{cannot find 'DoesNotExist' in scope}}
74+
}
75+
6876
func internalMethod() -> DoesNotExist { // expected-error {{cannot find type 'DoesNotExist' in scope}}
6977
return 1
7078
}
79+
80+
static func internalStaticMethod() -> DoesNotExist { // expected-error {{cannot find type 'DoesNotExist' in scope}}
81+
return 1
82+
}
7183
}
7284

7385
struct InternalStruct: DoesNotExist { // expected-error {{cannot find type 'DoesNotExist' in scope}}
@@ -76,6 +88,32 @@ struct InternalStruct: DoesNotExist { // expected-error {{cannot find type 'Does
7688
func f(_ x: DoesNotExist) {} // expected-error {{cannot find type 'DoesNotExist' in scope}}
7789
}
7890

91+
public class PublicClass {
92+
// FIXME: Test properties
93+
94+
public init(x: Int) {
95+
_ = DoesNotExist() // expected-error {{cannot find 'DoesNotExist' in scope}}
96+
}
97+
98+
// FIXME: TBDGen causes this constructor to be type checked
99+
// init(_ x: DoesNotExist) {}
100+
101+
public func publicMethod() -> Int {
102+
return true // expected-error {{cannot convert return expression of type 'Bool' to return type 'Int'}}
103+
}
104+
105+
public class func publicClassMethod() {
106+
_ = DoesNotExist() // expected-error {{cannot find 'DoesNotExist' in scope}}
107+
}
108+
109+
// FIXME: TBDGen causes these methods to be type checked
110+
// func internalMethod() -> DoesNotExist {}
111+
// class func internalClassMethod() -> DoesNotExist {}
112+
}
113+
114+
class InternalClass: DoesNotExist { // expected-error {{cannot find type 'DoesNotExist' in scope}}
115+
init(x: DoesNotExist) {} // expected-error {{cannot find type 'DoesNotExist' in scope}}
116+
}
79117
// FIXME: Test enums
80118
// FIXME: Test conformances
81119
// FIXME: Test global vars

test/Inputs/lazy_typecheck_client.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func testGlobalFunctions() {
2020
}
2121
}
2222

23-
func testPublicStruct(_ s: PublicStruct) {
23+
func testPublicStruct() {
24+
var s = PublicStruct(x: 1)
2425
_ = s.publicMethod()
26+
PublicStruct.publicStaticMethod()
27+
}
28+
29+
func testPublicClass() {
30+
let c = PublicClass(x: 2)
31+
_ = c.publicMethod()
32+
PublicClass.publicClassMethod()
2533
}

test/ModuleInterface/lazy-typecheck.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -emit-module -emit-module-path /dev/null -emit-module-interface-path %t/lazy_typecheck.swiftinterface -enable-library-evolution -parse-as-library -package-name Package -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-serialize-external-decls-only
3+
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -typecheck -emit-module-interface-path %t/lazy_typecheck.swiftinterface -enable-library-evolution -parse-as-library -package-name Package -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-serialize-external-decls-only
44
// RUN: %FileCheck %s < %t/lazy_typecheck.swiftinterface
55

66
// RUN: rm -rf %t/*.swiftmodule
@@ -31,5 +31,12 @@
3131
// CHECK: }
3232

3333
// CHECK: public struct PublicStruct {
34+
// CHECK: public init(x: Swift.Int)
3435
// CHECK: public func publicMethod() -> Swift.Int
3536
// CHECK: }
37+
38+
// CHECK: public class PublicClass {
39+
// CHECK: public init(x: Swift.Int)
40+
// CHECK: public func publicMethod() -> Swift.Int
41+
// CHECK: deinit
42+
// CHECK: }

test/TBD/lazy-typecheck.swift

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,23 @@ compatibility-version: 0
1717
swift-abi-version: 7
1818
exports:
1919
- targets: [ arm64-macos ]
20-
symbols: [ '_$s14lazy_typecheck10publicFuncSiyF', '_$s14lazy_typecheck11PublicProtoMp',
21-
'_$s14lazy_typecheck11PublicProtoP3reqSiyFTj', '_$s14lazy_typecheck11PublicProtoP3reqSiyFTq',
22-
'_$s14lazy_typecheck11PublicProtoTL', '_$s14lazy_typecheck11packageFuncSiyF',
23-
'_$s14lazy_typecheck12PublicStructV12publicMethodSiyF', '_$s14lazy_typecheck12PublicStructVMa',
24-
'_$s14lazy_typecheck12PublicStructVMn', '_$s14lazy_typecheck12PublicStructVN',
25-
'_$s14lazy_typecheck13inlinableFuncSiyF', '_$s14lazy_typecheck24publicFuncWithDefaultArgyS2iF',
26-
'_$s14lazy_typecheck30publicFuncWithOpaqueReturnTypeQryF',
27-
'_$s14lazy_typecheck30publicFuncWithOpaqueReturnTypeQryFQOMQ',
28-
'_$s14lazy_typecheck32constrainedGenericPublicFunctionyyxAA0E5ProtoRzlF' ]
20+
symbols: [ '_$s14lazy_typecheck10publicFuncSiyF', '_$s14lazy_typecheck11PublicClassC06publicD6MethodyyFZTj',
21+
'_$s14lazy_typecheck11PublicClassC06publicD6MethodyyFZTq',
22+
'_$s14lazy_typecheck11PublicClassC12publicMethodSiyFTj', '_$s14lazy_typecheck11PublicClassC12publicMethodSiyFTq',
23+
'_$s14lazy_typecheck11PublicClassC1xACSi_tcfC', '_$s14lazy_typecheck11PublicClassC1xACSi_tcfCTj',
24+
'_$s14lazy_typecheck11PublicClassC1xACSi_tcfCTq', '_$s14lazy_typecheck11PublicClassC1xACSi_tcfc',
25+
'_$s14lazy_typecheck11PublicClassCMa', '_$s14lazy_typecheck11PublicClassCMm',
26+
'_$s14lazy_typecheck11PublicClassCMn', '_$s14lazy_typecheck11PublicClassCMo',
27+
'_$s14lazy_typecheck11PublicClassCMu', '_$s14lazy_typecheck11PublicClassCN',
28+
'_$s14lazy_typecheck11PublicClassCfD', '_$s14lazy_typecheck11PublicClassCfd',
29+
'_$s14lazy_typecheck11PublicProtoMp', '_$s14lazy_typecheck11PublicProtoP3reqSiyFTj',
30+
'_$s14lazy_typecheck11PublicProtoP3reqSiyFTq', '_$s14lazy_typecheck11PublicProtoTL',
31+
'_$s14lazy_typecheck11packageFuncSiyF', '_$s14lazy_typecheck12PublicStructV12publicMethodSiyF',
32+
'_$s14lazy_typecheck12PublicStructV18publicStaticMethodyyFZ',
33+
'_$s14lazy_typecheck12PublicStructV1xACSi_tcfC', '_$s14lazy_typecheck12PublicStructVMa',
34+
'_$s14lazy_typecheck12PublicStructVMn', '_$s14lazy_typecheck12PublicStructVN',
35+
'_$s14lazy_typecheck13inlinableFuncSiyF', '_$s14lazy_typecheck24publicFuncWithDefaultArgyS2iF',
36+
'_$s14lazy_typecheck30publicFuncWithOpaqueReturnTypeQryF',
37+
'_$s14lazy_typecheck30publicFuncWithOpaqueReturnTypeQryFQOMQ',
38+
'_$s14lazy_typecheck32constrainedGenericPublicFunctionyyxAA0E5ProtoRzlF' ]
2939
...

0 commit comments

Comments
 (0)