Skip to content

Commit cd96282

Browse files
authored
Merge pull request #31398 from hborla/invalid-decl-ref-expr
[CSApply] Fix a case where CSApply produced an invalid DeclRefExpr
2 parents c8e9ffa + a181f21 commit cd96282

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
@@ -1030,6 +1030,18 @@ namespace {
10301030
// Build a member reference.
10311031
auto memberRef = resolveConcreteDeclRef(member, memberLocator);
10321032

1033+
// If we're referring to a member type, it's just a type
1034+
// reference.
1035+
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1036+
Type refType = simplifyType(openedType);
1037+
auto ref = TypeExpr::createForDecl(memberLoc, TD, cs.DC);
1038+
cs.setType(ref, refType);
1039+
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
1040+
base, dotLoc, ref, refType);
1041+
cs.setType(result, refType);
1042+
return result;
1043+
}
1044+
10331045
// If we're referring to the member of a module, it's just a simple
10341046
// reference.
10351047
if (baseTy->is<ModuleType>()) {
@@ -1043,18 +1055,6 @@ namespace {
10431055
return forceUnwrapIfExpected(DSBI, choice, memberLocator);
10441056
}
10451057

1046-
// If we're referring to a member type, it's just a type
1047-
// reference.
1048-
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1049-
Type refType = simplifyType(openedType);
1050-
auto ref = TypeExpr::createForDecl(memberLoc, TD, cs.DC);
1051-
cs.setType(ref, refType);
1052-
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
1053-
base, dotLoc, ref, refType);
1054-
cs.setType(result, refType);
1055-
return result;
1056-
}
1057-
10581058
bool isUnboundInstanceMember =
10591059
(!baseIsInstance && member->isInstanceMember());
10601060
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)