Skip to content

Commit 07b26e2

Browse files
committed
Deal with tests that don't import the Swift standard library
1 parent 33d6944 commit 07b26e2

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,13 +2047,14 @@ static bool checkSingleOverride(ValueDecl *override, ValueDecl *base) {
20472047
Type baseThrownError =
20482048
baseFn->getEffectiveThrownErrorType().value_or(ctx.getNeverType());
20492049

2050-
if (baseThrownError->hasTypeParameter()) {
2050+
if (baseThrownError && baseThrownError->hasTypeParameter()) {
20512051
auto subs = SubstitutionMap::getOverrideSubstitutions(base, override);
20522052
baseThrownError = baseThrownError.subst(subs);
20532053
baseThrownError = overrideFn->mapTypeIntoContext(baseThrownError);
20542054
}
20552055

2056-
overrideThrownError = overrideFn->mapTypeIntoContext(overrideThrownError);
2056+
if (overrideThrownError)
2057+
overrideThrownError = overrideFn->mapTypeIntoContext(overrideThrownError);
20572058

20582059
// Check for a subtyping relationship.
20592060
switch (compareThrownErrorsForSubtyping(

lib/Sema/TypeCheckEffects.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,6 +3549,13 @@ ThrownErrorSubtyping
35493549
swift::compareThrownErrorsForSubtyping(
35503550
Type subThrownError, Type superThrownError, DeclContext *dc
35513551
) {
3552+
// Deal with NULL errors. This should only occur when there is no standard
3553+
// library.
3554+
if (!subThrownError || !superThrownError) {
3555+
assert(!dc->getASTContext().getStdlibModule() && "NULL thrown error type");
3556+
return ThrownErrorSubtyping::ExactMatch;
3557+
}
3558+
35523559
// Easy case: exact match.
35533560
if (superThrownError->isEqual(subThrownError))
35543561
return ThrownErrorSubtyping::ExactMatch;

test/IRGen/protocol_synthesized.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import SynthesizedProtocol
1212

13+
enum Never { }
14+
protocol Error { }
15+
1316
// CHECK: @"$sSo5Flagsas9OptionSetSCMc" = linkonce_odr hidden constant { i32, i32, i32, i32, i16, i16, i32, i32 } { i32 {{(trunc \(i64 )?}}sub ({{i(32|64)}} ptrtoint (ptr @"$ss9OptionSetMp" to {{i(32|64)}}), {{i(32|64)}} ptrtoint (ptr @"$sSo5Flagsas9OptionSetSCMc" to {{i(32|64)}})){{( to i32\))?}}, i32 {{(trunc \(i64 )?}}sub ({{i(32|64)}} ptrtoint (ptr @"$sSo5FlagsaMn" to {{i(32|64)}}), {{i(32|64)}} ptrtoint (ptr getelementptr inbounds ({ i32, i32, i32, i32, i16, i16, i32, i32 }, ptr @"$sSo5Flagsas9OptionSetSCMc", i32 0, i32 1) to {{i(32|64)}})){{( to i32\))?}}, i32 {{(trunc \(i64 )?}}sub ({{i(32|64)}} ptrtoint (ptr @"$sSo5Flagsas9OptionSetSCWP" to {{i(32|64)}}), {{i(32|64)}} ptrtoint (ptr getelementptr inbounds ({ i32, i32, i32, i32, i16, i16, i32, i32 }, ptr @"$sSo5Flagsas9OptionSetSCMc", i32 0, i32 2) to {{i(32|64)}})){{( to i32\))?}}, i32 131200, i16 3, i16 1, i32 {{(trunc \(i64 )?}}sub ({{i(32|64)}} ptrtoint (ptr @"$sSo5Flagsas9OptionSetSCWI" to {{i(32|64)}}), {{i(32|64)}} ptrtoint (ptr getelementptr inbounds ({ i32, i32, i32, i32, i16, i16, i32, i32 }, ptr @"$sSo5Flagsas9OptionSetSCMc", i32 0, i32 6) to {{i(32|64)}})){{( to i32\))?}}, i32 {{(trunc \(i64 )?}}sub ({{i(32|64)}} ptrtoint (ptr @"$sSo5Flagsas9OptionSetSCMcMK" to {{i(32|64)}}), {{i(32|64)}} ptrtoint (ptr getelementptr inbounds ({ i32, i32, i32, i32, i16, i16, i32, i32 }, ptr @"$sSo5Flagsas9OptionSetSCMc", i32 0, i32 7) to {{i(32|64)}})) {{(to i32\) )?}}}, section "{{[^"]*}}"{{(, comdat)?}},{{.*}} align 4
1417

1518
// Triggers the inclusion of the relevant ProtocolConformanceDescriptor

test/SIL/OwnershipVerifier/definite_init.sil

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ sil_stage raw
55

66
import Builtin
77

8+
enum Never { }
9+
protocol Error { }
10+
811
enum Optional<T> {
912
case some(T)
1013
case none

0 commit comments

Comments
 (0)