Skip to content

Commit 125ad63

Browse files
committed
[Archetype builder] Remove RequirementSource::Kind::OuterScope.
"Explicit" covers everything we need now. NFC
1 parent 527482c commit 125ad63

File tree

5 files changed

+8
-29
lines changed

5 files changed

+8
-29
lines changed

include/swift/AST/ArchetypeBuilder.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ class RequirementSource {
8383
///
8484
/// These are dropped when building the GenericSignature.
8585
Inherited,
86-
87-
/// The requirement came from an outer scope.
88-
/// FIXME: eliminate this in favor of keeping requirement sources in
89-
/// GenericSignatures, at least non-canonical ones?
90-
OuterScope,
9186
};
9287

9388
RequirementSource(Kind kind, SourceLoc loc) : StoredKind(kind), Loc(loc) { }
@@ -252,13 +247,8 @@ class ArchetypeBuilder {
252247
void addRequirement(const Requirement &req, RequirementSource source);
253248

254249
/// \brief Add all of a generic signature's parameters and requirements.
255-
///
256-
/// FIXME: Requirements from the generic signature are treated as coming from
257-
/// an outer scope. Setting \c treatRequirementsAsExplicit to true disables
258-
/// this behavior.
259250
void addGenericSignature(GenericSignature *sig,
260-
GenericEnvironment *genericEnv,
261-
bool treatRequirementsAsExplicit = false);
251+
GenericEnvironment *genericEnv);
262252

263253
/// \brief Build the generic signature.
264254
GenericSignature *getGenericSignature();

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,7 @@ ArchetypeBuilder *ASTContext::getOrCreateArchetypeBuilder(
12631263

12641264
// Create a new archetype builder with the given signature.
12651265
auto builder = new ArchetypeBuilder(*mod, Diags);
1266-
builder->addGenericSignature(sig, nullptr,
1267-
/*treatRequirementsAsExplicit=*/true);
1266+
builder->addGenericSignature(sig, nullptr);
12681267

12691268
// Store this archetype builder.
12701269
Impl.ArchetypeBuilders[{sig, mod}]

lib/AST/ArchetypeBuilder.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ void RequirementSource::dump(llvm::raw_ostream &out,
6161
out << "inferred";
6262
break;
6363

64-
case OuterScope:
65-
out << "outer";
66-
break;
67-
6864
case Inherited:
6965
out << "inherited";
7066
break;
@@ -685,7 +681,6 @@ ArchetypeBuilder::PotentialArchetype::getType(ArchetypeBuilder &builder) {
685681
switch (conforms.second.getKind()) {
686682
case RequirementSource::Explicit:
687683
case RequirementSource::Inferred:
688-
case RequirementSource::OuterScope:
689684
case RequirementSource::Protocol:
690685
case RequirementSource::Redundant:
691686
Protos.push_back(conforms.first);
@@ -2010,14 +2005,10 @@ ArchetypeBuilder::mapTypeOutOfContext(ModuleDecl *M,
20102005
}
20112006

20122007
void ArchetypeBuilder::addGenericSignature(GenericSignature *sig,
2013-
GenericEnvironment *env,
2014-
bool treatRequirementsAsExplicit) {
2008+
GenericEnvironment *env) {
20152009
if (!sig) return;
20162010

2017-
RequirementSource::Kind sourceKind = treatRequirementsAsExplicit
2018-
? RequirementSource::Explicit
2019-
: RequirementSource::OuterScope;
2020-
2011+
RequirementSource::Kind sourceKind = RequirementSource::Explicit;
20212012
for (auto param : sig->getGenericParams()) {
20222013
addGenericParameter(param);
20232014

@@ -2057,7 +2048,6 @@ static void collectRequirements(ArchetypeBuilder &builder,
20572048
switch (source.getKind()) {
20582049
case RequirementSource::Explicit:
20592050
case RequirementSource::Inferred:
2060-
case RequirementSource::OuterScope:
20612051
// The requirement was explicit and required, keep it.
20622052
break;
20632053

test/Generics/requirement_inference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Fox : P1 {
5757
class Box<T : Fox> {
5858
// CHECK-LABEL: .unpack@
5959
// CHECK-NEXT: Requirements:
60-
// CHECK-NEXT: T : Fox [outer]
60+
// CHECK-NEXT: T : Fox [explicit]
6161
func unpack(_ x: X1<T>) {}
6262
}
6363

test/SILGen/generic_witness.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct Canvas<I : Ink> where I.Paint : Pen {
5050

5151
extension Canvas : Medium {}
5252

53-
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWuRx15generic_witness3Inkwx5PaintS_3PenrGVS_6Canvasx_S_6MediumS_FS4_4drawuRd__S_6Pencilwd__6StrokezWx7TextureS1__rfT5paintWxS7_S1__6pencilqd___T_ : $@convention(witness_method) <τ_0_0 where τ_0_0 : Ink, τ_0_0.Paint : Pen><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, @in_guaranteed Canvas<τ_0_0>) -> ()
54-
// CHECK: [[FN:%.*]] = function_ref @_TFV15generic_witness6Canvas4drawuRd__S_6Pencilwx5Paintzwd__6StrokerfT5paintwxS2_6pencilqd___T_ : $@convention(method) <τ_0_0 where τ_0_0 : Ink, τ_0_0.Paint : Pen><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
55-
// CHECK: apply [[FN]]<τ_0_0, τ_1_0, τ_0_0.Paint>({{.*}}) : $@convention(method) <τ_0_0 where τ_0_0 : Ink, τ_0_0.Paint : Pen><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
53+
// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWuRx15generic_witness3Inkwx5PaintS_3PenrGVS_6Canvasx_S_6MediumS_FS4_4drawuRd__S_6Pencilwd__6StrokezWx7TextureS1__rfT5paintWxS7_S1__6pencilqd___T_ : $@convention(witness_method) <τ_0_0 where τ_0_0 : Ink><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, @in_guaranteed Canvas<τ_0_0>) -> ()
54+
// CHECK: [[FN:%.*]] = function_ref @_TFV15generic_witness6Canvas4drawuRd__S_6Pencilwx5Paintzwd__6StrokerfT5paintwxS2_6pencilqd___T_ : $@convention(method) <τ_0_0 where τ_0_0 : Ink><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
55+
// CHECK: apply [[FN]]<τ_0_0, τ_1_0>({{.*}}) : $@convention(method) <τ_0_0 where τ_0_0 : Ink><τ_1_0 where τ_1_0 : Pencil, τ_0_0.Paint == τ_1_0.Stroke> (@in τ_0_0.Paint, @in τ_1_0, Canvas<τ_0_0>) -> ()
5656
// CHECK: }

0 commit comments

Comments
 (0)