Skip to content

Commit 6d1fd6d

Browse files
authored
Merge pull request #13881 from slavapestov/type-reconstruction-inout-try-again
Re-apply "TypeReconstruction: Fix reconstruction of InOutType"
2 parents 546bd6c + e7feb5a commit 6d1fd6d

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

include/swift/IDE/Utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ Decl *getDeclFromUSR(ASTContext &context, StringRef USR, std::string &error);
134134
Decl *getDeclFromMangledSymbolName(ASTContext &context, StringRef mangledName,
135135
std::string &error);
136136

137-
Type getTypeFromMangledTypename(ASTContext &Ctx, StringRef mangledName,
138-
std::string &error);
139-
140137
Type getTypeFromMangledSymbolname(ASTContext &Ctx, StringRef mangledName,
141138
std::string &error);
142139

lib/IDE/TypeReconstruction.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ static void VisitNodeInOut(
16971697
VisitNodeResult type_result;
16981698
VisitNode(ast, cur_node->getFirstChild(), type_result);
16991699
if (type_result._types.size() == 1 && type_result._types[0]) {
1700-
result._types.push_back(Type(LValueType::get(type_result._types[0])));
1700+
result._types.push_back(Type(InOutType::get(type_result._types[0])));
17011701
} else {
17021702
result._error = "couldn't resolve referent type";
17031703
}
@@ -2196,26 +2196,6 @@ Decl *ide::getDeclFromMangledSymbolName(ASTContext &context,
21962196
return nullptr;
21972197
}
21982198

2199-
Type ide::getTypeFromMangledTypename(ASTContext &Ctx,
2200-
StringRef mangledName,
2201-
std::string &error) {
2202-
Demangle::Context DemangleCtx;
2203-
auto node = DemangleCtx.demangleTypeAsNode(mangledName);
2204-
VisitNodeResult result;
2205-
2206-
if (node)
2207-
VisitNode(&Ctx, node, result);
2208-
error = result._error;
2209-
if (error.empty() && result._types.size() == 1) {
2210-
return result._types.front().getPointer();
2211-
} else {
2212-
error = stringWithFormat("type for typename '%s' was not found",
2213-
mangledName);
2214-
return Type();
2215-
}
2216-
return Type();
2217-
}
2218-
22192199
Type ide::getTypeFromMangledSymbolname(ASTContext &Ctx,
22202200
StringRef mangledName,
22212201
std::string &error) {

test/IDE/reconstruct_type_from_mangled_name.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ class Myclass2 {
6565
arr1.append(1)
6666
// FIXME: missing append()
6767
// CHECK: dref: FAILURE for 'append' usr=s:Sa6appendyyxF
68-
// CHECK: type: (@lvalue Array<Int>) -> (Int) -> ()
68+
// CHECK: type: (inout Array<Int>) -> (Int) -> ()
6969

7070
var arr2 : [Mystruct1]
7171
// CHECK: decl: var arr2: [Mystruct1]
7272
// CHECK: type: Array<Mystruct1>
7373

7474
arr2.append(Mystruct1())
75-
// CHECK: type: (@lvalue Array<Mystruct1>) -> (Mystruct1) -> ()
75+
// CHECK: type: (inout Array<Mystruct1>) -> (Mystruct1) -> ()
7676

7777
var arr3 : [Myclass1]
7878
// CHECK: decl: var arr3: [Myclass1]
7979
// CHECK: type: Array<Myclass1>
8080

8181
arr3.append(Myclass1())
82-
// CHECK: type: (@lvalue Array<Myclass1>) -> (Myclass1) -> ()
82+
// CHECK: type: (inout Array<Myclass1>) -> (Myclass1) -> ()
8383

8484
_ = Myclass2.init()
8585
// CHECK: dref: init()
@@ -116,7 +116,7 @@ func f2() {
116116
e.method()
117117
// CHECK: (MyEnum) -> (MyEnum) -> Int
118118
e.compare(e)
119-
// CHECK: (@lvalue MyEnum) -> () -> ()
119+
// CHECK: (inout MyEnum) -> () -> ()
120120
e.mutatingMethod()
121121
}
122122

0 commit comments

Comments
 (0)