Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ struct ASTContext::Implementation {
llvm::DenseMap<Type, InOutType*> InOutTypes;
llvm::DenseMap<std::pair<Type, void*>, DependentMemberType *>
DependentMemberTypes;
llvm::DenseMap<void *, PlaceholderType *> PlaceholderTypes;
llvm::DenseMap<Type, DynamicSelfType *> DynamicSelfTypes;
llvm::DenseMap<std::pair<EnumDecl*, Type>, EnumType*> EnumTypes;
llvm::DenseMap<std::pair<StructDecl*, Type>, StructType*> StructTypes;
Expand Down Expand Up @@ -3125,27 +3124,8 @@ Type ErrorType::get(Type originalType) {

Type PlaceholderType::get(ASTContext &ctx, Originator originator) {
assert(originator);

auto hasTypeVariables = [&]() -> bool {
if (originator.is<TypeVariableType *>())
return true;

if (auto *depTy = originator.dyn_cast<DependentMemberType *>())
return depTy->hasTypeVariable();

return false;
}();
auto arena = hasTypeVariables ? AllocationArena::ConstraintSolver
: AllocationArena::Permanent;

auto &cache = ctx.getImpl().getArena(arena).PlaceholderTypes;
auto &entry = cache[originator.getOpaqueValue()];
if (entry)
return entry;

entry = new (ctx, arena)
return new (ctx, AllocationArena::Permanent)
PlaceholderType(ctx, originator, RecursiveTypeProperties::HasPlaceholder);
return entry;
}

BuiltinIntegerType *BuiltinIntegerType::get(BuiltinIntegerWidth BitWidth,
Expand Down
6 changes: 1 addition & 5 deletions test/Constraints/rdar44770297.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ func foo<T: P>(_: () throws -> T) -> T.A? { // expected-note {{where 'T' = 'Neve
fatalError()
}

let _ = foo() {fatalError()} & nil
// expected-error@-1 {{global function 'foo' requires that 'Never' conform to 'P'}}
// expected-error@-2 {{value of optional type 'Never.A?' must be unwrapped to a value of type 'Never.A'}}
// expected-note@-3 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
// expected-note@-4 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
let _ = foo() {fatalError()} & nil // expected-error {{global function 'foo' requires that 'Never' conform to 'P'}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ let _: () -> Void = {
// expected-error@-1 {{cannot convert value of type 'Any?' to specified type '(_, _)}}
}

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