Skip to content

Commit 5c2fe42

Browse files
authored
Merge pull request #85517 from beccadax/mod-squad-bound-by-its-word
Don’t repeat lookup work that may not round-trip
2 parents 7ea48e5 + b9747b7 commit 5c2fe42

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/AST/NameLookup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,6 +3238,11 @@ static llvm::TinyPtrVector<TypeDecl *> directReferencesForQualifiedTypeLookup(
32383238
static DirectlyReferencedTypeDecls directReferencesForDeclRefTypeRepr(
32393239
Evaluator &evaluator, ASTContext &ctx, DeclRefTypeRepr *repr,
32403240
DeclContext *dc, DirectlyReferencedTypeLookupOptions options) {
3241+
// If we've already bound this TypeRepr, don't repeat the work.
3242+
if (repr->isBound()) {
3243+
return DirectlyReferencedTypeDecls({ repr->getBoundDecl() }, {});
3244+
}
3245+
32413246
if (auto *qualIdentTR = dyn_cast<QualifiedIdentTypeRepr>(repr)) {
32423247
auto result = directReferencesForTypeRepr(
32433248
evaluator, ctx, qualIdentTR->getBase(), dc, options);

test/NameLookup/module_selector.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,11 @@ func dependentTypeLookup<T, U, V, W, X>(_: T, _: U, _: V, _: W, _: X) where
440440
X: Identifiable, X: ComparableIdentifiable, X.NonexistentModule::ID == Int
441441
// expected-error@-1 {{module selector is not allowed on generic member type; associated types with the same name are merged instead of shadowing one another}} {{49-68=}}
442442
{}
443+
444+
// rdar://164647850 -- conforming to `Swift::Error` doesn't work when there's an `Error` type around
445+
446+
enum Error {}
447+
enum E: Swift::Error { case err }
448+
449+
func testErrorConformance() -> Result<Void, E> { .success(()) }
450+
// no-error@-1

validation-test/compiler_crashers/RequirementMachine-areReducedTypeParametersEqual-1801de.swift renamed to validation-test/compiler_crashers_fixed/RequirementMachine-areReducedTypeParametersEqual-1801de.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// {"kind":"typecheck","signature":"swift::rewriting::RequirementMachine::areReducedTypeParametersEqual(swift::Type, swift::Type) const"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
protocol a {
44
typealias Index extension Collection where Self : a{b : Index} protocol a

0 commit comments

Comments
 (0)