Skip to content

Commit 9d76ce9

Browse files
committed
[Import as Member] Fix oversight where we skip getter validation.
In the code that makes sure to pair up getters/setters only from the same top level module, we were accidentally skipping the final validity checks (e.g. do the number of parameters line up). This fixes that.
1 parent 266fa15 commit 9d76ce9

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

lib/ClangImporter/IAMInference.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,11 @@ bool IAMInference::validToImportAsProperty(
664664
// as a getter with no setter, or we cannot be a property
665665
if (isGet) {
666666
pairedAccessor = nullptr;
667-
return true;
667+
setterDecl = nullptr;
668+
} else {
669+
// This is set-only as far as we're concerned
670+
return false;
668671
}
669-
670-
// This is set-only as far as we're concerned
671-
return false;
672672
}
673673

674674
if (!selfIndex)

test/IDE/Inputs/custom-modules/CollisionImportAsMember.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
#include "InferImportAsMember.h"
44

55
extern double IAMStruct1GetNonPropertyExternalCollision(struct IAMStruct1 s);
6+
7+
extern void IAMStruct1SetCollisionNonProperty(struct IAMStruct1, int, float);
8+

test/IDE/Inputs/custom-modules/InferImportAsMember.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,7 @@ extern unsigned IAMClassGetTypeID(void);
110110
extern IAMClassRef IAMClassCreate(double i);
111111
extern void IAMClassInvert(IAMOtherName iamOtherName);
112112

113+
// Test collision where we can see the getter, but not setter
114+
extern float IAMStruct1GetCollisionNonProperty(struct IAMStruct1, int);
113115

114116
#endif // INFER_IMPORT_AS_MEMBER_H

test/IDE/infer_import_as_member.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import InferImportAsMember
88
let mine = IAMStruct1()
9+
let _ = mine.getCollisionNonProperty(1)
910

1011
// TODO: more cases, eventually exhaustive, as we start inferring the result we
1112
// want
@@ -75,6 +76,9 @@ let mine = IAMStruct1()
7576
// PRINT-NEXT: init(fuzzy fuzzy: ())
7677
// PRINT-NEXT: init(fuzzyWithFuzzyName fuzzyWithFuzzyName: ())
7778
// PRINT-NEXT: init(fuzzyName fuzzyName: ())
79+
//
80+
// PRINT-NEXT: func getCollisionNonProperty(_ _: Int32) -> Float
81+
//
7882
// PRINT-NEXT: }
7983
//
8084
// PRINT-NEXT: func __IAMStruct1IgnoreMe(_ s: IAMStruct1) -> Double

0 commit comments

Comments
 (0)