Skip to content

Commit 2672afb

Browse files
committed
Sema: Remove GenericTypeResolver::recordParamType()
1 parent 7fea83e commit 2672afb

File tree

4 files changed

+3
-43
lines changed

4 files changed

+3
-43
lines changed

lib/Sema/GenericTypeResolver.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ class GenericTypeResolver {
5757
/// Determine whether the given types are equivalent within the generic
5858
/// context.
5959
virtual bool areSameType(Type type1, Type type2) = 0;
60-
61-
/// Set the contextual type or the interface type of the parameter.
62-
virtual void recordParamType(ParamDecl *decl, Type ty) = 0;
6360
};
6461

6562
/// Generic type resolver that leaves all generic types dependent.
@@ -78,8 +75,6 @@ class DependentGenericTypeResolver : public GenericTypeResolver {
7875
ComponentIdentTypeRepr *ref);
7976

8077
virtual bool areSameType(Type type1, Type type2);
81-
82-
virtual void recordParamType(ParamDecl *decl, Type ty);
8378
};
8479

8580
/// Generic type resolver that maps a generic type parameter type to its
@@ -106,8 +101,6 @@ class GenericTypeToArchetypeResolver : public GenericTypeResolver {
106101
ComponentIdentTypeRepr *ref);
107102

108103
virtual bool areSameType(Type type1, Type type2);
109-
110-
virtual void recordParamType(ParamDecl *decl, Type ty);
111104
};
112105

113106
/// Generic type resolver that only handles what can appear in a protocol
@@ -126,8 +119,6 @@ class ProtocolRequirementTypeResolver : public GenericTypeResolver {
126119
ComponentIdentTypeRepr *ref);
127120

128121
virtual bool areSameType(Type type1, Type type2);
129-
130-
virtual void recordParamType(ParamDecl *decl, Type ty);
131122
};
132123

133124
/// Generic type resolver that performs complete resolution of dependent
@@ -155,8 +146,6 @@ class CompleteGenericTypeResolver : public GenericTypeResolver {
155146
ComponentIdentTypeRepr *ref);
156147

157148
virtual bool areSameType(Type type1, Type type2);
158-
159-
virtual void recordParamType(ParamDecl *decl, Type ty);
160149
};
161150

162151
} // end namespace swift

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4116,7 +4116,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
41164116
auto accessorParam = valueParams->get(valueParams->size() - e + i);
41174117
accessorParam->setType(paramTy);
41184118
accessorParam->setInterfaceType(paramIfaceTy);
4119-
accessorParam->getTypeLoc().setType(paramTy);
4119+
accessorParam->getTypeLoc().setType(paramIfaceTy);
41204120
}
41214121
}
41224122

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ bool DependentGenericTypeResolver::areSameType(Type type1, Type type2) {
5050
return true;
5151
}
5252

53-
void DependentGenericTypeResolver::recordParamType(ParamDecl *decl, Type type) {
54-
// Do nothing
55-
}
56-
5753
Type GenericTypeToArchetypeResolver::mapTypeIntoContext(Type type) {
5854
return GenericEnvironment::mapTypeIntoContext(GenericEnv, type);
5955
}
@@ -70,19 +66,6 @@ bool GenericTypeToArchetypeResolver::areSameType(Type type1, Type type2) {
7066
return type1->isEqual(type2);
7167
}
7268

73-
void GenericTypeToArchetypeResolver::recordParamType(ParamDecl *decl, Type type) {
74-
decl->setType(type);
75-
76-
// When type checking a closure or subscript index, this is the only
77-
// resolver that runs, so make sure we also set the interface type,
78-
// if one was not already set.
79-
//
80-
// When type checking functions, the CompleteGenericTypeResolver sets
81-
// the interface type.
82-
if (!decl->hasInterfaceType())
83-
decl->setInterfaceType(type->mapTypeOutOfContext());
84-
}
85-
8669
Type ProtocolRequirementTypeResolver::mapTypeIntoContext(Type type) {
8770
return type;
8871
}
@@ -110,12 +93,6 @@ bool ProtocolRequirementTypeResolver::areSameType(Type type1, Type type2) {
11093
return areSameType(depMem1->getBase(), depMem2->getBase());
11194
}
11295

113-
void ProtocolRequirementTypeResolver::recordParamType(ParamDecl *decl,
114-
Type type) {
115-
llvm_unreachable(
116-
"recording a param type of a protocol requirement doesn't make sense");
117-
}
118-
11996
CompleteGenericTypeResolver::CompleteGenericTypeResolver(
12097
TypeChecker &tc,
12198
GenericSignature *genericSig)
@@ -242,11 +219,6 @@ bool CompleteGenericTypeResolver::areSameType(Type type1, Type type2) {
242219
== genericSig->getCanonicalTypeInContext(type2);
243220
}
244221

245-
void
246-
CompleteGenericTypeResolver::recordParamType(ParamDecl *decl, Type type) {
247-
decl->setInterfaceType(type);
248-
}
249-
250222
///
251223
/// Common code for generic functions, generic types
252224
///

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,9 @@ bool TypeChecker::typeCheckParameterList(ParameterList *PL, DeclContext *DC,
856856
param->markInvalid();
857857
hadError = true;
858858
} else {
859-
if (!type->isMaterializable()) {
859+
if (type->is<InOutType>())
860860
param->setSpecifier(VarDecl::Specifier::InOut);
861-
}
862-
resolver.recordParamType(param, type->getInOutObjectType());
861+
param->setInterfaceType(type->getInOutObjectType());
863862
}
864863

865864
checkTypeModifyingDeclAttributes(param);

0 commit comments

Comments
 (0)