Skip to content

Commit 54b75be

Browse files
authored
Merge pull request swiftlang#31409 from hborla/5.3-invalid-decl-ref-expr
[5.3][CSApply] Fix a case where CSApply produced an invalid DeclRefExpr
2 parents d366941 + 1848eb3 commit 54b75be

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

lib/Sema/CSApply.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,18 @@ namespace {
10801080
// Build a member reference.
10811081
auto memberRef = resolveConcreteDeclRef(member, memberLocator);
10821082

1083+
// If we're referring to a member type, it's just a type
1084+
// reference.
1085+
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1086+
Type refType = simplifyType(openedType);
1087+
auto ref = TypeExpr::createForDecl(memberLoc, TD, cs.DC, /*isImplicit=*/false);
1088+
cs.setType(ref, refType);
1089+
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
1090+
base, dotLoc, ref, refType);
1091+
cs.setType(result, refType);
1092+
return result;
1093+
}
1094+
10831095
// If we're referring to the member of a module, it's just a simple
10841096
// reference.
10851097
if (baseTy->is<ModuleType>()) {
@@ -1093,18 +1105,6 @@ namespace {
10931105
return forceUnwrapIfExpected(DSBI, choice, memberLocator);
10941106
}
10951107

1096-
// If we're referring to a member type, it's just a type
1097-
// reference.
1098-
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1099-
Type refType = simplifyType(openedType);
1100-
auto ref = TypeExpr::createForDecl(memberLoc, TD, cs.DC, /*isImplicit=*/false);
1101-
cs.setType(ref, refType);
1102-
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
1103-
base, dotLoc, ref, refType);
1104-
cs.setType(result, refType);
1105-
return result;
1106-
}
1107-
11081108
bool isUnboundInstanceMember =
11091109
(!baseIsInstance && member->isInstanceMember());
11101110
bool isPartialApplication = shouldBuildCurryThunk(choice, baseIsInstance);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface Data
4+
@end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -module-name SomeModule -typecheck -verify -dump-ast -import-objc-header %S/Inputs/imported_type.h %s | %FileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
7+
// CHECK: declref_expr type='module<SomeModule>'
8+
// CHECK-NEXT: type_expr type='Data.Type'
9+
let type = SomeModule.Data.self

0 commit comments

Comments
 (0)