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
5 changes: 4 additions & 1 deletion lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3958,8 +3958,9 @@ TypeResolver::resolveASTFunctionTypeParams(TupleTypeRepr *inputRepr,
}

// Validate the presence of ownership for a noncopyable parameter.
// FIXME: This won't diagnose if the type contains unbound generics.
if (inStage(TypeResolutionStage::Interface)
&& !ty->hasUnboundGenericType()) {
&& !ty->hasUnboundGenericType() && !ty->hasTypeVariable()) {
diagnoseMissingOwnership(ownership, eltTypeRepr, ty, resolution);

// @_staticExclusiveOnly types cannot be passed as 'inout' in function
Expand Down Expand Up @@ -5709,6 +5710,7 @@ NeverNullType TypeResolver::resolveVarargType(VarargTypeRepr *repr,
}

// do not allow move-only types as the element of a vararg
// FIXME: This does not correctly handle type variables and unbound generics.
if (inStage(TypeResolutionStage::Interface)) {
auto contextTy = GenericEnvironment::mapTypeIntoContext(
resolution.getGenericSignature().getGenericEnvironment(), element);
Expand Down Expand Up @@ -5895,6 +5897,7 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr,
// Track the presence of a noncopyable field for diagnostic purposes only.
// We don't need to re-diagnose if a tuple contains another tuple, though,
// since we should've diagnosed the inner tuple already.
// FIXME: This won't diagnose if the type contains unbound generics
if (!ctx.LangOpts.hasFeature(Feature::MoveOnlyTuples) &&
!options.contains(TypeResolutionFlags::SILMode) &&
inStage(TypeResolutionStage::Interface) &&
Expand Down
5 changes: 5 additions & 0 deletions test/Sema/editor_placeholders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ func test_ambiguity_with_placeholders(pairs: [(rank: Int, count: Int)]) -> Bool

let unboundInPlaceholder1: Array<Never> = <#T##Array#> // expected-error{{editor placeholder in source file}}
let unboundInPlaceholder2: Array<Never> = foo(<#T##t: Array##Array<Never>#>) // expected-error{{editor placeholder in source file}}

// Make sure this doesn't crash:
<#T##(Result) -> Void#> // expected-error {{editor placeholder in source file}}
// expected-error@-1 {{generic parameter 'Success' could not be inferred}}
// expected-error@-2 {{generic parameter 'Failure' could not be inferred}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// {"kind":"typecheck","signature":"checkRequirementsImpl(llvm::ArrayRef<swift::Requirement>, bool)","signatureAssert":"Assertion failed: (!firstType->hasTypeVariable()), function checkRequirementsImpl"}
// RUN: not %target-swift-frontend -typecheck %s
struct a<b: ~Copyable
extension a: Copyable where b: Copyable
let c (a -> d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// {"kind":"typecheck","signature":"checkRequirementsImpl(llvm::ArrayRef<swift::Requirement>, bool)","signatureAssert":"Assertion failed: (!firstType->hasTypeVariable()), function checkRequirementsImpl"}
// RUN: not %target-swift-frontend -typecheck %s
struct a<b: ~Copyable
extension a: Copyable where b: Copyable
let c = <#T##(a -> d)#>