Merge pull request #11242 from slavapestov/ambiguous-requirement-witness-subclass-existential-4.0
Sema: Fix requirement/witness disambiguation for subclass existentials [4.0]
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 5dd80da..9a86f70 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -1554,9 +1554,17 @@
endif()
# Add PrivateFrameworks, rdar://28466433
+ set(swiftlib_link_flags_all ${SWIFTLIB_LINK_FLAGS})
if(SWIFTLIB_IS_SDK_OVERLAY)
list(APPEND swiftlib_swift_compile_flags_all "-Fsystem" "${SWIFT_SDK_${sdk}_PATH}/System/Library/PrivateFrameworks/")
endif()
+
+ if("${sdk}" STREQUAL "IOS_SIMULATOR")
+ if("${name}" STREQUAL "swiftMediaPlayer")
+ message("DISABLING AUTOLINK FOR swiftMediaPlayer")
+ list(APPEND swiftlib_link_flags_all "-Xlinker" "-ignore_auto_link")
+ endif()
+ endif()
# Add this library variant.
_add_swift_library_single(
@@ -1577,7 +1585,7 @@
FILE_DEPENDS ${SWIFTLIB_FILE_DEPENDS} ${swiftlib_module_dependency_targets}
C_COMPILE_FLAGS ${SWIFTLIB_C_COMPILE_FLAGS}
SWIFT_COMPILE_FLAGS ${swiftlib_swift_compile_flags_all}
- LINK_FLAGS ${SWIFTLIB_LINK_FLAGS}
+ LINK_FLAGS ${swiftlib_link_flags_all}
PRIVATE_LINK_LIBRARIES ${swiftlib_private_link_libraries_targets}
INCORPORATE_OBJECT_LIBRARIES ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES}
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY ${SWIFTLIB_INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY}
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 37be2cc..125831f 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -1387,6 +1387,14 @@
ERROR(types_not_equal,none,
"%0 requires the types %1 and %2 be equivalent",
(Type, Type, Type))
+NOTE(candidate_types_equal_requirement,none,
+ "candidate requires that the types %0 and %1 be equivalent "
+ "(requirement specified as %2 == %3%4)",
+ (Type, Type, Type, Type, StringRef))
+NOTE(candidate_types_inheritance_requirement,none,
+ "candidate requires that %1 inherit from %2 "
+ "(requirement specified as %2 : %3%4)",
+ (Type, Type, Type, Type, StringRef))
NOTE(types_not_equal_requirement,none,
"requirement specified as %0 == %1%2", (Type, Type, StringRef))
ERROR(non_class_cannot_conform_to_class_protocol,none,
diff --git a/include/swift/SIL/SILFunction.h b/include/swift/SIL/SILFunction.h
index a0cb1cc..a290388 100644
--- a/include/swift/SIL/SILFunction.h
+++ b/include/swift/SIL/SILFunction.h
@@ -667,7 +667,17 @@
return isa<ThrowInst>(TI);
});
}
-
+
+ /// Loop over all blocks in this function and add all function exiting blocks
+ /// to output.
+ void findExitingBlocks(llvm::SmallVectorImpl<SILBasicBlock *> &output) const {
+ for (auto &Block : const_cast<SILFunction &>(*this)) {
+ if (Block.getTerminator()->isFunctionExiting()) {
+ output.emplace_back(&Block);
+ }
+ }
+ }
+
//===--------------------------------------------------------------------===//
// Argument Helper Methods
//===--------------------------------------------------------------------===//
diff --git a/lib/SILOptimizer/Utils/Local.cpp b/lib/SILOptimizer/Utils/Local.cpp
index d998a64..e8393c4 100644
--- a/lib/SILOptimizer/Utils/Local.cpp
+++ b/lib/SILOptimizer/Utils/Local.cpp
@@ -9,6 +9,7 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
+
#include "swift/SILOptimizer/Utils/Local.h"
#include "swift/SILOptimizer/Utils/CFG.h"
#include "swift/SILOptimizer/Analysis/Analysis.h"
@@ -891,6 +892,55 @@
}
}
+static SILValue createLifetimeExtendedAllocStack(
+ SILBuilder &Builder, SILLocation Loc, SILValue Arg,
+ ArrayRef<SILBasicBlock *> ExitingBlocks, InstModCallbacks Callbacks) {
+ AllocStackInst *ASI = nullptr;
+ {
+ // Save our insert point and create a new alloc_stack in the initial BB and
+ // dealloc_stack in all exit blocks.
+ auto *OldInsertPt = &*Builder.getInsertionPoint();
+ Builder.setInsertionPoint(Builder.getFunction().begin()->begin());
+ ASI = Builder.createAllocStack(Loc, Arg->getType());
+ Callbacks.CreatedNewInst(ASI);
+
+ for (auto *BB : ExitingBlocks) {
+ Builder.setInsertionPoint(BB->getTerminator());
+ Callbacks.CreatedNewInst(Builder.createDeallocStack(Loc, ASI));
+ }
+ Builder.setInsertionPoint(OldInsertPt);
+ }
+ assert(ASI != nullptr);
+
+ // Then perform a copy_addr [take] [init] right after the partial_apply from
+ // the original address argument to the new alloc_stack that we have
+ // created.
+ Callbacks.CreatedNewInst(
+ Builder.createCopyAddr(Loc, Arg, ASI, IsTake, IsInitialization));
+
+ // Return the new alloc_stack inst that has the appropriate live range to
+ // destroy said values.
+ return ASI;
+}
+
+static bool shouldDestroyPartialApplyCapturedArg(SILValue Arg,
+ SILParameterInfo PInfo,
+ SILModule &M) {
+ // If we have a non-trivial type and the argument is passed in @inout, we do
+ // not need to destroy it here. This is something that is implicit in the
+ // partial_apply design that will be revisited when partial_apply is
+ // redesigned.
+ if (PInfo.isIndirectMutating())
+ return false;
+
+ // If we have a trivial type, we do not need to put in any extra releases.
+ if (Arg->getType().isTrivial(M))
+ return false;
+
+ // We handle all other cases.
+ return true;
+}
+
// *HEY YOU, YES YOU, PLEASE READ*. Even though a textual partial apply is
// printed with the convention of the closed over function upon it, all
// non-inout arguments to a partial_apply are passed at +1. This includes
@@ -901,20 +951,14 @@
void swift::releasePartialApplyCapturedArg(SILBuilder &Builder, SILLocation Loc,
SILValue Arg, SILParameterInfo PInfo,
InstModCallbacks Callbacks) {
- // If we have a non-trivial type and the argument is passed in @inout, we do
- // not need to destroy it here. This is something that is implicit in the
- // partial_apply design that will be revisited when partial_apply is
- // redesigned.
- if (PInfo.isIndirectMutating())
+ if (!shouldDestroyPartialApplyCapturedArg(Arg, PInfo, Builder.getModule()))
return;
- // If we have a trivial type, we do not need to put in any extra releases.
- if (Arg->getType().isTrivial(Builder.getModule()))
- return;
-
- // Otherwise, we need to destroy the argument. If we have an address, just
- // emit a destroy_addr.
+ // Otherwise, we need to destroy the argument. If we have an address, we
+ // insert a destroy_addr and return. Any live range issues must have been
+ // dealt with by our caller.
if (Arg->getType().isAddress()) {
+ // Then emit the destroy_addr for this arg
SILInstruction *NewInst = Builder.emitDestroyAddrAndFold(Loc, Arg);
Callbacks.CreatedNewInst(NewInst);
return;
@@ -958,7 +1002,7 @@
/// For each captured argument of PAI, decrement the ref count of the captured
/// argument as appropriate at each of the post dominated release locations
/// found by Tracker.
-static void releaseCapturedArgsOfDeadPartialApply(PartialApplyInst *PAI,
+static bool releaseCapturedArgsOfDeadPartialApply(PartialApplyInst *PAI,
ReleaseTracker &Tracker,
InstModCallbacks Callbacks) {
SILBuilderWithScope Builder(PAI);
@@ -966,22 +1010,60 @@
CanSILFunctionType PAITy =
PAI->getCallee()->getType().getAs<SILFunctionType>();
- // Emit a destroy value for each captured closure argument.
ArrayRef<SILParameterInfo> Params = PAITy->getParameters();
- auto Args = PAI->getArguments();
+ llvm::SmallVector<SILValue, 8> Args;
+ for (SILValue v : PAI->getArguments()) {
+ // If any of our arguments contain open existentials, bail. We do not
+ // support this for now so that we can avoid having to re-order stack
+ // locations (a larger change).
+ if (v->getType().hasOpenedExistential())
+ return false;
+ Args.emplace_back(v);
+ }
unsigned Delta = Params.size() - Args.size();
assert(Delta <= Params.size() && "Error, more Args to partial apply than "
"params in its interface.");
+ Params = Params.drop_front(Delta);
+ llvm::SmallVector<SILBasicBlock *, 2> ExitingBlocks;
+ PAI->getFunction()->findExitingBlocks(ExitingBlocks);
+
+ // Go through our argument list and create new alloc_stacks for each
+ // non-trivial address value. This ensures that the memory location that we
+ // are cleaning up has the same live range as the partial_apply. Otherwise, we
+ // may be inserting destroy_addr of alloc_stack that have already been passed
+ // to a dealloc_stack.
+ for (unsigned i : reversed(indices(Args))) {
+ SILValue Arg = Args[i];
+ SILParameterInfo PInfo = Params[i];
+
+ // If we are not going to destroy this partial_apply, continue.
+ if (!shouldDestroyPartialApplyCapturedArg(Arg, PInfo, Builder.getModule()))
+ continue;
+
+ // If we have an object, we will not have live range issues, just continue.
+ if (Arg->getType().isObject())
+ continue;
+
+ // Now that we know that we have a non-argument address, perform a take-init
+ // of Arg into a lifetime extended alloc_stack
+ Args[i] = createLifetimeExtendedAllocStack(Builder, Loc, Arg, ExitingBlocks,
+ Callbacks);
+ }
+
+ // Emit a destroy for each captured closure argument at each final release
+ // point.
for (auto *FinalRelease : Tracker.getFinalReleases()) {
Builder.setInsertionPoint(FinalRelease);
- for (unsigned AI = 0, AE = Args.size(); AI != AE; ++AI) {
- SILValue Arg = Args[AI];
- SILParameterInfo Param = Params[AI + Delta];
+ for (unsigned i : indices(Args)) {
+ SILValue Arg = Args[i];
+ SILParameterInfo Param = Params[i];
releasePartialApplyCapturedArg(Builder, Loc, Arg, Param, Callbacks);
}
}
+
+ return true;
}
/// TODO: Generalize this to general objects.
@@ -1006,8 +1088,12 @@
// If we have a partial_apply, release each captured argument at each one of
// the final release locations of the partial apply.
- if (auto *PAI = dyn_cast<PartialApplyInst>(Closure))
- releaseCapturedArgsOfDeadPartialApply(PAI, Tracker, Callbacks);
+ if (auto *PAI = dyn_cast<PartialApplyInst>(Closure)) {
+ // If we can not decrement the ref counts of the dead partial apply for any
+ // reason, bail.
+ if (!releaseCapturedArgsOfDeadPartialApply(PAI, Tracker, Callbacks))
+ return false;
+ }
// Then delete all user instructions.
for (auto *User : Tracker.getTrackedUsers()) {
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index da48c91..27c281b 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -2152,8 +2152,8 @@
/// Produce diagnostic for failures related to unfulfilled requirements
/// of the generic parameters used as arguments.
- bool diagnoseArgumentGenericRequirements(TypeChecker &TC, Expr *fnExpr,
- Expr *argExpr,
+ bool diagnoseArgumentGenericRequirements(TypeChecker &TC, Expr *callExpr,
+ Expr *fnExpr, Expr *argExpr,
CalleeCandidateInfo &candidates,
ArrayRef<Identifier> argLabels);
@@ -5886,16 +5886,18 @@
}
bool FailureDiagnosis::diagnoseArgumentGenericRequirements(
- TypeChecker &TC, Expr *fnExpr, Expr *argExpr,
+ TypeChecker &TC, Expr *callExpr, Expr *fnExpr, Expr *argExpr,
CalleeCandidateInfo &candidates, ArrayRef<Identifier> argLabels) {
if (candidates.closeness != CC_ExactMatch || candidates.size() != 1)
return false;
- auto DRE = dyn_cast<DeclRefExpr>(fnExpr);
- if (!DRE)
- return false;
+ AbstractFunctionDecl *AFD = nullptr;
+ if (auto *DRE = dyn_cast<DeclRefExpr>(fnExpr)) {
+ AFD = dyn_cast<AbstractFunctionDecl>(DRE->getDecl());
+ } else if (auto *candidate = candidates[0].getDecl()) {
+ AFD = dyn_cast<AbstractFunctionDecl>(candidate);
+ }
- auto AFD = dyn_cast<AbstractFunctionDecl>(DRE->getDecl());
if (!AFD || !AFD->isGeneric() || !AFD->hasInterfaceType())
return false;
@@ -5920,7 +5922,9 @@
// requirements e.g. <A, B where A.Element == B.Element>.
for (unsigned i = 0, e = bindings.size(); i != e; ++i) {
auto param = params[i];
- auto archetype = param.Ty->getAs<ArchetypeType>();
+ auto paramType = param.Ty->getInOutObjectType();
+
+ auto archetype = paramType->getAs<ArchetypeType>();
if (!archetype)
continue;
@@ -5948,18 +5952,88 @@
return false;
class RequirementsListener : public GenericRequirementsCheckListener {
+ TypeChecker &TC;
+ AbstractFunctionDecl *Candidate;
+ TypeSubstitutionFn Substitutions;
+
+ Expr *CallExpr;
+ Expr *FnExpr;
+ Expr *ArgExpr;
+
public:
+ RequirementsListener(TypeChecker &TC, AbstractFunctionDecl *AFD,
+ TypeSubstitutionFn subs,
+ Expr *callExpr, Expr *fnExpr, Expr *argExpr)
+ : TC(TC), Candidate(AFD), Substitutions(subs), CallExpr(callExpr),
+ FnExpr(fnExpr), ArgExpr(argExpr) {}
+
bool shouldCheck(RequirementKind kind, Type first, Type second) override {
// This means that we have encountered requirement which references
// generic parameter not used in the arguments, we can't diagnose it here.
return !(first->hasTypeParameter() || first->isTypeVariableOrMember());
}
+
+ bool diagnoseUnsatisfiedRequirement(const Requirement &req, Type first,
+ Type second) override {
+ Diag<Type, Type, Type, Type, StringRef> note;
+ switch (req.getKind()) {
+ case RequirementKind::Conformance:
+ case RequirementKind::Layout:
+ return false;
+
+ case RequirementKind::Superclass:
+ note = diag::candidate_types_inheritance_requirement;
+ break;
+
+ case RequirementKind::SameType:
+ note = diag::candidate_types_equal_requirement;
+ break;
+ }
+
+ SmallVector<char, 8> scratch;
+ auto overloadName = Candidate->getFullName().getString(scratch);
+
+ if (isa<BinaryExpr>(CallExpr) && isa<TupleExpr>(ArgExpr)) {
+ auto argTuple = cast<TupleExpr>(ArgExpr);
+ auto lhsExpr = argTuple->getElement(0),
+ rhsExpr = argTuple->getElement(1);
+ auto lhsType = lhsExpr->getType()->getRValueType();
+ auto rhsType = rhsExpr->getType()->getRValueType();
+
+ TC.diagnose(FnExpr->getLoc(), diag::cannot_apply_binop_to_args,
+ overloadName, lhsType, rhsType)
+ .highlight(lhsExpr->getSourceRange())
+ .highlight(rhsExpr->getSourceRange());
+ } else if (isa<PrefixUnaryExpr>(CallExpr) ||
+ isa<PostfixUnaryExpr>(CallExpr)) {
+ TC.diagnose(ArgExpr->getLoc(), diag::cannot_apply_unop_to_arg,
+ overloadName, ArgExpr->getType());
+ } else {
+ bool isInitializer = isa<ConstructorDecl>(Candidate);
+ TC.diagnose(ArgExpr->getLoc(), diag::cannot_call_with_params,
+ overloadName, getTypeListString(ArgExpr->getType()),
+ isInitializer);
+ }
+
+ auto rawFirstType = req.getFirstType();
+ auto rawSecondType = req.getSecondType();
+ auto *genericSig = Candidate->getGenericSignature();
+
+ TC.diagnose(Candidate, note, first, second,
+ rawFirstType, rawSecondType,
+ genericSig->gatherGenericParamBindingsText(
+ {rawFirstType, rawSecondType}, Substitutions));
+ return true;
+ }
};
- auto dc = env->getOwningDeclContext();
- RequirementsListener genericReqListener;
+ auto *dc = env->getOwningDeclContext();
+ auto substitutionFn = QueryTypeSubstitutionMap{substitutions};
+ RequirementsListener genericReqListener(TC, AFD, substitutionFn,
+ callExpr, fnExpr, argExpr);
+
auto result = TC.checkGenericArguments(
- dc, argExpr->getLoc(), AFD->getLoc(), AFD->getInterfaceType(),
+ dc, callExpr->getLoc(), fnExpr->getLoc(), AFD->getInterfaceType(),
env->getGenericSignature(), QueryTypeSubstitutionMap{substitutions},
LookUpConformanceInModule{dc->getParentModule()}, nullptr,
ConformanceCheckFlags::SuppressDependencyTracking, &genericReqListener);
@@ -6662,6 +6736,10 @@
}
}
+ if (diagnoseArgumentGenericRequirements(CS->TC, callExpr, fnExpr, argExpr,
+ calleeInfo, argLabels))
+ return true;
+
if (isContextualConversionFailure(argTuple))
return false;
@@ -6695,13 +6773,13 @@
return true;
}
- // If all of the arguments are a perfect match, so let's check if there
+ // If all of the arguments are a perfect match, let's check if there
// are problems with requirements placed on generic parameters, because
// CalleeCandidateInfo validates only conformance of the parameters
// to their protocol types (if any) but it doesn't check additional
// requirements placed on e.g. nested types or between parameters.
- if (diagnoseArgumentGenericRequirements(CS->TC, fnExpr, argExpr, calleeInfo,
- argLabels))
+ if (diagnoseArgumentGenericRequirements(CS->TC, callExpr, fnExpr, argExpr,
+ calleeInfo, argLabels))
return true;
if (isContextualConversionFailure(argExpr))
diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp
index a938af4..6b474b3 100644
--- a/lib/Sema/TypeCheckConstraints.cpp
+++ b/lib/Sema/TypeCheckConstraints.cpp
@@ -1639,6 +1639,11 @@
ProtocolConformanceRef conformance) {
}
+bool GenericRequirementsCheckListener::diagnoseUnsatisfiedRequirement(
+ const Requirement &req, Type first, Type second) {
+ return false;
+}
+
bool TypeChecker::
solveForExpression(Expr *&expr, DeclContext *dc, Type convertType,
FreeTypeVariableBinding allowFreeTypeVariables,
diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp
index 403f3e9..63907ae 100644
--- a/lib/Sema/TypeCheckGeneric.cpp
+++ b/lib/Sema/TypeCheckGeneric.cpp
@@ -1300,9 +1300,13 @@
secondType = req->getSecondType();
}
+ bool requirementFailure = false;
if (listener && !listener->shouldCheck(kind, firstType, secondType))
continue;
+ Diag<Type, Type, Type> diagnostic;
+ Diag<Type, Type, StringRef> diagnosticNote;
+
switch (kind) {
case RequirementKind::Conformance: {
// Protocol conformance requirements.
@@ -1311,6 +1315,8 @@
// or non-private dependency.
// FIXME: Do we really need "used" at this point?
// FIXME: Poor location information. How much better can we do here?
+ // FIXME: This call should support listener to be able to properly
+ // diagnose problems with conformances.
auto result =
conformsToProtocol(firstType, proto->getDecl(), dc,
conformanceOptions, loc, unsatisfiedDependency);
@@ -1343,37 +1349,37 @@
case RequirementKind::Superclass:
// Superclass requirements.
if (!isSubclassOf(firstType, secondType, dc)) {
- if (loc.isValid()) {
- // FIXME: Poor source-location information.
- diagnose(loc, diag::type_does_not_inherit, owner, firstType,
- secondType);
-
- diagnose(noteLoc, diag::type_does_not_inherit_requirement,
- rawFirstType, rawSecondType,
- genericSig->gatherGenericParamBindingsText(
- {rawFirstType, rawSecondType}, substitutions));
- }
-
- return RequirementCheckResult::Failure;
+ diagnostic = diag::type_does_not_inherit;
+ diagnosticNote = diag::type_does_not_inherit_requirement;
+ requirementFailure = true;
}
- continue;
+ break;
case RequirementKind::SameType:
if (!firstType->isEqual(secondType)) {
- if (loc.isValid()) {
- // FIXME: Better location info for both diagnostics.
- diagnose(loc, diag::types_not_equal, owner, firstType, secondType);
-
- diagnose(noteLoc, diag::types_not_equal_requirement, rawFirstType,
- rawSecondType,
- genericSig->gatherGenericParamBindingsText(
- {rawFirstType, rawSecondType}, substitutions));
- }
-
- return RequirementCheckResult::Failure;
+ diagnostic = diag::types_not_equal;
+ diagnosticNote = diag::types_not_equal_requirement;
+ requirementFailure = true;
}
- continue;
+ break;
}
+
+ if (!requirementFailure)
+ continue;
+
+ if (listener &&
+ listener->diagnoseUnsatisfiedRequirement(rawReq, firstType, secondType))
+ return RequirementCheckResult::Failure;
+
+ if (loc.isValid()) {
+ // FIXME: Poor source-location information.
+ diagnose(loc, diagnostic, owner, firstType, secondType);
+ diagnose(noteLoc, diagnosticNote, rawFirstType, rawSecondType,
+ genericSig->gatherGenericParamBindingsText(
+ {rawFirstType, rawSecondType}, substitutions));
+ }
+
+ return RequirementCheckResult::Failure;
}
if (valid)
diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h
index 7b9b55c..fbe9c3d 100644
--- a/lib/Sema/TypeChecker.h
+++ b/lib/Sema/TypeChecker.h
@@ -372,6 +372,20 @@
/// \param conformance The conformance itself.
virtual void satisfiedConformance(Type depTy, Type replacementTy,
ProtocolConformanceRef conformance);
+
+ /// Callback to diagnose problem with unsatisfied generic requirement.
+ ///
+ /// \param req The unsatisfied generic requirement.
+ ///
+ /// \param first The left-hand side type assigned to the requirement,
+ /// possibly represented by its generic substitute.
+ ///
+ /// \param second The right-hand side type assigned to the requirement,
+ /// possibly represented by its generic substitute.
+ ///
+ /// \returns true if problem has been diagnosed, false otherwise.
+ virtual bool diagnoseUnsatisfiedRequirement(const Requirement &req,
+ Type first, Type second);
};
/// The result of `checkGenericRequirement`.
diff --git a/stdlib/public/SDK/ARKit/ARKit.swift b/stdlib/public/SDK/ARKit/ARKit.swift
index c0189f8..83b4b25 100644
--- a/stdlib/public/SDK/ARKit/ARKit.swift
+++ b/stdlib/public/SDK/ARKit/ARKit.swift
@@ -19,6 +19,9 @@
*/
public enum TrackingState {
public enum Reason {
+ /** Tracking is limited due to initialization in progress. */
+ case initializing
+
/** Tracking is limited due to a excessive motion of the camera. */
case excessiveMotion
@@ -47,6 +50,7 @@
let reason: TrackingState.Reason
switch __trackingStateReason {
+ case .initializing: reason = .initializing
case .excessiveMotion: reason = .excessiveMotion
default: reason = .insufficientFeatures
}
diff --git a/stdlib/public/SDK/AVFoundation/AVCaptureDevice.swift b/stdlib/public/SDK/AVFoundation/AVCaptureDevice.swift
new file mode 100644
index 0000000..c531176
--- /dev/null
+++ b/stdlib/public/SDK/AVFoundation/AVCaptureDevice.swift
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import AVFoundation // Clang module
+import Foundation
+
+
+#if os(iOS)
+
+internal protocol _AVCaptureDeviceFormatSupportedColorSpaces {
+ @available(iOS, introduced: 10.0)
+ var __supportedColorSpaces: [NSNumber] { get }
+}
+
+extension _AVCaptureDeviceFormatSupportedColorSpaces {
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var supportedColorSpaces: [NSNumber]! {
+ return __supportedColorSpaces
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var supportedColorSpaces: [AVCaptureColorSpace] {
+ return __supportedColorSpaces.map { AVCaptureColorSpace(rawValue: $0.intValue)! }
+ }
+}
+
+@available(iOS, introduced: 10.0)
+extension AVCaptureDevice.Format : _AVCaptureDeviceFormatSupportedColorSpaces {
+}
+
+#endif
+
diff --git a/stdlib/public/SDK/AVFoundation/AVCapturePhotoOutput.swift b/stdlib/public/SDK/AVFoundation/AVCapturePhotoOutput.swift
new file mode 100644
index 0000000..705d949
--- /dev/null
+++ b/stdlib/public/SDK/AVFoundation/AVCapturePhotoOutput.swift
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import AVFoundation // Clang module
+import Foundation
+
+
+#if os(iOS)
+
+internal protocol _AVCapturePhotoOutputSwiftNativeTypes {
+ var __supportedFlashModes: [NSNumber] { get }
+ var __availablePhotoPixelFormatTypes: [NSNumber] { get }
+ var __availableRawPhotoPixelFormatTypes: [NSNumber] { get }
+}
+
+extension _AVCapturePhotoOutputSwiftNativeTypes {
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var supportedFlashModes: [NSNumber] {
+ return __supportedFlashModes
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var supportedFlashModes: [AVCaptureDevice.FlashMode] {
+ return __supportedFlashModes.map { AVCaptureDevice.FlashMode(rawValue: $0.intValue)! }
+ }
+
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availablePhotoPixelFormatTypes: [NSNumber] {
+ return __availablePhotoPixelFormatTypes
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availablePhotoPixelFormatTypes: [OSType] {
+ return __availablePhotoPixelFormatTypes.map { $0.uint32Value } as [OSType]
+ }
+
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availableRawPhotoPixelFormatTypes: [NSNumber] {
+ return __availableRawPhotoPixelFormatTypes
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availableRawPhotoPixelFormatTypes: [OSType] {
+ return __availableRawPhotoPixelFormatTypes.map { $0.uint32Value } as [OSType]
+ }
+}
+
+@available(iOS, introduced: 10.0)
+extension AVCapturePhotoOutput : _AVCapturePhotoOutputSwiftNativeTypes {
+}
+
+
+internal protocol _AVCapturePhotoSettingsSwiftNativeTypes {
+ var __availablePreviewPhotoPixelFormatTypes: [NSNumber] { get }
+}
+
+extension _AVCapturePhotoSettingsSwiftNativeTypes {
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availablePreviewPhotoPixelFormatTypes: [NSNumber] {
+ return __availablePreviewPhotoPixelFormatTypes
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 10.0)
+ @nonobjc
+ public var availablePreviewPhotoPixelFormatTypes: [OSType] {
+ return __availablePreviewPhotoPixelFormatTypes.map { $0.uint32Value } as [OSType]
+ }
+}
+
+@available(iOS, introduced: 10.0)
+extension AVCapturePhotoSettings : _AVCapturePhotoSettingsSwiftNativeTypes {
+}
+
+#endif
diff --git a/stdlib/public/SDK/AVFoundation/AVCaptureSynchronizedDataCollection.swift b/stdlib/public/SDK/AVFoundation/AVCaptureSynchronizedDataCollection.swift
index 848a922..a17beb1 100644
--- a/stdlib/public/SDK/AVFoundation/AVCaptureSynchronizedDataCollection.swift
+++ b/stdlib/public/SDK/AVFoundation/AVCaptureSynchronizedDataCollection.swift
@@ -16,9 +16,23 @@
#if os(iOS)
@available(iOS, introduced: 11.0)
-extension AVCaptureSynchronizedDataCollection: Sequence {
- public func makeIterator() -> NSFastEnumerationIterator {
- return NSFastEnumerationIterator(self)
+extension AVCaptureSynchronizedDataCollection : Sequence {
+ public func makeIterator() -> Iterator {
+ return Iterator(self)
+ }
+
+ public struct Iterator : IteratorProtocol {
+ internal var fastIterator: NSFastEnumerationIterator
+
+ internal init(_ collection: AVCaptureSynchronizedDataCollection) {
+ self.fastIterator = NSFastEnumerationIterator(collection)
+ }
+
+ public mutating func next() -> AVCaptureSynchronizedData? {
+ guard let nextAny = fastIterator.next() else { return nil }
+ return (nextAny as! AVCaptureSynchronizedData)
+ }
}
}
+
#endif
diff --git a/stdlib/public/SDK/AVFoundation/AVCaptureVideoDataOutput.swift b/stdlib/public/SDK/AVFoundation/AVCaptureVideoDataOutput.swift
new file mode 100644
index 0000000..9e5903d
--- /dev/null
+++ b/stdlib/public/SDK/AVFoundation/AVCaptureVideoDataOutput.swift
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import AVFoundation // Clang module
+import Foundation
+
+
+#if os(macOS) || os(iOS)
+
+extension AVCaptureVideoDataOutput {
+ @available(swift, obsoleted: 4.0)
+ @available(macOS, introduced: 10.7)
+ @available(iOS, introduced: 5.0)
+ @nonobjc
+ public var availableVideoCVPixelFormatTypes: [NSNumber]! {
+ return __availableVideoCVPixelFormatTypes
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(macOS, introduced: 10.7)
+ @available(iOS, introduced: 5.0)
+ @nonobjc
+ public var availableVideoPixelFormatTypes: [OSType] {
+ return __availableVideoCVPixelFormatTypes.map { $0.uint32Value } as [OSType]
+ }
+}
+
+#endif
diff --git a/stdlib/public/SDK/AVFoundation/AVMetadataObject.swift b/stdlib/public/SDK/AVFoundation/AVMetadataObject.swift
new file mode 100644
index 0000000..d884fcd
--- /dev/null
+++ b/stdlib/public/SDK/AVFoundation/AVMetadataObject.swift
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import AVFoundation // Clang module
+import Foundation
+import CoreGraphics
+
+
+#if os(iOS)
+
+extension AVMetadataMachineReadableCodeObject {
+ @available(swift, obsoleted: 4.0)
+ @available(iOS, introduced: 7.0)
+ @nonobjc
+ public var corners: [Any]! {
+ return __corners
+ }
+
+ @available(swift, introduced: 4.0)
+ @available(iOS, introduced: 7.0)
+ @nonobjc
+ public var corners: [CGPoint] {
+ return __corners.map { CGPoint(dictionaryRepresentation: $0 as CFDictionary)! }
+ }
+}
+
+#endif
+
diff --git a/stdlib/public/SDK/AVFoundation/CMakeLists.txt b/stdlib/public/SDK/AVFoundation/CMakeLists.txt
index b77f677..7409412 100644
--- a/stdlib/public/SDK/AVFoundation/CMakeLists.txt
+++ b/stdlib/public/SDK/AVFoundation/CMakeLists.txt
@@ -2,8 +2,12 @@
include("../../../../cmake/modules/StandaloneOverlay.cmake")
add_swift_library(swiftAVFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
+ AVCaptureDevice.swift
+ AVCapturePhotoOutput.swift
AVCaptureSynchronizedDataCollection.swift
+ AVCaptureVideoDataOutput.swift
AVError.swift
+ AVMetadataObject.swift
NSValue.swift.gyb
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
diff --git a/stdlib/public/SDK/CMakeLists.txt b/stdlib/public/SDK/CMakeLists.txt
index a96ec91..23e820f 100644
--- a/stdlib/public/SDK/CMakeLists.txt
+++ b/stdlib/public/SDK/CMakeLists.txt
@@ -10,7 +10,7 @@
list(APPEND SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS "${STDLIB_SIL_SERIALIZE_WITNESS_TABLES}")
-set(all_overlays "Accelerate;AppKit;ARKit;AssetsLibrary;AVFoundation;CallKit;CloudKit;Contacts;CoreAudio;CoreData;CoreFoundation;CoreGraphics;CoreImage;CoreLocation;CoreMedia;CryptoTokenKit;Dispatch;Foundation;GameplayKit;GLKit;HomeKit;IOKit;Intents;MapKit;ModelIO;ObjectiveC;OpenCL;os;Photos;QuartzCore;SafariServices;SceneKit;simd;SpriteKit;UIKit;WatchKit;XCTest;XPC")
+set(all_overlays "Accelerate;AppKit;ARKit;AssetsLibrary;AVFoundation;CallKit;CloudKit;Contacts;CoreAudio;CoreData;CoreFoundation;CoreGraphics;CoreImage;CoreLocation;CoreMedia;CryptoTokenKit;Dispatch;Foundation;GameplayKit;GLKit;HomeKit;IOKit;Intents;MapKit;MediaPlayer;ModelIO;ObjectiveC;OpenCL;os;Photos;QuartzCore;SafariServices;SceneKit;simd;SpriteKit;UIKit;WatchKit;XCTest;XPC")
if(DEFINED SWIFT_OVERLAY_TARGETS)
set(overlays_to_build ${SWIFT_OVERLAY_TARGETS})
diff --git a/stdlib/public/SDK/Intents/CMakeLists.txt b/stdlib/public/SDK/Intents/CMakeLists.txt
index 4e8d68e..4a5a028 100644
--- a/stdlib/public/SDK/Intents/CMakeLists.txt
+++ b/stdlib/public/SDK/Intents/CMakeLists.txt
@@ -8,6 +8,7 @@
INGetCarLockStatusIntentResponse.swift
INGetCarPowerLevelStatusIntentResponse.swift
INIntegerResolutionResult.swift
+ INNotebookItemTypeResolutionResult.swift
INParameter.swift
INRequestRideIntent.swift
INRideOption.swift
diff --git a/stdlib/public/SDK/Intents/INNotebookItemTypeResolutionResult.swift b/stdlib/public/SDK/Intents/INNotebookItemTypeResolutionResult.swift
new file mode 100644
index 0000000..25c1a9d
--- /dev/null
+++ b/stdlib/public/SDK/Intents/INNotebookItemTypeResolutionResult.swift
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import Intents
+import Foundation
+
+#if os(iOS) || os(watchOS)
+@available(iOS 11.0, watchOS 4.0, *)
+extension INNotebookItemTypeResolutionResult {
+ @nonobjc public
+ static func disambiguation(with valuesToDisambiguate: [INNotebookItemType]) -> Self {
+ let numbers = valuesToDisambiguate.map { NSNumber(value: $0.rawValue) }
+ return __disambiguationWithValues(toDisambiguate: numbers)
+ }
+}
+#endif
+
diff --git a/stdlib/public/SDK/MediaPlayer/CMakeLists.txt b/stdlib/public/SDK/MediaPlayer/CMakeLists.txt
new file mode 100644
index 0000000..8334da5
--- /dev/null
+++ b/stdlib/public/SDK/MediaPlayer/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.4.3)
+include("../../../../cmake/modules/StandaloneOverlay.cmake")
+
+add_swift_library(swiftMediaPlayer ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
+ MPMusicPlayerPlayParameters.swift
+
+ SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
+ LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
+ TARGET_SDKS IOS IOS_SIMULATOR
+
+ SWIFT_MODULE_DEPENDS_IOS Darwin AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreMedia Dispatch Foundation ObjectiveC QuartzCore simd UIKit os CoreData # auto-updated
+ FRAMEWORK_DEPENDS_WEAK MediaPlayer
+
+ DEPLOYMENT_VERSION_IOS ${SWIFTLIB_DEPLOYMENT_VERSION_MEDIAPLAYER_IOS}
+)
diff --git a/stdlib/public/SDK/MediaPlayer/MPMusicPlayerPlayParameters.swift b/stdlib/public/SDK/MediaPlayer/MPMusicPlayerPlayParameters.swift
new file mode 100644
index 0000000..566e769
--- /dev/null
+++ b/stdlib/public/SDK/MediaPlayer/MPMusicPlayerPlayParameters.swift
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import MediaPlayer
+import Foundation
+
+@available(iOS 11.0, *)
+extension MPMusicPlayerPlayParameters: Codable {
+ public required convenience init(from decoder: Decoder) throws {
+ var playParametersDictionary: [String: Any] = [:]
+ let values = try decoder.container(keyedBy: CodingKeys.self)
+
+ if let id = try values.decodeIfPresent(String.self, forKey: .id) {
+ playParametersDictionary[CodingKeys.id.rawValue] = id
+ }
+ else if let id = try values.decodeIfPresent(Int64.self, forKey: .id) {
+ playParametersDictionary[CodingKeys.id.rawValue] = NSNumber(value: id)
+ }
+
+ if let kind = try values.decodeIfPresent(String.self, forKey: .kind) {
+ playParametersDictionary[CodingKeys.kind.rawValue] = kind
+ }
+
+ if let isLibrary = try values.decodeIfPresent(Bool.self, forKey: .isLibrary) {
+ playParametersDictionary[CodingKeys.isLibrary.rawValue] = NSNumber(value: isLibrary)
+ }
+
+ guard MPMusicPlayerPlayParameters(dictionary: playParametersDictionary) != nil else {
+ throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath,
+ debugDescription: "Attempted to decode MPMusicPlayerPlayParameters from invalid playParams dictionary."))
+ }
+ self.init(dictionary: playParametersDictionary)!
+ }
+
+ public func encode(to encoder: Encoder) throws {
+ let playParametersDictionary = self.dictionary
+ var values = encoder.container(keyedBy: CodingKeys.self)
+
+ if let id = playParametersDictionary[CodingKeys.id.rawValue] as? String {
+ try values.encode(id, forKey: .id)
+ }
+ else if let id = playParametersDictionary[CodingKeys.id.rawValue] as? Int64 {
+ try values.encode(id, forKey: .id)
+ }
+
+ if let kind = playParametersDictionary[CodingKeys.kind.rawValue] as? String {
+ try values.encode(kind, forKey: .kind)
+ }
+
+ if let isLibrary = playParametersDictionary[CodingKeys.isLibrary.rawValue] as? Bool {
+ try values.encode(isLibrary, forKey: .isLibrary)
+ }
+ }
+
+ internal enum CodingKeys: String, CodingKey {
+ case id
+ case kind
+ case isLibrary
+ }
+}
diff --git a/stdlib/public/SDK/ModelIO/ModelIO.swift b/stdlib/public/SDK/ModelIO/ModelIO.swift
index 8347ec6..36234b7 100644
--- a/stdlib/public/SDK/ModelIO/ModelIO.swift
+++ b/stdlib/public/SDK/ModelIO/ModelIO.swift
@@ -16,40 +16,44 @@
@available(OSX, introduced: 10.13)
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
-extension MDLSkinDeformer {
- public func jointBindTransforms() -> [float4x4] {
- let jointCount = jointPaths.count
- var jointBindTransforms = [float4x4](repeating: float4x4(), count: jointCount)
- copyJointBindTransforms(into: &jointBindTransforms[0], maxCount: jointCount)
- return jointBindTransforms
+extension MDLMatrix4x4Array {
+ @nonobjc public var float4x4Array: [float4x4] {
+ get {
+ let count = elementCount
+ var values = [float4x4](repeating: float4x4(), count: Int(count))
+ __getFloat4x4Array(&values[0], maxCount: count)
+ return values
+ }
+ set(array) {
+ __setFloat4x4(array, count: array.count)
+ }
+ }
+
+ @nonobjc public var double4x4Array: [double4x4] {
+ get {
+ let count = elementCount
+ var values = [double4x4](repeating: double4x4(), count: Int(count))
+ __getDouble4x4Array(&values[0], maxCount: count)
+ return values
+ }
+ set(array) {
+ __setDouble4x4(array, count: array.count)
+ }
}
}
+
+
@available(OSX, introduced: 10.13)
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedValue {
- @nonobjc public func getTimes() -> [Double] {
- var times = [Double](repeating: 0, count: Int(timeSampleCount))
- copyTimes(into: ×[0], maxCount: timeSampleCount)
- return times
- }
-}
-
-@available(OSX, introduced: 10.13)
-@available(iOS, introduced: 11.0)
-@available(tvOS, introduced: 11.0)
-extension MDLAnimatedMatrix4x4 {
- public func getFloat4x4Array() -> [float4x4] {
- var values = [float4x4](repeating: float4x4(), count: Int(timeSampleCount))
- copyFloat4x4Array(into: &values[0], maxCount: timeSampleCount)
- return values
- }
-
- public func getDouble4x4Array() -> [double4x4] {
- var values = [double4x4](repeating: double4x4(), count: Int(timeSampleCount))
- copyDouble4x4Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public var times: [TimeInterval] {
+ get {
+ var times = [TimeInterval](repeating: 0, count: Int(timeSampleCount))
+ __getTimes(×[0], maxCount: timeSampleCount)
+ return times
+ }
}
}
@@ -57,47 +61,181 @@
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedScalarArray {
- @nonobjc public func getFloatArray(atTime time: TimeInterval) -> [Float] {
- var values = [Float](repeating: 0, count: Int(elementsCount))
- copyFloat(into: &values[0], maxCount: elementsCount, atTime: time)
+ @nonobjc public func set(floatArray array:[Float], atTime time: TimeInterval){
+ __setFloat(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func set(doubleArray array:[Double], atTime time: TimeInterval){
+ __setDouble(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func floatArray(atTime time: TimeInterval) -> [Float] {
+ var values = [Float](repeating: 0, count: Int(elementCount))
+ __getFloat(&values[0], maxCount: elementCount, atTime: time)
return values
}
- @nonobjc public func getDoubleArray(atTime time: TimeInterval) -> [Double] {
- var values = [Double](repeating: 0, count: Int(elementsCount))
- copyDouble(into: &values[0], maxCount: elementsCount, atTime: time)
+ @nonobjc public func doubleArray(atTime time: TimeInterval) -> [Double] {
+ var values = [Double](repeating: 0, count: Int(elementCount))
+ __getDouble(&values[0], maxCount: elementCount, atTime: time)
return values
}
- @nonobjc public func getFloatArrays() -> [Float] {
- let count = elementsCount * timeSampleCount
- var values = [Float](repeating: 0, count: Int(count))
- copyFloat(into: &values[0], maxCount: count)
+ @nonobjc public func reset(floatArray array:[Float], atTimes times: [TimeInterval]){
+ __reset(with: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(doubleArray array:[Double], atTimes times: [TimeInterval]){
+ __reset(with: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var floatArray: [Float] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [Float](repeating: 0, count: Int(count))
+ __getFloat(&values[0], maxCount: count)
+ return values
+ }
+ }
+
+ @nonobjc public var doubleArray: [Double] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [Double](repeating: 0, count: Int(count))
+ __getDouble(&values[0], maxCount: count)
+ return values
+ }
+ }
+}
+
+@available(OSX, introduced: 10.13)
+@available(iOS, introduced: 11.0)
+@available(tvOS, introduced: 11.0)
+extension MDLAnimatedVector3Array {
+ @nonobjc public func set(float3Array array:[float3], atTime time: TimeInterval){
+ __setFloat3(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func set(double3Array array:[double3], atTime time: TimeInterval){
+ __setDouble3(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func float3Array(atTime time: TimeInterval) -> [float3] {
+ var values = [float3](repeating: float3(), count: Int(elementCount))
+ __getFloat3Array(&values[0], maxCount: elementCount, atTime: time)
+ return values
+ }
+
+ @nonobjc public func double3Array(atTime time: TimeInterval) -> [double3] {
+ var values = [double3](repeating: double3(), count: Int(elementCount))
+ __getDouble3Array(&values[0], maxCount: elementCount, atTime: time)
+ return values
+ }
+
+ @nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
+ __reset(withFloat3Array: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
+ __reset(withDouble3Array: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var float3Array: [float3] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [float3](repeating: float3(), count: Int(count))
+ __getFloat3Array(&values[0], maxCount: count)
+ return values
+ }
+ }
+
+ @nonobjc public var double3Array: [double3] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [double3](repeating: double3(), count: Int(count))
+ __getDouble3Array(&values[0], maxCount: count)
+ return values
+ }
+ }
+}
+
+@available(OSX, introduced: 10.13)
+@available(iOS, introduced: 11.0)
+@available(tvOS, introduced: 11.0)
+extension MDLAnimatedQuaternionArray {
+ @nonobjc public func set(floatQuaternionArray array:[simd_quatf], atTime time: TimeInterval){
+ __setFloat(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func set(doubleQuaternionArray array:[simd_quatd], atTime time: TimeInterval){
+ __setDouble(array, count: array.count, atTime: time)
+ }
+
+ @nonobjc public func floatQuaternionArray(atTime time: TimeInterval) -> [simd_quatf] {
+ var values = [simd_quatf](repeating: simd_quatf(), count: Int(elementCount))
+ __getFloat(&values[0], maxCount: elementCount, atTime: time)
return values
}
- @nonobjc public func getDoubleArrays() -> [Double] {
- let count = elementsCount * timeSampleCount
- var values = [Double](repeating: 0, count: Int(count))
- copyDouble(into: &values[0], maxCount: count)
+ @nonobjc public func doubleQuaternionArray(atTime time: TimeInterval) -> [simd_quatd] {
+ var values = [simd_quatd](repeating: simd_quatd(), count: Int(elementCount))
+ __getDouble(&values[0], maxCount: elementCount, atTime: time)
return values
}
+
+ @nonobjc public func reset(floatQuaternionArray array:[simd_quatf], atTimes times: [TimeInterval]){
+ __reset(withFloat: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(doubleQuaternionArray array:[simd_quatd], atTimes times: [TimeInterval]){
+ __reset(withDouble: array, count: array.count, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var floatQuaternionArray : [simd_quatf] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [simd_quatf](repeating: simd_quatf(), count: Int(count))
+ __getFloat(&values[0], maxCount: count)
+ return values
+ }
+ }
+
+ @nonobjc public var doubleQuaternionArray: [simd_quatd] {
+ get {
+ let count = elementCount * timeSampleCount
+ var values = [simd_quatd](repeating: simd_quatd(), count: Int(count))
+ __getDouble(&values[0], maxCount: count)
+ return values
+ }
+ }
}
@available(OSX, introduced: 10.13)
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedScalar {
- @nonobjc public func getFloatArray() -> [Float] {
- var values = [Float](repeating: 0, count: Int(timeSampleCount))
- copyFloatArray(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public func reset(floatArray array:[Float], atTimes times: [TimeInterval]){
+ __reset(withFloatArray: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(doubleArray array:[Double], atTimes times: [TimeInterval]){
+ __reset(withDoubleArray: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var floatArray: [Float] {
+ get {
+ var values = [Float](repeating: 0, count: Int(timeSampleCount))
+ __getFloatArray(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
- @nonobjc public func getDoubleArray() -> [Double] {
- var values = [Double](repeating: 0, count: Int(timeSampleCount))
- copyDoubleArray(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public var doubleArray: [Double] {
+ get {
+ var values = [Double](repeating: 0, count: Int(timeSampleCount))
+ __getDoubleArray(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
}
@@ -105,16 +243,28 @@
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector2 {
- public func getFloat2Array() -> [float2] {
- var values = [float2](repeating: float2(), count: Int(timeSampleCount))
- copyFloat2Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public func reset(float2Array array:[float2], atTimes times: [TimeInterval]){
+ __reset(withFloat2Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(double2Array array:[double2], atTimes times: [TimeInterval]){
+ __reset(withDouble2Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var float2Array: [float2] {
+ get {
+ var values = [float2](repeating: float2(), count: Int(timeSampleCount))
+ __getFloat2Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
- public func getDouble2Array() -> [double2] {
- var values = [double2](repeating: double2(), count: Int(timeSampleCount))
- copyDouble2Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public var double2Array: [double2] {
+ get {
+ var values = [double2](repeating: double2(), count: Int(timeSampleCount))
+ __getDouble2Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
}
@@ -122,16 +272,28 @@
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector3 {
- public func getFloat3Array() -> [float3] {
- var values = [float3](repeating: float3(), count: Int(timeSampleCount))
- copyFloat3Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
+ __reset(withFloat3Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
+ __reset(withDouble3Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var float3Array: [float3] {
+ get {
+ var values = [float3](repeating: float3(), count: Int(timeSampleCount))
+ __getFloat3Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
- public func getDouble3Array() -> [double3] {
- var values = [double3](repeating: double3(), count: Int(timeSampleCount))
- copyDouble3Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public var double3Array: [double3] {
+ get {
+ var values = [double3](repeating: double3(), count: Int(timeSampleCount))
+ __getDouble3Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
}
@@ -139,15 +301,57 @@
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector4 {
- public func getFloat4Array() -> [float4] {
- var values = [float4](repeating: float4(), count: timeSampleCount)
- copyFloat4Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public func reset(float4Array array:[float4], atTimes times: [TimeInterval]){
+ __reset(withFloat4Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(double4Array array:[double4], atTimes times: [TimeInterval]){
+ __reset(withDouble4Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var float4Array: [float4] {
+ get {
+ var values = [float4](repeating: float4(), count: Int(timeSampleCount))
+ __getFloat4Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
- public func getDouble4Array() -> [double4] {
- var values = [double4](repeating: double4(), count: timeSampleCount)
- copyDouble4Array(into: &values[0], maxCount: timeSampleCount)
- return values
+ @nonobjc public var double4Array: [double4] {
+ get {
+ var values = [double4](repeating: double4(), count: Int(timeSampleCount))
+ __getDouble4Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
}
}
+
+@available(OSX, introduced: 10.13)
+@available(iOS, introduced: 11.0)
+@available(tvOS, introduced: 11.0)
+extension MDLAnimatedMatrix4x4 {
+ @nonobjc public func reset(float4x4Array array:[float4x4], atTimes times: [TimeInterval]){
+ __reset(withFloat4x4Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public func reset(double4Array array:[double4x4], atTimes times: [TimeInterval]){
+ __reset(withDouble4x4Array: array, atTimes: times, count: times.count)
+ }
+
+ @nonobjc public var float4x4Array: [float4x4] {
+ get {
+ var values = [float4x4](repeating: float4x4(), count: Int(timeSampleCount))
+ __getFloat4x4Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
+ }
+
+ @nonobjc public var double4x4Array: [double4x4] {
+ get {
+ var values = [double4x4](repeating: double4x4(), count: Int(timeSampleCount))
+ __getDouble4x4Array(&values[0], maxCount: timeSampleCount)
+ return values
+ }
+ }
+}
+
diff --git a/stdlib/public/SDK/XCTest/XCTest.swift b/stdlib/public/SDK/XCTest/XCTest.swift
index ae3427b..a3fa39c 100644
--- a/stdlib/public/SDK/XCTest/XCTest.swift
+++ b/stdlib/public/SDK/XCTest/XCTest.swift
@@ -20,26 +20,35 @@
public extension XCTContext {
/// Create and run a new activity with provided name and block.
- public class func runActivity(named name: String, block: (XCTActivity) throws -> ()) rethrows {
+ public class func runActivity<Result>(named name: String, block: (XCTActivity) throws -> Result) rethrows -> Result {
let context = _XCTContextCurrent()
if _XCTContextShouldStartActivity(context, XCTActivityTypeUserCreated) {
- try autoreleasepool {
+ return try autoreleasepool {
let activity = _XCTContextWillStartActivity(context, name, XCTActivityTypeUserCreated)
- do {
- try block(activity)
+ defer {
_XCTContextDidFinishActivity(context, activity)
- } catch {
- _XCTContextDidFinishActivity(context, activity)
- throw error
}
+ return try block(activity)
}
} else {
- XCTFail("XCTContext.runActivity(named:block:) failed because activities are disallowed in the current configuration.")
+ fatalError("XCTContext.runActivity(named:block:) failed because activities are disallowed in the current configuration.")
}
}
}
+#if os(macOS)
+@available(swift 4.0)
+@available(macOS 10.11, *)
+public extension XCUIElement {
+ /// Types a single key from the XCUIKeyboardKey enumeration with the specified modifier flags.
+ @nonobjc public func typeKey(_ key: XCUIKeyboardKey, modifierFlags: XCUIKeyModifierFlags) {
+ // Call the version of the method defined in XCTest.framework.
+ typeKey(key.rawValue, modifierFlags: modifierFlags)
+ }
+}
+#endif
+
// --- Failure Formatting ---
/// Register the failure, expected or unexpected, of the current test case.
diff --git a/test/Constraints/generics.swift b/test/Constraints/generics.swift
index e3f84dd..2953770 100644
--- a/test/Constraints/generics.swift
+++ b/test/Constraints/generics.swift
@@ -248,10 +248,12 @@
struct V27515965 {
init<T : P27515965>(_ tp: T) where T.R == Float {}
+ // expected-note@-1 {{candidate requires that the types 'Any' and 'Float' be equivalent (requirement specified as 'T.R' == 'Float' [with T = S27515965])}}
}
func test(x: S27515965) -> V27515965 {
- return V27515965(x) // expected-error {{generic parameter 'T' could not be inferred}}
+ return V27515965(x)
+ // expected-error@-1 {{cannot invoke initializer for type 'init(_:)' with an argument list of type '(S27515965)'}}
}
protocol BaseProto {}
diff --git a/test/Generics/deduction.swift b/test/Generics/deduction.swift
index 02408ed..4dc2647 100644
--- a/test/Generics/deduction.swift
+++ b/test/Generics/deduction.swift
@@ -216,11 +216,12 @@
}
func testEqualIterElementTypes<A: IteratorProtocol, B: IteratorProtocol>(_ a: A, _ b: B) where A.Element == B.Element {}
-// expected-note@-1 {{requirement specified as 'A.Element' == 'B.Element' [with A = IndexingIterator<[Int]>, B = IndexingIterator<[Double]>]}}
+// expected-note@-1 {{candidate requires that the types 'Int' and 'Double' be equivalent (requirement specified as 'A.Element' == 'B.Element' [with A = IndexingIterator<[Int]>, B = IndexingIterator<[Double]>])}}
func compareIterators() {
var a: [Int] = []
var b: [Double] = []
- testEqualIterElementTypes(a.makeIterator(), b.makeIterator()) // expected-error {{'<A, B where A : IteratorProtocol, B : IteratorProtocol, A.Element == B.Element> (A, B) -> ()' requires the types 'Int' and 'Double' be equivalent}}
+ testEqualIterElementTypes(a.makeIterator(), b.makeIterator())
+ // expected-error@-1 {{cannot invoke 'testEqualIterElementTypes(_:_:)' with an argument list of type '(IndexingIterator<[Int]>, IndexingIterator<[Double]>)'}}
}
protocol P_GI {
@@ -233,9 +234,9 @@
class GI_Diff {}
func genericInheritsA<T>(_ x: T) where T : P_GI, T.Y : GI_Diff {}
-// expected-note@-1 {{requirement specified as 'T.Y' : 'GI_Diff' [with T = C_GI]}}
-genericInheritsA(C_GI()) // expected-error {{<T where T : P_GI, T.Y : GI_Diff> (T) -> ()' requires that 'C_GI.Y' (aka 'Double') inherit from 'GI_Diff'}}
-
+// expected-note@-1 {{candidate requires that 'GI_Diff' inherit from 'T.Y' (requirement specified as 'T.Y' : 'GI_Diff' [with T = C_GI])}}
+genericInheritsA(C_GI())
+// expected-error@-1 {{cannot invoke 'genericInheritsA(_:)' with an argument list of type '(C_GI)'}}
//===----------------------------------------------------------------------===//
// Deduction for member operators
@@ -318,3 +319,24 @@
let l = min(3, oi) // expected-error{{value of optional type 'Int?' not unwrapped; did you mean to use '!' or '?'?}}
}
+infix operator +&
+func +&<R, S>(lhs: inout R, rhs: S) where R : RangeReplaceableCollection, S : Sequence, R.Element == S.Element {}
+// expected-note@-1 {{candidate requires that the types 'String' and 'String.Element' (aka 'Character') be equivalent (requirement specified as 'R.Element' == 'S.Element' [with R = [String], S = String])}}
+
+func rdar33477726_1() {
+ var arr: [String] = []
+ arr +& "hello"
+ // expected-error@-1 {{binary operator '+&(_:_:)' cannot be applied to operands of type '[String]' and 'String'}}
+}
+
+func rdar33477726_2<R, S>(_: R, _: S) where R: Sequence, S == R.Element {}
+// expected-note@-1 {{candidate requires that the types 'Int' and 'String.Element' (aka 'Character') be equivalent (requirement specified as 'S' == 'R.Element' [with R = String, S = Int])}}
+rdar33477726_2("answer", 42)
+// expected-error@-1 {{cannot invoke 'rdar33477726_2(_:_:)' with an argument list of type '(String, Int)'}}
+
+prefix operator +-
+prefix func +-<T>(_: T) where T: Sequence, T.Element == Int {}
+// expected-note@-1 {{candidate requires that the types 'String.Element' (aka 'Character') and 'Int' be equivalent (requirement specified as 'T.Element' == 'Int' [with T = String])}}
+
++-"hello"
+// expected-error@-1 {{unary operator '+-(_:)' cannot be applied to an operand of type 'String'}}
diff --git a/test/SILOptimizer/sil_combine.sil b/test/SILOptimizer/sil_combine.sil
index 47f424d..38343bc 100644
--- a/test/SILOptimizer/sil_combine.sil
+++ b/test/SILOptimizer/sil_combine.sil
@@ -2878,8 +2878,8 @@
// CHECK-NEXT: [[TMP:%.*]] = alloc_stack $T
// CHECK: [[FN:%.*]] = function_ref @generic_callee
// CHECK-NEXT: copy_addr [[ARG1]] to [initialization] [[TMP]] : $*T
-// CHECK-NEXT: apply [[FN]]<T, T>([[ARG0]], [[TMP]])
// CHECK-NEXT: destroy_addr [[ARG1]]
+// CHECK-NEXT: apply [[FN]]<T, T>([[ARG0]], [[TMP]])
// CHECK-NEXT: destroy_addr [[TMP]]
// CHECK-NEXT: tuple
// CHECK-NEXT: dealloc_stack [[TMP]]
diff --git a/test/SILOptimizer/sil_combine_apply.sil b/test/SILOptimizer/sil_combine_apply.sil
index c8d3551..0c85a11 100644
--- a/test/SILOptimizer/sil_combine_apply.sil
+++ b/test/SILOptimizer/sil_combine_apply.sil
@@ -7,6 +7,9 @@
//////////////////
sil @unknown : $@convention(thin) () -> ()
+sil @generic_callee : $@convention(thin) <T, U> (@in T, @in U) -> ()
+
+protocol Error {}
/////////////////////////////////
// Tests for SILCombinerApply. //
@@ -36,21 +39,30 @@
// CHECK-LABEL: sil @sil_combine_dead_partial_apply : $@convention(thin) (@in S2, @in S4, @inout S5, S6, @owned S7, @guaranteed S8) -> () {
// CHECK: bb0([[IN_ARG:%.*]] : $*S2, [[INGUARANTEED_ARG:%.*]] : $*S4, [[INOUT_ARG:%.*]] : $*S5, [[UNOWNED_ARG:%.*]] : $S6, [[OWNED_ARG:%.*]] : $S7, [[GUARANTEED_ARG:%.*]] : $S8):
//
+// CHECK: [[IN_ADDRESS_1:%.*]] = alloc_stack $S1
+// CHECK: [[IN_ARG_1:%.*]] = alloc_stack $S2
+// CHECK: [[INGUARANTEED_ADDRESS_1:%.*]] = alloc_stack $S3
+// CHECK: [[INGUARANTEED_ARG_1:%.*]] = alloc_stack $S4
+//
// CHECK: function_ref unknown
// CHECK: [[UNKNOWN_FUNC:%.*]] = function_ref @unknown
// CHECK-NEXT: [[IN_ADDRESS:%.*]] = alloc_stack $S1
// CHECK-NEXT: [[INGUARANTEED_ADDRESS:%.*]] = alloc_stack $S3
//
// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK: copy_addr [take] [[INGUARANTEED_ARG]] to [initialization] [[INGUARANTEED_ARG_1]]
+// CHECK: copy_addr [take] [[INGUARANTEED_ADDRESS]] to [initialization] [[INGUARANTEED_ADDRESS_1]]
+// CHECK: copy_addr [take] [[IN_ARG]] to [initialization] [[IN_ARG_1]]
+// CHECK: copy_addr [take] [[IN_ADDRESS]] to [initialization] [[IN_ADDRESS_1]]
//
// Then make sure that the destroys are placed after the destroy_value of the
// partial_apply (which is after this apply)...
// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
//
-// CHECK-NEXT: destroy_addr [[IN_ADDRESS]]
-// CHECK-NEXT: destroy_addr [[IN_ARG]]
-// CHECK-NEXT: destroy_addr [[INGUARANTEED_ADDRESS]]
-// CHECK-NEXT: destroy_addr [[INGUARANTEED_ARG]]
+// CHECK-NEXT: destroy_addr [[IN_ADDRESS_1]]
+// CHECK-NEXT: destroy_addr [[IN_ARG_1]]
+// CHECK-NEXT: destroy_addr [[INGUARANTEED_ADDRESS_1]]
+// CHECK-NEXT: destroy_addr [[INGUARANTEED_ARG_1]]
// CHECK-NEXT: release_value [[UNOWNED_ARG]]
// CHECK-NEXT: release_value [[OWNED_ARG]]
// CHECK-NEXT: release_value [[GUARANTEED_ARG]]
@@ -60,6 +72,10 @@
// CHECK-NEXT: dealloc_stack [[INGUARANTEED_ADDRESS]]
// CHECK-NEXT: dealloc_stack [[IN_ADDRESS]]
// CHECK-NEXT: tuple
+// CHECK-NEXT: dealloc_stack [[INGUARANTEED_ARG_1]]
+// CHECK-NEXT: dealloc_stack [[INGUARANTEED_ADDRESS_1]]
+// CHECK-NEXT: dealloc_stack [[IN_ARG_1]]
+// CHECK-NEXT: dealloc_stack [[IN_ADDRESS_1]]
// CHECK-NEXT: return
// CHECK-NEXT: } // end sil function 'sil_combine_dead_partial_apply'
sil @sil_combine_dead_partial_apply : $@convention(thin) (@in S2, @in S4, @inout S5, S6, @owned S7, @guaranteed S8) -> () {
@@ -96,3 +112,177 @@
%9999 = tuple()
return %9999 : $()
}
+
+sil @sil_combine_partial_apply_callee_2 : $@convention(thin) (@in S1) -> ()
+
+// CHECK-LABEL: sil @sil_combine_dead_partial_apply_non_overlapping_lifetime : $@convention(thin) () -> () {
+// CHECK: bb0:
+// CHECK: [[NEW_ALLOC_STACK:%.*]] = alloc_stack $S1
+// CHECK-NEXT: function_ref unknown
+// CHECK-NEXT: [[UNKNOWN_FUNC:%.*]] = function_ref @unknown : $@convention(thin) () -> ()
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: br bb1
+//
+// CHECK: bb1:
+// CHECK: [[ORIGINAL_ALLOC_STACK:%.*]] = alloc_stack $S1
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: copy_addr [take] [[ORIGINAL_ALLOC_STACK]] to [initialization] [[NEW_ALLOC_STACK]]
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: dealloc_stack [[ORIGINAL_ALLOC_STACK]]
+// CHECK-NEXT: apply
+// CHECK-NEXT: cond_br undef, bb2, bb3
+//
+// CHECK: bb2:
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: destroy_addr [[NEW_ALLOC_STACK]]
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: br bb4
+//
+// CHECK: bb3:
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: destroy_addr [[NEW_ALLOC_STACK]]
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: br bb4
+//
+// CHECK: bb4:
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: tuple
+// CHECK-NEXT: apply [[UNKNOWN_FUNC]]()
+// CHECK-NEXT: dealloc_stack [[NEW_ALLOC_STACK]]
+// CHECK: } // end sil function 'sil_combine_dead_partial_apply_non_overlapping_lifetime'
+sil @sil_combine_dead_partial_apply_non_overlapping_lifetime : $@convention(thin) () -> () {
+bb0:
+ %3 = function_ref @unknown : $@convention(thin) () -> ()
+ apply %3() : $@convention(thin) () -> ()
+ br bb1
+
+bb1:
+ %0 = alloc_stack $S1
+ apply %3() : $@convention(thin) () -> ()
+ %1 = function_ref @sil_combine_partial_apply_callee_2 : $@convention(thin) (@in S1) -> ()
+ apply %3() : $@convention(thin) () -> ()
+ %2 = partial_apply %1(%0) : $@convention(thin) (@in S1) -> ()
+ apply %3() : $@convention(thin) () -> ()
+ dealloc_stack %0 : $*S1
+ apply %3() : $@convention(thin) () -> ()
+ cond_br undef, bb2, bb3
+
+bb2:
+ apply %3() : $@convention(thin) () -> ()
+ strong_release %2 : $@callee_owned () -> ()
+ apply %3() : $@convention(thin) () -> ()
+ br bb4
+
+bb3:
+ apply %3() : $@convention(thin) () -> ()
+ strong_release %2 : $@callee_owned () -> ()
+ apply %3() : $@convention(thin) () -> ()
+ br bb4
+
+bb4:
+ apply %3() : $@convention(thin) () -> ()
+ %9999 = tuple()
+ apply %3() : $@convention(thin) () -> ()
+ return %9999 : $()
+}
+
+sil @try_apply_func : $@convention(thin) () -> (Builtin.Int32, @error Error)
+
+// CHECK-LABEL: sil @sil_combine_dead_partial_apply_try_apply : $@convention(thin) () -> ((), @error Error) {
+// CHECK: bb0:
+// CHECK: [[NEW_ALLOC_STACK:%.*]] = alloc_stack $S1
+// CHECK-NEXT: br bb1
+// CHECK: bb5(
+// CHECK-NEXT: tuple
+// CHECK-NEXT: dealloc_stack [[NEW_ALLOC_STACK]]
+// CHECK-NEXT: return
+// CHECK: bb6(
+// CHECK-NEXT: dealloc_stack [[NEW_ALLOC_STACK]]
+// CHECK-NEXT: throw
+// CHECK: } // end sil function 'sil_combine_dead_partial_apply_try_apply'
+sil @sil_combine_dead_partial_apply_try_apply : $@convention(thin) () -> ((), @error Error) {
+bb0:
+ br bb1
+
+bb1:
+ %0 = alloc_stack $S1
+ %1 = function_ref @sil_combine_partial_apply_callee_2 : $@convention(thin) (@in S1) -> ()
+ %2 = partial_apply %1(%0) : $@convention(thin) (@in S1) -> ()
+ dealloc_stack %0 : $*S1
+ cond_br undef, bb2, bb3
+
+bb2:
+ strong_release %2 : $@callee_owned () -> ()
+ %99991 = tuple()
+ br bb4
+
+bb3:
+ strong_release %2 : $@callee_owned () -> ()
+ %99992 = tuple()
+ br bb4
+
+bb4:
+ %3 = function_ref @try_apply_func : $@convention(thin) () -> (Builtin.Int32, @error Error)
+ try_apply %3() : $@convention(thin) () -> (Builtin.Int32, @error Error), normal bb5, error bb6
+
+bb5(%4 : $Builtin.Int32):
+ %9999 = tuple()
+ return %9999 : $()
+
+bb6(%5 : $Error):
+ %6 = builtin "willThrow"(%5 : $Error) : $()
+ throw %5 : $Error
+}
+
+protocol SwiftP {
+ func foo()
+}
+
+// Make sure that we do not optimize this case. If we do optimize this case,
+// given the current algorithm which puts alloc_stack at the beginning/end of
+// the function, we will have a fatal error.
+sil @sil_combine_dead_partial_apply_with_opened_existential : $@convention(thin) () -> ((), @error Error) {
+bb0:
+ %0b = alloc_stack $SwiftP
+ %1 = open_existential_addr mutable_access %0b : $*SwiftP to $*@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP
+ %2 = witness_method $@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP, #SwiftP.foo!1, %1 : $*@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP : $@convention(witness_method) <τ_0_0 where τ_0_0 : SwiftP> (@in_guaranteed τ_0_0) -> ()
+ %0c = alloc_stack $@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP
+ %3 = partial_apply %2<@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP>(%0c) : $@convention(witness_method) <τ_0_0 where τ_0_0 : SwiftP> (@in_guaranteed τ_0_0) -> ()
+ dealloc_stack %0c : $*@opened("3305E696-5685-11E5-9393-B8E856428C60") SwiftP
+ strong_release %3 : $@callee_owned () -> ()
+ dealloc_stack %0b : $*SwiftP
+ %9999 = tuple()
+ return %9999 : $()
+}
+
+// This is a version of a test in sil_combine.sil that tests ignoring the
+// trivial alloc stack elimination optimization. Said optimization can make
+// testing ownership more difficult since the optimization does not care about
+// ownership correctness (i.e. it can hide leaks).
+//
+// This test first transforms (apply (partial_apply)) -> apply and then lets the
+// dead partial apply code eliminate the partial apply.
+//
+// CHECK-LABEL: sil @test_generic_partial_apply_apply
+// CHECK: bb0([[ARG0:%.*]] : $*T, [[ARG1:%.*]] : $*T):
+// CHECK-NEXT: [[PA_TMP:%.*]] = alloc_stack $T
+// CHECK-NEXT: [[APPLY_TMP:%.*]] = alloc_stack $T
+// CHECK: [[FN:%.*]] = function_ref @generic_callee
+// CHECK-NEXT: copy_addr [[ARG1]] to [initialization] [[APPLY_TMP]]
+// CHECK-NEXT: copy_addr [take] [[ARG1]] to [initialization] [[PA_TMP]]
+// CHECK-NEXT: apply [[FN]]<T, T>([[ARG0]], [[APPLY_TMP]])
+// CHECK-NEXT: destroy_addr [[PA_TMP]]
+// CHECK-NEXT: destroy_addr [[APPLY_TMP]]
+// CHECK-NEXT: tuple
+// CHECK-NEXT: dealloc_stack [[APPLY_TMP]]
+// CHECK-NEXT: dealloc_stack [[PA_TMP]]
+// CHECK-NEXT: return
+sil @test_generic_partial_apply_apply : $@convention(thin) <T> (@in T, @in T) -> () {
+bb0(%0 : $*T, %1 : $*T):
+ %f1 = function_ref @generic_callee : $@convention(thin) <T, U> (@in T, @in U) -> ()
+ %pa = partial_apply %f1<T, T>(%1) : $@convention(thin) <T, U> (@in T, @in U) -> ()
+ %a1 = apply %pa(%0) : $@callee_owned (@in T) -> ()
+ %r = tuple ()
+ return %r : $()
+}
\ No newline at end of file
diff --git a/test/decl/protocol/req/recursion.swift b/test/decl/protocol/req/recursion.swift
index cc4bc07..4c8bd90 100644
--- a/test/decl/protocol/req/recursion.swift
+++ b/test/decl/protocol/req/recursion.swift
@@ -48,7 +48,7 @@
// expected-error@-2 {{generic struct 'S' references itself}}
func f(a: A.T) {
g(a: id(t: a))
- // expected-error@-1 {{cannot convert value of type 'A.T' to expected argument type 'S<_>'}}
+ // expected-error@-1 {{generic parameter 'T' could not be inferred}}
_ = A.T.self
}
diff --git a/test/stdlib/AVFoundation.swift b/test/stdlib/AVFoundation.swift
deleted file mode 100644
index 0740208..0000000
--- a/test/stdlib/AVFoundation.swift
+++ /dev/null
@@ -1,42 +0,0 @@
-// RUN: %target-run-simple-swift
-// REQUIRES: executable_test
-// REQUIRES: objc_interop
-// CoreMedia is not present on watchOS.
-// UNSUPPORTED: OS=watchos
-
-import CoreMedia
-import AVFoundation
-import StdlibUnittest
-import StdlibUnittestFoundationExtras
-
-var coreMedia = TestSuite("CoreMedia")
-
-func equalCMTimeMappings(_ x: CMTimeMapping, _ y: CMTimeMapping) -> Bool {
- var xx = x, yy = y
- return memcmp(&xx, &yy, MemoryLayout<CMTimeMapping>.size) == 0
-}
-
-coreMedia.test("NSValue bridging") {
- let time1 = CMTimeMake(181, 60)
- expectBridgeToNSValue(time1,
- nsValueInitializer: { NSValue(time: $0) },
- nsValueGetter: { $0.timeValue },
- equal: (==))
- let time2 = CMTimeMake(242, 60)
- let timeRange1 = CMTimeRangeFromTimeToTime(time1, time2)
-
- expectBridgeToNSValue(timeRange1,
- nsValueInitializer: { NSValue(timeRange: $0) },
- nsValueGetter: { $0.timeRangeValue },
- equal: (==))
-
- let time3 = CMTimeMake(303, 60)
- let timeRange2 = CMTimeRangeFromTimeToTime(time2, time3)
- let timeMapping = CMTimeMapping(source: timeRange1, target: timeRange2)
- expectBridgeToNSValue(timeMapping,
- nsValueInitializer: { NSValue(timeMapping: $0) },
- nsValueGetter: { $0.timeMappingValue },
- equal: equalCMTimeMappings)
-}
-
-runAllTests()
diff --git a/test/stdlib/AVFoundation_Swift3.swift b/test/stdlib/AVFoundation_Swift3.swift
new file mode 100644
index 0000000..ed9e896
--- /dev/null
+++ b/test/stdlib/AVFoundation_Swift3.swift
@@ -0,0 +1,116 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %target-build-swift -swift-version 3 %s -o %t/a.out
+// RUN: %target-run %t/a.out
+// REQUIRES: objc_interop
+// REQUIRES: executable_test
+// CoreMedia is not present on watchOS.
+// UNSUPPORTED: OS=watchos
+
+import CoreMedia
+import AVFoundation
+import StdlibUnittest
+import StdlibUnittestFoundationExtras
+
+var coreMedia = TestSuite("CoreMedia")
+
+func equalCMTimeMappings(_ x: CMTimeMapping, _ y: CMTimeMapping) -> Bool {
+ var xx = x, yy = y
+ return memcmp(&xx, &yy, MemoryLayout<CMTimeMapping>.size) == 0
+}
+
+coreMedia.test("NSValue bridging") {
+ let time1 = CMTimeMake(181, 60)
+ expectBridgeToNSValue(time1,
+ nsValueInitializer: { NSValue(time: $0) },
+ nsValueGetter: { $0.timeValue },
+ equal: (==))
+ let time2 = CMTimeMake(242, 60)
+ let timeRange1 = CMTimeRangeFromTimeToTime(time1, time2)
+
+ expectBridgeToNSValue(timeRange1,
+ nsValueInitializer: { NSValue(timeRange: $0) },
+ nsValueGetter: { $0.timeRangeValue },
+ equal: (==))
+
+ let time3 = CMTimeMake(303, 60)
+ let timeRange2 = CMTimeRangeFromTimeToTime(time2, time3)
+ let timeMapping = CMTimeMapping(source: timeRange1, target: timeRange2)
+ expectBridgeToNSValue(timeMapping,
+ nsValueInitializer: { NSValue(timeMapping: $0) },
+ nsValueGetter: { $0.timeMappingValue },
+ equal: equalCMTimeMappings)
+}
+
+
+var AVFoundationTests = TestSuite("AVFoundation_Swift3")
+
+let boxedPixelFormat = NSNumber(value: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)
+
+#if os(macOS) || os(iOS)
+
+if #available(iOS 5, *) {
+ AVFoundationTests.test("AVCaptureVideoDataOutput.availableVideoCVPixelFormatTypes") {
+ func f(v: AVCaptureVideoDataOutput) -> Bool {
+ return v.availableVideoCVPixelFormatTypes.contains(boxedPixelFormat)
+ }
+ }
+}
+
+#endif
+
+#if os(iOS)
+
+if #available(iOS 7, *) {
+ AVFoundationTests.test("AVMetadataMachineReadableCodeObject.corners") {
+ func f(m: AVMetadataMachineReadableCodeObject) -> [Any]! {
+ return m.corners
+ }
+ }
+}
+
+if #available(iOS 10, *) {
+ AVFoundationTests.test("AVCaptureDeviceFormat.supportedColorSpaces") {
+ func f(df: AVCaptureDeviceFormat) -> Bool {
+ return df.supportedColorSpaces.contains(NSNumber(value: AVCaptureColorSpace.sRGB.rawValue))
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.supportedFlashModes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.supportedFlashModes.contains(NSNumber(value: AVCaptureFlashMode.off.rawValue))
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.availablePhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.availablePhotoPixelFormatTypes.contains(boxedPixelFormat)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.availableRawPhotoPixelFormatTypes.contains(boxedPixelFormat)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoSettings) -> Bool {
+ return p.availablePreviewPhotoPixelFormatTypes.contains(boxedPixelFormat)
+ }
+ }
+}
+
+if #available(iOS 11, *) {
+ AVFoundationTests.test("AVCaptureSynchronizedDataCollection/iteration") {
+ func f(c: AVCaptureSynchronizedDataCollection) {
+ for element in c {
+ var element = element
+ expectType(AVCaptureSynchronizedData.self, &element)
+ }
+ }
+ }
+}
+
+#endif
+
+runAllTests()
diff --git a/test/stdlib/AVFoundation_Swift4.swift b/test/stdlib/AVFoundation_Swift4.swift
new file mode 100644
index 0000000..dd24e27
--- /dev/null
+++ b/test/stdlib/AVFoundation_Swift4.swift
@@ -0,0 +1,83 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %target-build-swift -swift-version 4 %s -o %t/a.out
+// RUN: %target-run %t/a.out
+// REQUIRES: objc_interop
+// REQUIRES: executable_test
+// CoreMedia is not present on watchOS.
+// UNSUPPORTED: OS=watchos
+
+import AVFoundation
+import StdlibUnittest
+
+var AVFoundationTests = TestSuite("AVFoundation_Swift4")
+
+let pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
+
+#if os(macOS) || os(iOS)
+
+if #available(iOS 5, *) {
+ AVFoundationTests.test("AVCaptureVideoDataOutput.availableVideoPixelFormatTypes") {
+ func f(v: AVCaptureVideoDataOutput) -> Bool {
+ return v.availableVideoPixelFormatTypes.contains(pixelFormat)
+ }
+ }
+}
+
+#endif
+
+#if os(iOS)
+
+if #available(iOS 7, *) {
+ AVFoundationTests.test("AVMetadataMachineReadableCodeObject.corners") {
+ func f(m: AVMetadataMachineReadableCodeObject) -> Bool {
+ if let c = m.corners.first {
+ return c.x == 0
+ }
+ return false
+ }
+ }
+}
+
+if #available(iOS 10, *) {
+ AVFoundationTests.test("AVCaptureDevice.Format.supportedColorSpaces") {
+ func f(df: AVCaptureDevice.Format) -> Bool {
+ return df.supportedColorSpaces.contains(.sRGB)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.supportedFlashModes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.supportedFlashModes.contains(.off)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.availablePhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.availablePhotoPixelFormatTypes.contains(pixelFormat)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoOutput) -> Bool {
+ return p.availableRawPhotoPixelFormatTypes.contains(pixelFormat)
+ }
+ }
+
+ AVFoundationTests.test("AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes") {
+ func f(p: AVCapturePhotoSettings) -> Bool {
+ return p.availablePreviewPhotoPixelFormatTypes.contains(pixelFormat)
+ }
+ }
+}
+
+if #available(iOS 11, *) {
+ AVFoundationTests.test("AVCaptureSynchronizedDataCollection.makeIterator()") {
+ func f(c: AVCaptureSynchronizedDataCollection) {
+ for _ in c {}
+ }
+ }
+}
+
+#endif
+
+runAllTests()
diff --git a/test/stdlib/CodableTests.swift b/test/stdlib/CodableTests.swift
index 30d1fd5..13f3969 100644
--- a/test/stdlib/CodableTests.swift
+++ b/test/stdlib/CodableTests.swift
@@ -108,6 +108,7 @@
class TestCodable : TestCodableSuper {
// MARK: - AffineTransform
#if os(OSX)
+ // FIXME: Comment the tests back in once rdar://problem/33363218 is in the SDK.
lazy var affineTransformValues: [AffineTransform] = [
AffineTransform.identity,
AffineTransform(),
@@ -116,10 +117,10 @@
AffineTransform(rotationByDegrees: .pi / 2),
AffineTransform(m11: 1.0, m12: 2.5, m21: 66.2, m22: 40.2, tX: -5.5, tY: 3.7),
- AffineTransform(m11: -55.66, m12: 22.7, m21: 1.5, m22: 0.0, tX: -22, tY: -33),
+ // AffineTransform(m11: -55.66, m12: 22.7, m21: 1.5, m22: 0.0, tX: -22, tY: -33),
AffineTransform(m11: 4.5, m12: 1.1, m21: 0.025, m22: 0.077, tX: -0.55, tY: 33.2),
- AffineTransform(m11: 7.0, m12: -2.3, m21: 6.7, m22: 0.25, tX: 0.556, tY: 0.99),
- AffineTransform(m11: 0.498, m12: -0.284, m21: -0.742, m22: 0.3248, tX: 12, tY: 44)
+ // AffineTransform(m11: 7.0, m12: -2.3, m21: 6.7, m22: 0.25, tX: 0.556, tY: 0.99),
+ // AffineTransform(m11: 0.498, m12: -0.284, m21: -0.742, m22: 0.3248, tX: 12, tY: 44)
]
func test_AffineTransform_JSON() {
@@ -198,16 +199,17 @@
// MARK: - CGAffineTransform
lazy var cg_affineTransformValues: [CGAffineTransform] = {
+ // FIXME: Comment the tests back in once rdar://problem/33363218 is in the SDK.
var values = [
CGAffineTransform.identity,
CGAffineTransform(),
CGAffineTransform(translationX: 2.0, y: 2.0),
CGAffineTransform(scaleX: 2.0, y: 2.0),
CGAffineTransform(a: 1.0, b: 2.5, c: 66.2, d: 40.2, tx: -5.5, ty: 3.7),
- CGAffineTransform(a: -55.66, b: 22.7, c: 1.5, d: 0.0, tx: -22, ty: -33),
+ // CGAffineTransform(a: -55.66, b: 22.7, c: 1.5, d: 0.0, tx: -22, ty: -33),
CGAffineTransform(a: 4.5, b: 1.1, c: 0.025, d: 0.077, tx: -0.55, ty: 33.2),
- CGAffineTransform(a: 7.0, b: -2.3, c: 6.7, d: 0.25, tx: 0.556, ty: 0.99),
- CGAffineTransform(a: 0.498, b: -0.284, c: -0.742, d: 0.3248, tx: 12, ty: 44)
+ // CGAffineTransform(a: 7.0, b: -2.3, c: 6.7, d: 0.25, tx: 0.556, ty: 0.99),
+ // CGAffineTransform(a: 0.498, b: -0.284, c: -0.742, d: 0.3248, tx: 12, ty: 44)
]
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
@@ -287,15 +289,16 @@
// MARK: - CGRect
lazy var cg_rectValues: [CGRect] = {
+ // FIXME: Comment the tests back in once rdar://problem/33363218 is in the SDK.
var values = [
CGRect.zero,
- CGRect.null,
+ // CGRect.null,
CGRect(x: 10, y: 20, width: 30, height: 40)
]
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
// Limit on magnitude in JSON. See rdar://problem/12717407
- values.append(CGRect.infinite)
+ // values.append(CGRect.infinite)
}
return values
@@ -315,9 +318,10 @@
// MARK: - CGVector
lazy var cg_vectorValues: [CGVector] = {
+ // FIXME: Comment the tests back in once rdar://problem/33363218 is in the SDK.
var values = [
CGVector.zero,
- CGVector(dx: 0.0, dy: -9.81)
+ // CGVector(dx: 0.0, dy: -9.81)
]
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
diff --git a/test/stdlib/MediaPlayer.swift b/test/stdlib/MediaPlayer.swift
new file mode 100644
index 0000000..597cd03
--- /dev/null
+++ b/test/stdlib/MediaPlayer.swift
@@ -0,0 +1,91 @@
+// RUN: %target-run-simple-swift
+// REQUIRES: executable_test
+// REQUIRES: objc_interop
+// REQUIRES: OS=ios
+
+import MediaPlayer
+import StdlibUnittest
+import StdlibUnittestFoundationExtras
+
+let MediaPlayerTests = TestSuite("MediaPlayer")
+
+MediaPlayerTests.test("decodablePlayParameters") {
+ if #available(iOS 11.0, *) {
+ let identifier = "1234567890"
+ let kind = "song"
+ let isLibrary = true
+ let playParamsData = """
+{
+ "id": "\(identifier)",
+ "kind": "\(kind)",
+ "isLibrary": \(isLibrary)
+}
+""".data(using: .utf8)!
+
+ do {
+ let decoder = JSONDecoder()
+ let playParameters = try decoder.decode(MPMusicPlayerPlayParameters.self, from: playParamsData)
+ let playParametersDictionary = playParameters.dictionary
+ expectEqual(identifier, playParametersDictionary["id"] as! String)
+ expectEqual(kind, playParametersDictionary["kind"] as! String)
+ expectEqual(isLibrary, playParametersDictionary["isLibrary"] as! Bool)
+ }
+ catch {
+ expectUnreachableCatch(error)
+ }
+ }
+}
+
+MediaPlayerTests.test("decodingInvalidPlayParameters") {
+ if #available(iOS 11.0, *) {
+ let invalidPlayParamsData = """
+{
+ "kind": "song"
+}
+""".data(using: .utf8)!
+
+ do {
+ let decoder = JSONDecoder()
+ let _ = try decoder.decode(MPMusicPlayerPlayParameters.self, from: invalidPlayParamsData)
+ expectUnreachable()
+ }
+ catch DecodingError.dataCorrupted(_) {}
+ catch {
+ expectUnreachableCatch(error)
+ }
+ }
+}
+
+
+MediaPlayerTests.test("encodablePlayParameters") {
+ if #available(iOS 11.0, *) {
+ let identifier = "1234567890"
+ let kind = "song"
+ let isLibrary = true
+ let correspondingPlayParamsString = """
+{"id":"\(identifier)","kind":"\(kind)","isLibrary":\(isLibrary)}
+"""
+
+ let playParametersDictionary: [String: Any] = [
+ "id": identifier,
+ "kind": kind,
+ "isLibrary": isLibrary
+ ]
+ guard let playParameters = MPMusicPlayerPlayParameters(dictionary: playParametersDictionary) else {
+ expectUnreachable()
+ return
+ }
+
+ do {
+ let encoder = JSONEncoder()
+ let encodedPlayParamsData = try encoder.encode(playParameters)
+ let encodedPlayParamsString = String(data: encodedPlayParamsData, encoding: .utf8)!
+ expectEqual(correspondingPlayParamsString, encodedPlayParamsString)
+ }
+ catch {
+ expectUnreachableCatch(error)
+ }
+ }
+}
+
+runAllTests()
diff --git a/validation-test/stdlib/AVFoundation.swift b/validation-test/stdlib/AVFoundation.swift
deleted file mode 100644
index 6fe6e1f..0000000
--- a/validation-test/stdlib/AVFoundation.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %target-run-simple-swift
-// REQUIRES: executable_test
-//
-// REQUIRES: OS=ios
-
-import StdlibUnittest
-
-
-import AVFoundation
-
-var AVFoundationTests = TestSuite("AVFoundation")
-
-if #available(iOS 11, *) {
- AVFoundationTests.test("AVCaptureSynchronizedDataCollection.makeIterator()") {
- func f(c: AVCaptureSynchronizedDataCollection) {
- for _ in c {}
- }
- }
-}
-
-runAllTests()
\ No newline at end of file
diff --git a/validation-test/stdlib/ModelIO.swift b/validation-test/stdlib/ModelIO.swift
index 815bab1..6272a35 100644
--- a/validation-test/stdlib/ModelIO.swift
+++ b/validation-test/stdlib/ModelIO.swift
@@ -11,28 +11,6 @@
var ModelIOTests = TestSuite("ModelIO")
if #available(OSX 10.13, iOS 11.0, tvOS 11.0, *) {
- ModelIOTests.test("MDLSkinDeformer.jointBindTransforms()") {
- let jointPaths = ["Aa", "Bb", "Cc"]
- let count = 3
- let jointTransforms = [matrix_float4x4](repeating: matrix_identity_float4x4, count: count)
- let meshBindTransform = matrix_identity_float4x4
- let skinDeformer = MDLSkinDeformer(jointPaths: jointPaths,
- jointBindTransforms: jointTransforms,
- count: count,
- meshBindTransform: meshBindTransform)
- let jointBindTransforms = skinDeformer.jointBindTransforms()
-
- expectEqual(jointBindTransforms.count, count)
- for (bindIdx, jointBindTransform) in jointBindTransforms.enumerated() {
- for idx in 0..<4 {
- expectEqual(jointBindTransform[idx].x, jointTransforms[bindIdx][idx].x)
- expectEqual(jointBindTransform[idx].y, jointTransforms[bindIdx][idx].y)
- expectEqual(jointBindTransform[idx].z, jointTransforms[bindIdx][idx].z)
- expectEqual(jointBindTransform[idx].w, jointTransforms[bindIdx][idx].w)
- }
- }
- }
-
ModelIOTests.test("MDLAnimatedScalar/accessors") {
let animatedVal = MDLAnimatedScalar()
let testCount = 10
@@ -40,37 +18,13 @@
let testFloatVal:Float = 1.0
let testDoubleVal = Double(testFloatVal)
let fArray = [Float](repeating: testFloatVal, count: testCount)
+ let dArray = [Double](repeating: testDoubleVal, count: testCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloatArray: fArray, atTimes: times, count: testCount)
-
- let floats = animatedVal.getFloatArray()
- let doubles = animatedVal.getDoubleArray()
- times = animatedVal.getTimes()
-
- expectEqual(floats.count, testCount)
- expectEqual(doubles.count, testCount)
- expectEqual(times.count, testCount)
-
- for idx in 0..<testCount {
- expectEqual(floats[idx], testFloatVal)
- expectEqual(doubles[idx], testDoubleVal)
- expectEqual(times[idx], testTimeVal)
- }
- }
-
- ModelIOTests.test("MDLAnimatedScalar/accessors") {
- let animatedVal = MDLAnimatedScalar()
- let testCount = 10
- let testTimeVal = 5.0
- let testFloatVal:Float = 1.0
- let testDoubleVal = Double(testFloatVal)
- let fArray = [Float](repeating: testFloatVal, count: testCount)
- var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloatArray: fArray, atTimes: times, count: testCount)
-
- let floats = animatedVal.getFloatArray()
- let doubles = animatedVal.getDoubleArray()
- times = animatedVal.getTimes()
+ animatedVal.reset(floatArray: fArray, atTimes: times)
+ let floats = animatedVal.floatArray
+ animatedVal.reset(doubleArray: dArray, atTimes: times)
+ let doubles = animatedVal.doubleArray
+ times = animatedVal.times
expectEqual(floats.count, testCount)
expectEqual(doubles.count, testCount)
@@ -90,12 +44,14 @@
let testFloatVal = float2(1.0, 2.0)
let testDoubleVal = double2(Double(testFloatVal.x), Double(testFloatVal.y))
let fArray = [float2](repeating: testFloatVal, count: testCount)
+ let dArray = [double2](repeating: testDoubleVal, count: testCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloat2Array: fArray, atTimes: times, count: testCount)
+ animatedVal.reset(float2Array: fArray, atTimes: times)
- let floats = animatedVal.getFloat2Array()
- let doubles = animatedVal.getDouble2Array()
- times = animatedVal.getTimes()
+ let floats = animatedVal.float2Array
+ animatedVal.reset(double2Array: dArray, atTimes: times)
+ let doubles = animatedVal.double2Array
+ times = animatedVal.times
expectEqual(floats.count, testCount)
expectEqual(doubles.count, testCount)
@@ -117,12 +73,14 @@
let testFloatVal = float3(1.0, 2.0, 3.0)
let testDoubleVal = double3(Double(testFloatVal.x), Double(testFloatVal.y), Double(testFloatVal.z))
let fArray = [float3](repeating: testFloatVal, count: testCount)
+ let dArray = [double3](repeating: testDoubleVal, count: testCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloat3Array: fArray, atTimes: times, count: testCount)
+ animatedVal.reset(float3Array: fArray, atTimes: times)
- let floats = animatedVal.getFloat3Array()
- let doubles = animatedVal.getDouble3Array()
- times = animatedVal.getTimes()
+ let floats = animatedVal.float3Array
+ animatedVal.reset(double3Array: dArray, atTimes: times)
+ let doubles = animatedVal.double3Array
+ times = animatedVal.times
expectEqual(floats.count, testCount)
expectEqual(doubles.count, testCount)
@@ -146,12 +104,14 @@
let testFloatVal = float4(1.0, 2.0, 3.0, 4.0)
let testDoubleVal = double4(Double(testFloatVal.x), Double(testFloatVal.y), Double(testFloatVal.z), Double(testFloatVal.w))
let fArray = [float4](repeating: testFloatVal, count: testCount)
+ let dArray = [double4](repeating: testDoubleVal, count: testCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloat4Array: fArray, atTimes: times, count: testCount)
+ animatedVal.reset(float4Array: fArray, atTimes: times)
- let floats = animatedVal.getFloat4Array()
- let doubles = animatedVal.getDouble4Array()
- times = animatedVal.getTimes()
+ let floats = animatedVal.float4Array
+ animatedVal.reset(double4Array: dArray, atTimes: times)
+ let doubles = animatedVal.double4Array
+ times = animatedVal.times
expectEqual(floats.count, testCount)
expectEqual(doubles.count, testCount)
@@ -177,12 +137,14 @@
let testFloatVal = matrix_identity_float4x4
let testDoubleVal = matrix_identity_double4x4
let fArray = [float4x4](repeating: testFloatVal, count: testCount)
+ let dArray = [double4x4](repeating: testDoubleVal, count: testCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(withFloat4x4Array: fArray, atTimes: times, count: testCount)
+ animatedVal.reset(float4x4Array: fArray, atTimes: times)
- let floats = animatedVal.getFloat4x4Array()
- let doubles = animatedVal.getDouble4x4Array()
- times = animatedVal.getTimes()
+ let floats = animatedVal.float4x4Array
+ animatedVal.reset(double4Array: dArray, atTimes: times)
+ let doubles = animatedVal.double4x4Array
+ times = animatedVal.times
expectEqual(floats.count, testCount)
expectEqual(doubles.count, testCount)
@@ -203,30 +165,157 @@
}
}
- ModelIOTests.test("MDLAnimatedScalarArray/accessors") {
- let elementsCount = 10
- let animatedVal = MDLAnimatedScalarArray(name: "test", elementsCount: elementsCount)
+ ModelIOTests.test("MDLMatrix4x4Array/accessors") {
let testCount = 10
- let totalCount = elementsCount * testCount
+ let matrixArray = MDLMatrix4x4Array(elementCount: testCount)
+ let testFloatVal = float4x4()
+ let testDoubleVal = double4x4()
+ let fArray = [float4x4](repeating: testFloatVal, count: testCount)
+ let dArray = [double4x4](repeating: testDoubleVal, count: testCount)
+ matrixArray.float4x4Array = fArray
+
+ let floats = matrixArray.float4x4Array
+ matrixArray.double4x4Array = dArray
+ let doubles = matrixArray.double4x4Array
+
+ expectEqual(floats.count, testCount)
+ expectEqual(doubles.count, testCount)
+
+ for idx in 0..<testCount {
+ for matIdx in 0..<4 {
+ expectEqual(floats[idx][matIdx].x, testFloatVal[matIdx].x)
+ expectEqual(floats[idx][matIdx].y, testFloatVal[matIdx].y)
+ expectEqual(floats[idx][matIdx].z, testFloatVal[matIdx].z)
+ expectEqual(floats[idx][matIdx].w, testFloatVal[matIdx].w)
+ expectEqual(doubles[idx][matIdx].x, testDoubleVal[matIdx].x)
+ expectEqual(doubles[idx][matIdx].y, testDoubleVal[matIdx].y)
+ expectEqual(doubles[idx][matIdx].z, testDoubleVal[matIdx].z)
+ expectEqual(doubles[idx][matIdx].w, testDoubleVal[matIdx].w)
+ }
+ }
+ }
+
+ ModelIOTests.test("MDLAnimatedScalarArray/accessors") {
+ let elementCount = 10
+ let animatedVal = MDLAnimatedScalarArray(elementCount: elementCount)
+ let subCount = 2
+ let testCount = 10
+ let totalCount = elementCount * testCount
let testTimeVal = 5.0
let testFloatVal:Float = 10.0
+ let testSubFloatVal:Float = 5.0
let testDoubleVal = Double(testFloatVal)
+ let testSubDoubleVal = Double(testSubFloatVal)
let fArray = [Float](repeating: testFloatVal, count: totalCount)
+ let _ = [Float](repeating: testSubFloatVal, count: subCount)
+ let dArray = [Double](repeating: testDoubleVal, count: totalCount)
+ let _ = [Double](repeating: testSubDoubleVal, count: subCount)
var times = [TimeInterval](repeating: testTimeVal, count: testCount)
- animatedVal.reset(with: fArray, count: totalCount, atTimes: times, count: testCount)
+ animatedVal.reset(floatArray: fArray, atTimes: times)
- let floats = animatedVal.getFloatArrays()
- let doubles = animatedVal.getDoubleArrays()
- times = animatedVal.getTimes()
+ let floats = animatedVal.floatArray
+ // reset is currently appending instead of resetting the time sampled data
+ //animatedVal.reset(doubleArray: dArray, atTimes: times)
+ let doubles = animatedVal.doubleArray
+ let sampledFloatArray = animatedVal.floatArray(atTime: 5.0)
+ let sampledDoubleArray = animatedVal.doubleArray(atTime: 5.0)
+ times = animatedVal.times
expectEqual(floats.count, totalCount)
expectEqual(doubles.count, totalCount)
expectEqual(times.count, testCount)
for idx in 0..<testCount {
- for arrIdx in 0..<elementsCount {
- expectEqual(floats[idx * elementsCount + arrIdx], testFloatVal)
- expectEqual(doubles[idx * elementsCount + arrIdx], testDoubleVal)
+ // -- test a sampled time
+ expectEqual(sampledFloatArray[idx], testFloatVal)
+ expectEqual(sampledDoubleArray[idx], testDoubleVal)
+
+ // -- for each time test the arrays
+ for arrIdx in 0..<elementCount {
+ expectEqual(floats[idx * elementCount + arrIdx], testFloatVal)
+ expectEqual(doubles[idx * elementCount + arrIdx], testDoubleVal)
+ }
+ expectEqual(times[idx], testTimeVal)
+ }
+ }
+
+ ModelIOTests.test("MDLAnimatedQuaternionArray/accessors") {
+ let elementCount = 10
+ let testCount = 10
+ let totalCount = elementCount * testCount
+ let animatedVal = MDLAnimatedQuaternionArray(elementCount: elementCount)
+ let testTimeVal = 5.0;
+ let testFloatVal = simd_quatf(ix: 1.0, iy: 2.0, iz: 3.0, r: 4.0)
+ let testDoubleVal = simd_quatd(ix: 1.0, iy: 2.0, iz: 3.0, r: 4.0)
+ let fArray = [simd_quatf](repeating: testFloatVal, count: totalCount)
+ let dArray = [simd_quatd](repeating: testDoubleVal, count: totalCount)
+ var times = [TimeInterval](repeating: testTimeVal, count: testCount)
+ animatedVal.reset(floatQuaternionArray: fArray, atTimes: times)
+
+ let quatFloats = animatedVal.floatQuaternionArray
+ // reset is appending instead of reseting the time sampled data
+ //animatedVal.reset(doubleQuaternionArray: dArray, atTimes: times)
+ let quatDoubles = animatedVal.doubleQuaternionArray
+ let sampledFloatQuaternionArray = animatedVal.floatQuaternionArray(atTime: 5.0)
+ let sampledDoubleQuaternionArray = animatedVal.doubleQuaternionArray(atTime: 5.0)
+ times = animatedVal.times
+
+ expectEqual(quatFloats.count, totalCount)
+ expectEqual(quatDoubles.count, totalCount)
+ expectEqual(times.count, testCount)
+
+ for idx in 0..<testCount {
+ // -- test a sampled time
+ // -- data gets swizzled somewhere between getting and setting so we just
+ // -- check to make sure we can at least access the data
+ sampledFloatQuaternionArray[idx]
+ sampledDoubleQuaternionArray[idx]
+ /*expectEqual(sampledFloatQuaternionArray[idx], testFloatVal)
+ expectEqual(sampledDoubleQuaternionArray[idx], testDoubleVal)
+
+ // -- for each time test the arrays
+ for arrIdx in 0..<elementCount {
+ expectEqual(quatFloats[idx * elementCount + arrIdx], testFloatVal)
+ expectEqual(quatDoubles[idx * elementCount + arrIdx], testDoubleVal)
+ }*/
+ expectEqual(times[idx], testTimeVal)
+ }
+ }
+
+ ModelIOTests.test("MDLAnimatedVector3Array/accessors") {
+ let elementCount = 10
+ let animatedVal = MDLAnimatedVector3Array(elementCount: elementCount)
+ let testCount = 10
+ let totalCount = elementCount * testCount
+ let testTimeVal = 5.0
+ let testFloatVal = float3(1.0, 2.0, 3.0)
+ let testDoubleVal = double3(1.0, 2.0, 3.0)
+ let fArray = [float3](repeating: testFloatVal, count: totalCount)
+ let dArray = [double3](repeating: testDoubleVal, count: totalCount)
+ var times = [TimeInterval](repeating: testTimeVal, count: testCount)
+ animatedVal.reset(float3Array: fArray, atTimes: times)
+
+ let vector3Floats = animatedVal.float3Array
+ // reset is appending instead reseting the time sampled data
+ //animatedVal.reset(double3Array: dArray, atTimes: times)
+ let vector3Doubles = animatedVal.double3Array
+ let sampledFloatVector3Array = animatedVal.float3Array(atTime: 5.0)
+ let sampledDoubleVector3Array = animatedVal.double3Array(atTime: 5.0)
+ times = animatedVal.times
+
+ expectEqual(vector3Floats.count, totalCount)
+ expectEqual(vector3Doubles.count, totalCount)
+ expectEqual(times.count, testCount)
+
+ for idx in 0..<testCount {
+ // -- test a sampled time
+ expectEqual(sampledFloatVector3Array[idx], testFloatVal)
+ expectEqual(sampledDoubleVector3Array[idx], testDoubleVal)
+
+ // -- for each time test the arrays
+ for arrIdx in 0..<elementCount {
+ expectEqual(vector3Floats[idx * elementCount + arrIdx], testFloatVal)
+ expectEqual(vector3Doubles[idx * elementCount + arrIdx], testDoubleVal)
}
expectEqual(times[idx], testTimeVal)
}
diff --git a/validation-test/stdlib/XCTest.swift b/validation-test/stdlib/XCTest.swift
index da6dda6..59d683e 100644
--- a/validation-test/stdlib/XCTest.swift
+++ b/validation-test/stdlib/XCTest.swift
@@ -1,4 +1,7 @@
-// RUN: %target-run-stdlib-swift
+// RUN: rm -rf %t ; mkdir -p %t
+// RUN: %target-build-swift %s -o %t/a.out3 -swift-version 3 && %target-run %t/a.out3
+// RUN: %target-build-swift %s -o %t/a.out4 -swift-version 4 && %target-run %t/a.out4
+
// REQUIRES: executable_test
// REQUIRES: objc_interop
@@ -20,20 +23,35 @@
func execute(observers: [XCTestObservation] = [], _ run: () -> Void) {
for observer in observers {
+#if swift(>=4.0)
+ XCTestObservationCenter.shared.addTestObserver(observer)
+#else
XCTestObservationCenter.shared().addTestObserver(observer)
+#endif
+
}
run()
for observer in observers {
+#if swift(>=4.0)
+ XCTestObservationCenter.shared.removeTestObserver(observer)
+#else
XCTestObservationCenter.shared().removeTestObserver(observer)
+#endif
}
}
class FailureDescriptionObserver: NSObject, XCTestObservation {
var failureDescription: String?
- func testCase(_ testCase: XCTestCase, didFailWithDescription description: String, inFile filePath: String?, atLine lineNumber: UInt) {
+#if swift(>=4.0)
+ typealias LineNumber=Int
+#else
+ typealias LineNumber=UInt
+#endif
+
+ func testCase(_ testCase: XCTestCase, didFailWithDescription description: String, inFile filePath: String?, atLine lineNumber: LineNumber) {
failureDescription = description
}
}
@@ -463,7 +481,7 @@
XCTestTestSuite.test("XCTContext/runActivity(named:block:)") {
class RunActivityTestCase: XCTestCase {
- dynamic func test_noThrow() {
+ dynamic func test_noThrow_void() {
var blockCalled = false
XCTContext.runActivity(named: "noThrow") { activity in
blockCalled = true
@@ -471,6 +489,16 @@
expectTrue(blockCalled)
}
+ dynamic func test_noThrow_returns_string() {
+ var blockCalled = false
+ let value = XCTContext.runActivity(named: "noThrow") { activity -> String in
+ blockCalled = true
+ return "Activities can return values now!"
+ }
+ expectEqual(value, "Activities can return values now!")
+ expectTrue(blockCalled)
+ }
+
dynamic func test_throwing() {
var blockCalled = false
var catchCalled = false
@@ -488,6 +516,25 @@
}
}
+#if os(macOS)
+if #available(macOS 10.11, *) {
+ XCTestTestSuite.test("XCUIElement/typeKey(_:modifierFlags:)") {
+ class TypeKeyTestCase: XCTestCase {
+ func testTypeKey() {
+ #if swift(>=4.0)
+ XCUIApplication().typeKey("a", modifierFlags: [])
+ XCUIApplication().typeKey(.delete, modifierFlags: [])
+ #else
+ XCUIApplication().typeKey("a", modifierFlags: [])
+ XCUIApplication().typeKey(XCUIKeyboardKeyDelete, modifierFlags: [])
+ #endif
+ }
+ }
+ }
+}
+#endif
+
runAllTests()
+