Skip to content

Commit 296492e

Browse files
authored
Merge pull request #10941 from CodaFi/im-in-ur-member-base
Never Bind to ErrorType
2 parents d18d534 + e83131d commit 296492e

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ getSubstitutionMap(TypeSubstitutionFn subs,
422422
Type currentReplacement = depTy.subst(subs, lookupConformance,
423423
SubstFlags::UseErrorType);
424424
if (auto paramTy = dyn_cast<GenericTypeParamType>(canTy))
425-
subMap.addSubstitution(paramTy, currentReplacement);
425+
if (!currentReplacement->hasError())
426+
subMap.addSubstitution(paramTy, currentReplacement);
426427

427428
// Collect the conformances.
428429
for (auto req: reqs) {

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
29342934
// Error recovery path.
29352935
// FIXME: Generalized existentials will look here.
29362936
if (substBase->isOpenedExistential())
2937-
return getDependentMemberType(ErrorType::get(substBase));
2937+
return failed();
29382938

29392939
// If the parent is an archetype, extract the child archetype with the
29402940
// given name.
@@ -2945,7 +2945,7 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
29452945
// If looking for an associated type and the archetype is constrained to a
29462946
// class, continue to the default associated type lookup
29472947
if (!assocType || !archetypeParent->getSuperclass())
2948-
return getDependentMemberType(ErrorType::get(substBase));
2948+
return failed();
29492949
}
29502950

29512951
// If the parent is a type variable or a member rooted in a type variable,

lib/Sema/CSBindings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
148148
// coalescing supertype bounds when we are able to compute the meet.
149149
auto addPotentialBinding = [&](PotentialBinding binding,
150150
bool allowJoinMeet = true) {
151+
assert(!binding.BindingType->is<ErrorType>());
151152
// If this is a non-defaulted supertype binding, check whether we can
152153
// combine it with another supertype binding by computing the 'join' of the
153154
// types.
@@ -375,6 +376,10 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) {
375376
result.InvolvesTypeVariables = true;
376377
continue;
377378
}
379+
380+
// Do not attempt to bind to ErrorType.
381+
if (type->hasError())
382+
continue;
378383

379384
// If the type we'd be binding to is a dependent member, don't try to
380385
// resolve this type variable yet.

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ bool ConstraintSystem::typeVarOccursInType(TypeVariableType *typeVar,
128128

129129
void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
130130
bool updateState) {
131-
131+
assert(!type->hasError() &&
132+
"Should not be assigning a type involving ErrorType!");
133+
132134
typeVar->getImpl().assignFixedType(type, getSavedBindings());
133135

134136
if (!updateState)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
extension CountableRange{{}{}protocol P{typealias a:A{}func
1010
protocol A:CountableRange

0 commit comments

Comments
 (0)