From bea4a095da23bfc130da1533cb812255b35a81a2 Mon Sep 17 00:00:00 2001 From: Suyash Srijan Date: Wed, 17 Jun 2020 18:12:16 +0100 Subject: [PATCH] [Refactoring] Create 'AddEquatableContext' with extension only when there is an extended nominal declaration --- lib/IDE/Refactoring.cpp | 4 +++- test/refactoring/RefactoringKind/crashers.swift | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/IDE/Refactoring.cpp b/lib/IDE/Refactoring.cpp index a64ad89315458..7bd3af342739a 100644 --- a/lib/IDE/Refactoring.cpp +++ b/lib/IDE/Refactoring.cpp @@ -3451,7 +3451,9 @@ getDeclarationContextFromInfo(ResolvedCursorInfo Info) { return AddEquatableContext(NomDecl); } } else if (auto *ExtDecl = Info.ExtTyRef) { - return AddEquatableContext(ExtDecl); + if (ExtDecl->getExtendedNominal()) { + return AddEquatableContext(ExtDecl); + } } return AddEquatableContext(); } diff --git a/test/refactoring/RefactoringKind/crashers.swift b/test/refactoring/RefactoringKind/crashers.swift index cc64000987dcd..7be39848b21ea 100644 --- a/test/refactoring/RefactoringKind/crashers.swift +++ b/test/refactoring/RefactoringKind/crashers.swift @@ -38,3 +38,11 @@ func test_42098130(e1: T, e2: E_42098130) { // RUN: %refactor -source-filename %s -pos=31:3 | %FileCheck %s -check-prefix=CHECK3 // RUN: %refactor -source-filename %s -pos=32:3 | %FileCheck %s -check-prefix=CHECK3 // CHECK3: Action begins + +// SR-13000 +enum Foo {} +typealias Bar = (Any, Any) -> Foo +extension /*invoke here:*/Bar {} + +// RUN: %refactor --actions -source-filename %s -pos=45:27 | %FileCheck %s -check-prefix=CHECK4 +// CHECK4: Action begins