Skip to content

Commit f6dd524

Browse files
committed
SILGen: Increase test coverage for lazy typechecking.
None of these additional test cases actually uncovered any problems but it seems valuable to have them. Also, add pretty stack traces for a couple paths through SILGen.
1 parent 64dc2e9 commit f6dd524

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class SILGenVTable : public SILVTableVisitor<SILGenVTable> {
260260
}
261261

262262
void emitVTable() {
263+
PrettyStackTraceDecl("silgen emitVTable", theClass);
264+
263265
// Imported types don't have vtables right now.
264266
if (theClass->hasClangNode())
265267
return;
@@ -1118,6 +1120,8 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
11181120

11191121
/// Emit SIL functions for all the members of the type.
11201122
void emitType() {
1123+
PrettyStackTraceDecl("silgen emitType", theType);
1124+
11211125
SGM.emitLazyConformancesForType(theType);
11221126

11231127
for (Decl *member : theType->getABIMembers()) {
@@ -1292,6 +1296,8 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
12921296

12931297
/// Emit SIL functions for all the members of the extension.
12941298
void emitExtension(ExtensionDecl *e) {
1299+
PrettyStackTraceDecl("silgen emitExtension", e);
1300+
12951301
// Arguably, we should divert to SILGenType::emitType() here if it's an
12961302
// @_objcImplementation extension, but we don't actually need to do any of
12971303
// the stuff that it currently does.

test/SILGen/lazy_typecheck_errors.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -module-name Test -enable-library-evolution -experimental-lazy-typecheck -verify
1+
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -enable-library-evolution -module-name Test -experimental-lazy-typecheck -verify
2+
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -enable-library-evolution -module-name Test -experimental-lazy-typecheck -experimental-skip-non-inlinable-function-bodies -verify
3+
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -enable-library-evolution -module-name Test -experimental-lazy-typecheck -experimental-skip-non-inlinable-function-bodies -experimental-skip-non-exportable-decls -verify
4+
25

36
public protocol Proto {
47
func req()
@@ -21,3 +24,32 @@ public protocol ProtoWithAssociatedType {
2124
public struct ConformsToProtoProtoWithAssociatedType: ProtoWithAssociatedType {
2225
// expected-error@-1 {{type 'ConformsToProtoProtoWithAssociatedType' does not conform to protocol 'ProtoWithAssociatedType'}}
2326
}
27+
28+
public struct GenericStruct<T> {
29+
public var t: T
30+
}
31+
32+
public struct GenericStructWithInvalidParameterConstraint<T: NonExistent> {
33+
// expected-error@-1 {{cannot find type 'NonExistent' in scope}}
34+
}
35+
36+
extension GenericStruct where T == NonExistent {
37+
// expected-error@-1 {{cannot find type 'NonExistent' in scope}}
38+
public func methodInExtensionWithInvalidWhereClause() {}
39+
}
40+
41+
public class ValidClass {
42+
public func methodReturningNonExistentType() -> NonExistent {}
43+
// expected-error@-1 {{cannot find type 'NonExistent' in scope}}
44+
}
45+
46+
public class DerivedFromValidClass: ValidClass {
47+
override public func methodReturningNonExistentType() -> NonExistent {}
48+
// expected-error@-1 {{cannot find type 'NonExistent' in scope}}
49+
}
50+
51+
public class DerivedFromNonExistent: NonExistent {
52+
// expected-error@-1 {{cannot find type 'NonExistent' in scope}}
53+
54+
public func method() {}
55+
}

0 commit comments

Comments
 (0)