Skip to content

Commit fc03264

Browse files
committed
---
yaml --- r: 348869 b: refs/heads/master c: fac36f9 h: refs/heads/master i: 348867: 333aaf5
1 parent 8ab848b commit fc03264

File tree

7 files changed

+17
-25
lines changed

7 files changed

+17
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5669b9ec6a3f719dcf2b5058c086181b8e21473b
2+
refs/heads/master: fac36f95b0469766c0c0ce05b7d6543d8dc31c35
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/AST/Decl.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,13 +2744,7 @@ void ValueDecl::setInterfaceType(Type type) {
27442744
if (type) {
27452745
assert(!type->hasTypeVariable() && "Type variable in interface type");
27462746
assert(!type->is<InOutType>() && "Interface type must be materializable");
2747-
2748-
// ParamDecls in closure contexts can have type variables
2749-
// archetype in them during constraint generation.
2750-
if (!(isa<ParamDecl>(this) && isa<AbstractClosureExpr>(getDeclContext()))) {
2751-
assert(!type->hasArchetype() &&
2752-
"Archetype in interface type");
2753-
}
2747+
assert(!type->hasArchetype() && "Archetype in interface type");
27542748

27552749
if (type->hasError())
27562750
setInvalid();

trunk/lib/Sema/CSGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,9 @@ namespace {
20282028

20292029
// If a type was explicitly specified, use its opened type.
20302030
if (auto type = param->getTypeLoc().getType()) {
2031+
paramType = closureExpr->mapTypeIntoContext(type);
20312032
// FIXME: Need a better locator for a pattern as a base.
2032-
paramType = CS.openUnboundGenericType(type, locator);
2033+
paramType = CS.openUnboundGenericType(paramType, locator);
20332034
internalType = paramType;
20342035
} else {
20352036
// Otherwise, create fresh type variables.

trunk/lib/Sema/TypeCheckConstraints.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,7 @@ bool PreCheckExpression::walkToClosureExprPre(ClosureExpr *closure) {
13501350
options |= TypeResolutionFlags::AllowUnboundGenerics;
13511351
bool hadParameterError = false;
13521352

1353-
auto resolution = TypeResolution::forContextual(closure);
1354-
if (TC.typeCheckParameterList(PL, resolution, options)) {
1353+
if (TC.typeCheckParameterList(PL, closure, options)) {
13551354
// If we encounter an error validating the parameter list, don't bail.
13561355
// Instead, go on to validate any potential result type, and bail
13571356
// afterwards. This allows for better diagnostics, and keeps the
@@ -1361,8 +1360,9 @@ bool PreCheckExpression::walkToClosureExprPre(ClosureExpr *closure) {
13611360

13621361
// Validate the result type, if present.
13631362
if (closure->hasExplicitResultType() &&
1364-
TypeChecker::validateType(TC.Context, closure->getExplicitResultTypeLoc(),
1365-
resolution,
1363+
TypeChecker::validateType(TC.Context,
1364+
closure->getExplicitResultTypeLoc(),
1365+
TypeResolution::forContextual(closure),
13661366
TypeResolverContext::InExpression)) {
13671367
return false;
13681368
}

trunk/lib/Sema/TypeCheckDecl.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4045,8 +4045,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
40454045

40464046
// We want the function to be available for name lookup as soon
40474047
// as it has a valid interface type.
4048-
auto resolution = TypeResolution::forInterface(FD);
4049-
typeCheckParameterList(FD->getParameters(), resolution,
4048+
typeCheckParameterList(FD->getParameters(), FD,
40504049
TypeResolverContext::AbstractFunctionDecl);
40514050
validateResultType(FD, FD->getBodyResultTypeLoc());
40524051
// FIXME: Roll all of this interface type computation into a request.
@@ -4072,8 +4071,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
40724071

40734072
DeclValidationRAII IBV(CD);
40744073

4075-
auto res = TypeResolution::forInterface(CD);
4076-
typeCheckParameterList(CD->getParameters(), res,
4074+
typeCheckParameterList(CD->getParameters(), CD,
40774075
TypeResolverContext::AbstractFunctionDecl);
40784076
CD->computeType();
40794077
break;
@@ -4084,8 +4082,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
40844082

40854083
DeclValidationRAII IBV(DD);
40864084

4087-
auto res = TypeResolution::forInterface(DD);
4088-
typeCheckParameterList(DD->getParameters(), res,
4085+
typeCheckParameterList(DD->getParameters(), DD,
40894086
TypeResolverContext::AbstractFunctionDecl);
40904087
DD->computeType();
40914088
break;
@@ -4096,8 +4093,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
40964093

40974094
DeclValidationRAII IBV(SD);
40984095

4099-
auto res = TypeResolution::forInterface(SD);
4100-
typeCheckParameterList(SD->getIndices(), res,
4096+
typeCheckParameterList(SD->getIndices(), SD,
41014097
TypeResolverContext::SubscriptDecl);
41024098
validateResultType(SD, SD->getElementTypeLoc());
41034099
SD->computeType();
@@ -4112,8 +4108,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
41124108
DeclValidationRAII IBV(EED);
41134109

41144110
if (auto *PL = EED->getParameterList()) {
4115-
auto res = TypeResolution::forInterface(ED);
4116-
typeCheckParameterList(PL, res,
4111+
typeCheckParameterList(PL, ED,
41174112
TypeResolverContext::EnumElementDecl);
41184113
}
41194114

trunk/lib/Sema/TypeCheckPattern.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,10 @@ static bool validateParameterType(ParamDecl *decl, TypeResolution resolution,
794794

795795
/// Type check a parameter list.
796796
bool TypeChecker::typeCheckParameterList(ParameterList *PL,
797-
TypeResolution resolution,
797+
DeclContext *dc,
798798
TypeResolutionOptions options) {
799+
auto resolution = TypeResolution::forInterface(dc);
800+
799801
bool hadError = false;
800802

801803
for (auto param : *PL) {

trunk/lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ class TypeChecker final : public LazyResolver {
13541354
bool typeCheckCatchPattern(CatchStmt *S, DeclContext *dc);
13551355

13561356
/// Type check a parameter list.
1357-
bool typeCheckParameterList(ParameterList *PL, TypeResolution resolution,
1357+
bool typeCheckParameterList(ParameterList *PL, DeclContext *dc,
13581358
TypeResolutionOptions options);
13591359

13601360
/// Coerce a pattern to the given type.

0 commit comments

Comments
 (0)