Sema: A couple of recursion-breaking hacks

This commit is contained in:
Slava Pestov
2017-06-06 02:04:16 -07:00
parent d5e54b88df
commit c152fee9f8
6 changed files with 26 additions and 8 deletions

View File

@@ -1662,9 +1662,13 @@ PotentialArchetype *PotentialArchetype::getNestedArchetypeAnchor(
assocType = dyn_cast<AssociatedTypeDecl>(member);
// FIXME: Filter out type declarations that aren't in the protocol itself?
if (!concreteDecl && !isa<AssociatedTypeDecl>(member))
if (!concreteDecl && !isa<AssociatedTypeDecl>(member)) {
if (!member->hasInterfaceType())
builder.getLazyResolver()->resolveDeclSignature(member);
if (member->hasInterfaceType())
concreteDecl = dyn_cast<TypeDecl>(member);
}
}
if (assocType &&
(!bestAssocType ||
@@ -1781,9 +1785,13 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
assocType = dyn_cast<AssociatedTypeDecl>(member);
// FIXME: Filter out concrete types that aren't in the protocol itself?
if (!concreteDecl && !isa<AssociatedTypeDecl>(member))
if (!concreteDecl && !isa<AssociatedTypeDecl>(member)) {
if (!member->hasInterfaceType())
proto->getASTContext().getLazyResolver()->resolveDeclSignature(member);
if (member->hasInterfaceType())
concreteDecl = dyn_cast<TypeDecl>(member);
}
}
// There is no associated type or concrete type with this name in this
// protocol

View File

@@ -599,6 +599,10 @@ ModuleDecl::lookupConformance(Type type, ProtocolDecl *protocol,
// existential's list of conformances and the existential conforms to
// itself.
if (type->isExistentialType()) {
// FIXME: Recursion break.
if (!protocol->hasValidSignature())
return None;
// If the existential type cannot be represented or the protocol does not
// conform to itself, there's no point in looking further.
if (!protocol->existentialConformsToSelf() ||

View File

@@ -4200,7 +4200,13 @@ void ConformanceChecker::resolveTypeWitnesses() {
}
TC.validateDecl(assocType);
Type defaultType = assocType->getDefaultDefinitionLoc().getType().subst(
Type defaultType = assocType->getDefaultDefinitionLoc().getType();
// FIXME: Circularity
if (!defaultType)
return Type();
defaultType = defaultType.subst(
QueryTypeSubstitutionMap{substitutions},
LookUpConformanceInModule(DC->getParentModule()));

View File

@@ -5,5 +5,5 @@
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
protocol P{{}typealias a:=A.a:struct A:P

View File

@@ -5,5 +5,5 @@
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
protocol P}extension P{typealias a:Self.a{}func a:Self.a

View File

@@ -6,5 +6,5 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
// REQUIRES: asserts
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
@objc protocol P{typealias e:P{}var a}{}extension P{typealias e:P