Skip to content

Commit f31d7cd

Browse files
authored
Merge pull request #65704 from hamishknight/revert-placeholder
Revert "[AST] Allocate PlaceholderTypes in the correct arena"
2 parents 9a496e8 + 6ae5f1c commit f31d7cd

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ struct ASTContext::Implementation {
430430
llvm::DenseMap<Type, InOutType*> InOutTypes;
431431
llvm::DenseMap<std::pair<Type, void*>, DependentMemberType *>
432432
DependentMemberTypes;
433-
llvm::DenseMap<void *, PlaceholderType *> PlaceholderTypes;
434433
llvm::DenseMap<Type, DynamicSelfType *> DynamicSelfTypes;
435434
llvm::DenseMap<std::pair<EnumDecl*, Type>, EnumType*> EnumTypes;
436435
llvm::DenseMap<std::pair<StructDecl*, Type>, StructType*> StructTypes;
@@ -3125,27 +3124,8 @@ Type ErrorType::get(Type originalType) {
31253124

31263125
Type PlaceholderType::get(ASTContext &ctx, Originator originator) {
31273126
assert(originator);
3128-
3129-
auto hasTypeVariables = [&]() -> bool {
3130-
if (originator.is<TypeVariableType *>())
3131-
return true;
3132-
3133-
if (auto *depTy = originator.dyn_cast<DependentMemberType *>())
3134-
return depTy->hasTypeVariable();
3135-
3136-
return false;
3137-
}();
3138-
auto arena = hasTypeVariables ? AllocationArena::ConstraintSolver
3139-
: AllocationArena::Permanent;
3140-
3141-
auto &cache = ctx.getImpl().getArena(arena).PlaceholderTypes;
3142-
auto &entry = cache[originator.getOpaqueValue()];
3143-
if (entry)
3144-
return entry;
3145-
3146-
entry = new (ctx, arena)
3127+
return new (ctx, AllocationArena::Permanent)
31473128
PlaceholderType(ctx, originator, RecursiveTypeProperties::HasPlaceholder);
3148-
return entry;
31493129
}
31503130

31513131
BuiltinIntegerType *BuiltinIntegerType::get(BuiltinIntegerWidth BitWidth,

test/Constraints/rdar44770297.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ func foo<T: P>(_: () throws -> T) -> T.A? { // expected-note {{where 'T' = 'Neve
88
fatalError()
99
}
1010

11-
let _ = foo() {fatalError()} & nil
12-
// expected-error@-1 {{global function 'foo' requires that 'Never' conform to 'P'}}
13-
// expected-error@-2 {{value of optional type 'Never.A?' must be unwrapped to a value of type 'Never.A'}}
14-
// expected-note@-3 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
15-
// expected-note@-4 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
11+
let _ = foo() {fatalError()} & nil // expected-error {{global function 'foo' requires that 'Never' conform to 'P'}}

validation-test/Sema/type_checker_crashers_fixed/issue-65360.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ let _: () -> Void = {
1313
// expected-error@-1 {{cannot convert value of type 'Any?' to specified type '(_, _)}}
1414
}
1515

16-
let _: () -> Void = {
16+
let _: () -> Void = { // expected-error {{unable to infer closure type in the current context}}
1717
for case (0)? in [a] {}
1818
for case (0, 0) in [a] {}
19-
// expected-error@-1 {{cannot convert value of type 'Any?' to expected element type '(_, _)'}}
2019
}

0 commit comments

Comments
 (0)