Skip to content

Commit 9319a53

Browse files
committed
AST: Stricter contract for Type::subst()
Fix an odd corner case when UseErrorTypes was off; we would return the empty type if dependent member type substitution failed, but otherwise return the original type if it was a generic type parameter or an archetype. Now, if UseErrorTypes is off, return the empty type in both cases, even if the original type is 'primary'.
1 parent a3f725a commit 9319a53

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,7 +3049,7 @@ static Type substType(Type derivedType,
30493049
if (isa<GenericTypeParamType>(substOrig)) {
30503050
if (options.contains(SubstFlags::UseErrorType))
30513051
return ErrorType::get(type);
3052-
return Type(type);
3052+
return Type();
30533053
}
30543054

30553055
auto archetype = cast<ArchetypeType>(substOrig);
@@ -3065,7 +3065,7 @@ static Type substType(Type derivedType,
30653065
if (!parent) {
30663066
if (options.contains(SubstFlags::UseErrorType))
30673067
return ErrorType::get(type);
3068-
return Type(type);
3068+
return Type();
30693069
}
30703070

30713071
// Substitute into the parent type.

validation-test/compiler_crashers/28732-type-hasarchetype-not-fully-substituted.swift renamed to validation-test/compiler_crashers_fixed/28732-type-hasarchetype-not-fully-substituted.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

88
// REQUIRES: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
9+
// RUN: not %target-swift-frontend %s -emit-ir
1010
{
1111
protocol A{
1212
struct A:P{

0 commit comments

Comments
 (0)