New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Update trailingZeroBitCount
documentation
#24713
Conversation
Document the required behavior for `trailingZeroBitCount` when the value is zero. Namely, in that scenario, `trailingZeroBitCount` should be equal to `bitWidth`.
stdlib/public/core/Integers.swift
Outdated
@@ -716,6 +716,9 @@ public protocol BinaryInteger : | |||
/// let x = Int8(bitPattern: 0b1111_1000) | |||
/// // x == -8 | |||
/// // x.trailingZeroBitCount == 3 | |||
/// | |||
/// If there are no bits equal to 1 in this value's binary representation, | |||
/// then `trailingZeroBitCount` is equal to `bitWidth`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "If this value is zero, then trailingZeroBitCount
is bitWidth
." ("no bits equal to 1" feels like we're trying to leave some loophole for other ways this could happen, but really we just mean zero.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the wording here. Currently, the protocol imposes no requirements on the actual binary representation of integer values. If we guarantee (0 as T).trailingZeroBitCount == (0 as T).bitWidth
, then we are adding a requirement about the binary representation of zero--which is fine, but worth remarking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these properties are defined in terms of a twos-complement representation. Even if your type secretly does something else internally, the result is what you would get for twos-complement.
I.e. even if you secretly use sign-magnitude internally, .trailingZeroBitCount
of -0 should be .bitWidth
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But bitWidth
would then be the actual bit width and not that of the two's-complement representation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, bitWidth should also be the bitWidth of the two’s complement representation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I'd been under the impression that a subset of methods (operators, words
, etc.) specifically called for the two's-complement representation while another subset (bitWidth
principally) dealt with the actual binary representation. Not sure why I'd been thinking that.
Should |
@Azoy leadingZeroBitCount doesn’t exist for non-fixed-width types, so it’s less of an issue, but sure. |
@swift-ci smoke test |
@natecook1000 I'm merging this, but please still review. We can make further changes if you want. |
* Test: Add a test exercising expressions with an immutable base * Sema: Changed name of isInsideCall to isCallArgument and formatted changes * Sema: Change isImmutable to isMutable (thanks De Morgan) and negated call * [stdlib] Set.Sequence unittest explicit annotation Use explicit type annotation to make it crystal clear (beyoud any reasonable doubt) these are indeed testing the Sequence variants. * stubs: configure flags based on SDK target Due to the custom build system implemented in CMake for Swift, we cannot properly detect the target and set flags appropriately. Instead, assume that if the primary variant is an Apple target, that all targets are Apple variants. This fixes cross-compilation on macOS. * Sema: Get constraint locator for TupleExpr inside ApplyExpr branch Additionally has some other minor cleanup. * [Runtime] Add a test for +class and +self overrides. rdar://problem/49853091 * Don’t use isRequirementSignatureComputed because it is lazy * Intro Evaluator::hasActiveRequest to prevent request cycles * Avoid cycles when computing a requirement signature Replace most remaining uses of isRequirementSignatureComputed by isRequirementSignatureComputing which uses Evaluator::hasActiveRequest to detect if the requirements are currently being computed. * Test: Add tests for .init called on mutable value inside operator * Canonicalize stores in the CanonicalizeInstruction utility. This is the complement to load canonicalization. Although store canonicalization is not required before diagnostics, it should be defined in the same utility. * [cmake] Ensure swiftReflection is built for tools Some tools link against swiftReflection, so we should ensure it's built when we're building the tools. * Revert "Enable ExistentialSpecializer by default" * Drop @inline(__always) from Accelerate overlay; it doesn't do what you want. (apple#24641) @inline(__always) does not imply inlinable, which means that it effectively does nothing in the context of the Accelerate overlay. I have replaced all of these with @inlinable where that can be done as a one-line change. Functions that switch over open enums and more complex API (DCT, DFT, FFT) will require more sophisticated corrections, which we can undertake in later commits. For now, they have been rolled back to simply being normal public API. * [silgen] Always ensure that we have a +1 value when emitting reabstraction thunks. The machinery assumes that it will always have a +1 value. I am attempting to do the minimal fix here for cherry-picking purposes. There isn't a test case with this commit since the immutable address verifier (in the next commit) verifies that this is done correctly. The specific test that will trip is vtable_thunks_reabstraction.swift. rdar://50212579 * Also apply @inlinable to AccelerateBuffer default implementations. * Move strange interpolation fix to PreCheckExpression This defers diagnosis until a stage where #if conditions have definitely been evaluated, at the cost of a slightly more complex implementation. We’ll gain some of that complexity back in a subsequent refactoring. Fixes SR-9937. * [Parse] Parse string interpolations as args Now that we manipulate the argument list to correct strange interpolations in Sema, we can parse interpolations directly as argument lists, simplifying the parser. By itself, this refactoring causes a code completion regression; a subsequent commit will fix that. * [AST] Give appendInterpolation refs a SourceLoc This change permits UnresolvedDotExpr to have both a name and a base that are implicit, but a valid DotLoc, and to treat that DotLoc as the node’s location. It then changes the generation of string interpolation code so that `$stringInterpolation.appendInterpolation` references have a DotLoc corresponding to the backslash in the string literal. This makes it possible for `ExprContextAnalyzer` in IDE to correctly detect when you are code-completing in a string interpolation and treat it as an `appendInterpolation` call. * [AliasAnalysis] Check for nullptr before dereferencing. Fixes an undefined behaviour sanitizer bug. <rdar://problem/50641097> * Sema / Test: Fix misplaced fix-it for .init calls on instances * Add a PrettyStackTrace for SILInliner::inlineFunction (apple#24658) * build: correct flags for Windows build Adjust the preprocessor macros to get correct DLL Storage for imported functions. This should help identify cases of incorrect linkage to msvcrt/ucrt. * Update LibraryEvolution.rst for new attribute names * Add Windows build status on README * XFAIL ParsableInterface/verify_all_overlays.py rdar://problem/50648519 * [sil] Expand immutable address verification to in_guaranteed parameters. rdar://50212579 * [sil-combine] Do not perform existential type propagation on @in parameters when we have a copy of the underlying value. Otherwise, we may get use-after-frees as in the added test. rdar://50609145 * [IRGen] Remove unused explosion schema from enum payload schema At some point it might be useful to be able to use an appropriate explosion schema to explode payloads but currently the code that handles this is unused. There are lots of different ways we might add this functionality in the future and it isn't clear that the existing code will be the best way to use explosion schemas in the future. For now remove this dead code so that its presence doesn't obscure the code that is actually in use. * [Runtime] Use a #define for the value of swift_isaMask. This allows _swift_getClassOfAllocated to use a constant instead of loading from a global, and allows swift_isaMask to be computed without a static initializer. Debug builds verify that the #define matches the value from libobjc. rdar://problem/22375602 rdar://problem/46385113 * [Test] Delete ErrorBridgedStatic test. This test checks that error bridging with ObjC bridging works when the stdlib is statically linked. We no longer support static linking of the stdlib on platforms with ObjC interop. rdar://problem/49699316 * Remove DelayedRequirementSignatures and rely on laziness instead Because we create requirement signatures lazily, we don't need to force a full validateDecl of ProtocolDecls in this way anymore. * [SourceKit] Add InterfaceGen test case for pure Swift system module rdar://problem/50458412 * [windows] Add build script for Windows. This is a build script for Windows, intended for CI, not really for final users. The script mixes bits from WindowsBuild.md, and the Azure YAML script. It only builds up to libdispatch, including LLDB. If more products are ready, we can improve the script, but keeping in mind this should be a temporary solution. The script needs a couple of environment variables from the build machine (the Python installation path and the type of build), and also needs Visual Studio tools in path and its environment variables. Besides that, it should be self-contained. * minor fixes * [Test] Guard SwiftNativeNSXXXCoding tests behind #available(9999). These tests fail when run against older runtimes since they don't have the fix. rdar://problem/50504800 * Fix archive_attributes test to work on macOS 10.9 That OS doesn't have objc_readClassPair(). This test uses -target to explicitly select a newer deployment target and then runs the binary on an old OS to test the behavior. However this means arclite won't get linked in unless we also pass in -link-objc-runtime. Fixes <rdar://problem/50610877>. * [stdlib] Revise collection difference documentation (apple#24675) * Revise CollectionDifference documentation. * GSB: Remove another call to resolveDeclSignature() The GSB should avoid triggering declaration validation where possible, to avoid problems resulting from circularity and as a general performance rule-of-thumb. This last call was there to catch self-recursive protocol typealiases. However, we can diagnose this problem elsewhere, which allows us to emit a more accurate diagnostic as well. * AST: Simplify ProtocolConformanceRef::getTypeWitnessByName() * AST: Add ParamDecl::toFunctionParam() * AST: Remove ProtocolConformanceRef::getInheritedConformanceRef() * [benchmark] Set.Seq showcase optimized early exits * [android] Modify lit replacement of module-target-triple for ARMv7 Android ARMv7 has an LLVM triple of armv7-none-linux-androideabi, but the Swift module triple is just armv7-node-linux-android. The change removes the "eabi" bit for the %module-target-triple substitution of lit to avoid an error in the test test/SourceKit/CursorInfo/cursor_swiftonly_systemmodule.swift. Android AArch64 wasn't affected because the LLVM triple for it is just aarch64-none-linux-android. * docs: fix doc build error in LibraryEvolution.rst * Disable Prototypes/TextFormatting in 32-bit The new ImmutableAddressUseVerifier asserts when it tries to compile it. rdar://problem/50676315 * [Runtime] In the assert for SWIFT_ISA_MASK, tolerate it if objc_debug_isa_class_mask is not available. rdar://problem/50674635 * [android] Add a test for Android conditional compilation (AArch64) There are similar tests for other architectures/OS pairs, but android-aarch64 was missing. This should ensure that the conditional compilation for Android works correctly in this case. * [benchmark] Set.subtracting.Seq increased workload The workload multipliers need to be increased in order to accommodate the pending improvements from `lorentey:set-on-fire`, so that these benchmark don't drop to under 20 μs runtimes when those optimizations kick in. These multiplier will differ from those used on Set.subtracting.Set by a factor of 5. * [Build System: CMake] Cleanup the StandaloneOveraly CMake module. Preconditions have been moved to the top of the file. All the variables set have been grouped by kind and a few converted to cache variables for better control when building. This should cut down on merge-conflicts as well." * [Build System: CMake] Add CMake module paths before importing in StandaloneOverlay.cmake. * Disable Prototypes/TextFormatting everywhere * Runtime: Don't try to register class stubs on older objc runtimes This will allow us to emit class stubs unconditionally, rather than checking the -enable-resilient-objc-class-stubs flag. Part of <rdar://problem/49090631>. * IRGen: Always emit class stubs for classes with resilient ancestry This logic is no longer guarded by a flag. Sema will still emit certain diagnostics if the flag is not specified though. Progress on <rdar://problem/49090631>. * Revert "[SourceKit] Add InterfaceGen test case for pure Swift system module" * Serialization: use the mangled class name for serializing vtables. To distinguish between classes which have the same name (but are in different contexts). Fixes a miscompile if classes with the same name are used from a different module. SR-10634 rdar://problem/50538534 * [sil] Change the immutable address use verifier to ignore br/cond_br uses that introduce address phis and re-enable the test that shows this behavior. We want to eventually remove address phi arguments from SIL. This will enable all sorts of nice IRGen optimizations and in general make life better. We are not there yet, but given that is the direction we are going in, I don't think there is much use in having to implement this sort of checking for SIL phi arguments. rdar://50676315 * [sil] When the immutable address use verifier errors due to an unknown instruction, print the instruction to improve debuggability. * Consolidate StringInterpolationExpr to StringLiteralExpr * Use StringLiteralExpr node if it's a single literal segment * Use StringLiteralExpr for invalid InterpolatedStringLiteralExpr * [benchmark] Disable tests with overlong runtime Temporarily disable benchmarks that run for too long without optimizations pending in set-on-fire branch. * Fixing let var warnings on CheckCollectionInstance.swift * [CodeCompletion] Allow ErrorType in constructor Even if the constructor has `ErrorType` we can suggest it as long as it's `FunctionType`. rdar://problem/49480808 * [docs] Update `trailingZeroBitCount` documentation (apple#24713) * [docs] Update `trailingZeroBitCount` documentation Document the required behavior for `trailingZeroBitCount` when the value is zero. Namely, in that scenario, `trailingZeroBitCount` should be equal to `bitWidth`. * [docs] Address reviewer comments on `trailingZeroBitCount` docs * Bump compiler version to Swift 5.1 (apple#24671) * Bump version to Swift 5.1 * Update tests with compiler version bump * Undo flatMap and math obsolescences * Fix to make minimum AST nodes for StringLiteralExpr * Revert removal of invalid interpolation check * [Runtime] Don't check objc_debug_isa_class_mask when back deploying. Older OSes may not have this value or may have a different value. We only want to check going forward, because newer runtimes don't run on older OSes except in certain testing scenarios. rdar://problem/50700856 * [Serialization] Retire "shadowed module" in favor of "underlying" (apple#24711) Similar to 517f5d6, the "shadowed" terminology didn't end up describing the most common use of the feature; there is pretty much no intended case where a Swift module shadows a Clang module without also re-exporting it. Switch to "underlying", which was already in use in a few places, and which better parallels "overlay". No intended functionality change. * [SourceKit] Add InterfaceGen test case for pure Swift system module rdar://problem/50458412 (Reapply - Forgot to add `-target` in SourceKit test in previous change.) * Reduce the Stack Size of ConstraintSystem The ConstraintSystem class is on the order of 1000s of bytes in size on the stacka nd is causing issues with dispatch's 64k stack limit. This changes most Small data types which store data on the stack to non small heap based data types. * [api-digester] Remove whitespace changes * [build-script] Introduce ProductBuilder. Transform Ninja to use it. ProductBuilder allows us to tackle the different way than the different products need to be build. The builders follow a very simple interface, but inside them the details are hidden. Previously the Ninja product was both a Product and ProductBuilder. The methods that did the build have moved into ProductBuilder to match the future ProductBuilders. * [ModuleInterface] Pass -Rmodule-interface-rebuild to sub-invocation (apple#24737) Previously, we wouldn't pass this flag to sub-invocations, which means that if we had to fall back and recompile a transitive import, we wouldn't get a remark. rdar://50729662 * [Serialization] Drop inherited conformances on classes (apple#23347) These can be recreated if needed in a client library. To do this, I've added a new ConformanceLookupKind::NonInherited, which can also be used elsewhere in the project where we're already filtering out inherited conformances some other way. Note that this doesn't drop inherited conformances from the entire serialized interface, just from the list that a class explicitly declares. They still get referenced sometimes. rdar://problem/50541451 and possibly others * AST: Make ConstructorDecl::getInitializerInterfaceType() more forgiving of invalid code * Sema: Build type checked bodies for trivial accessors This includes all synthesized accessors except for lazy getters and observer setters. Building checked AST has certain advantages: - It is faster, avoiding the need to create and solve ConstraintSystems or performing various diagnostic and semantic walks over the AST. - It allows us to postpone delayed body synthesis until needed in SILGen, instead of having to walk a list of "external declarations" in Sema. It also unblocks lazier conformance checking. Now that SILGen can trigger conformance checking on its own, we need to be able to synthesize bodies of accessors that witness protocol requirements. This will allow us to eventually remove Sema's "used conformances" list. Note that for now, various utility functions in CodeSynthesis.cpp are used for both checked and unchecked function bodies, so they take a 'typeChecked' boolean parameter that complicates some logic more than necessary. Once the remaining body synthesizers are refactored to build type-checked AST, the 'typeChecked' flag will go away. * Sema: Move the Optional-typed nil peephole to SILGen When applying a solution to a nil literal of Optional type, we would build a direct reference to Optional<T>.none instead of leaving the NilLiteralExpr in place, because this would generate more efficient SIL that avoided the call to the Optional(nilLiteral: ()) witness. However, a few places in the type checker build type-checked AST, and they build NilLiteralExpr directly. Moving the peephole to SILGen's lowering of NilLiteralExpr allows us to simplify generated SIL even further by eliding an unnecessary metatype value. Furthermore, it allows SILGen to accept NilLiteralExprs that do not have a ConcreteDeclRef set, which makes type-checked AST easier to build. * Sema: Build type checked bodies for designated init overrides Similarly to trivial accessors, the body of a synthesized designated initializer override is simple enough that we can build it directly without involving the constraint solver. * [code-completion] Handle nested keypath dynamic lookup correctly If the root type of the KeyPath also has dynamic member lookup, we need to look through it. rdar://problem/50450037 * [windows] Make build-windows.bat use CRLF endings. Seems that Batch files need to use CRLF endings or the labels sometimes does not work. * [Build System: CMake] Add missing SWIFT_STDLIB_LIBRARY_TYPES to the StandaloneOverlay.cmake module. * Add doc comments to the new lookupVisible* functions * Consume toke for string literal expr in a better way Fix incorrect indent * Cache struct/class field offsets in SIL. The field's ordinal value is used by the Projection abstraction, which is the basis of efficiently comparing and sorting access paths in SIL. It must be cached before it is used by any SIL passes, including the verifier, or it causes widespread quadratic complexity. Fixes <rdar://problem/50353228> Swift compile time regression with optimizations enabled In production code, a file that was taking 40 minutes to compile now takes 1 minute, with more than half of the time in LLVM. Here's a short script that reproduces the problem. It used to take 30s and now takes 0.06s: // swift genlazyinit.swift > lazyinit.sil // sil-opt ./lazyinit.sil --access-enforcement-opts var NumProperties = 300 print(""" sil_stage canonical import Builtin import Swift import SwiftShims public class LazyProperties { """) for i in 0..<NumProperties { print(""" // public lazy var i\(i): Int { get set } @_hasStorage @_hasInitialValue final var __lazy_storage__i\(i): Int? { get set } """) } print(""" } // LazyProperties.init() sil @$s4lazy14LazyPropertiesCACycfc : $@convention(method) (@owned LazyProperties) -> @owned LazyProperties { bb0(%0 : $LazyProperties): %enum = enum $Optional<Int>, #Optional.none!enumelt """) for i in 0..<NumProperties { let adr = (i*4) + 2 let access = adr + 1 print(""" %\(adr) = ref_element_addr %0 : $LazyProperties, #LazyProperties.__lazy_storage__i\(i) %\(access) = begin_access [modify] [dynamic] %\(adr) : $*Optional<Int> store %enum to %\(access) : $*Optional<Int> end_access %\(access) : $*Optional<Int> """) } print(""" return %0 : $LazyProperties } // end sil function '$s4lazy14LazyPropertiesCACycfc' """) * Add scale-test --save-temps option. I'm not sure how anyone debugs these tests otherwise. * Add a scale-test for VarDecl::getStoredProperties. Adds a NumStoredPropertiesQueries stat. Adds a test case for an increasing number of lazy stored class properties. Each property requires a formal access within the initializer. This would manifest as cubic behavior in AccessEnforcementOpts, which scales as O(1.5) in the above stat. * [Build System: CMake] Set the install_name_dir to @rpath for the SwiftLang module in SourceKit. * test: make test paths more portable Windows uses `\` as the separator rather than `/`. Adjust the tests for this. * [SIL Optimization] Add a mandatory optimization pass for optimizing the new os log APIs based on string interpolation. * [ModuleInterface] Propagate availability for synthesized extensions (apple#24753) Otherwise, we can synthesize an extension that's extending a type that's unavailable on a particular platform, or that conforms to a protocol that hasn't been introduced on the minimum deployment target. * IRGen: Fix DynamicSelfType metadata recovery in @objc convenience initializers An @objc convenience initializer can replace 'self'. Since IRGen has no way to tell what the new 'self' value is from looking at SIL, it always refers back to the original 'self' argument when recovering DynamicSelfType metadata. This could cause a crash if the metadata was used after the 'self' value had been replaced. To fix the crash, always insert the metadata recovery into the entry block, where the 'self' value should be valid (even if uninitialized, the 'isa' pointer should be correct). Fixes <rdar://problem/50594689>. * IRGen: Remove IRBuilder::StableIP * [Runtime] Adjust to conforming type when instantiating witness table. When we find a protocol conformance descriptor for a given type, make sure we adjust to the conforming type of that descriptor (following the superclass chain as needed) before instantiating the witness table. Fixes rdar://problem/49741838. * Add regression test that opaque underlying type checking does not look in closures * Switch from using deprecated float3-style names to SIMD3<Float> in overlays. (apple#24743) * Fix LICM debug output typo. * Remove RefElementAddr field from AccessedStorage. - code simplification critical for comprehension - substantially improves the overhead of AccessedStorage comparison - as a side effect improves precision of analysis in some cases AccessedStorage is meant to be an immutable value type that identifies a storage location with minimal representation. It is used in many global interprocedural data structures. The RefElementAddress instruction that it was derived from does not contribute to the uniqueness of the storage location. It doesn't belong here. It was being used to create a ProjectionPath, which is an extremely inneficient way to compare access paths. Just delete all the code related to that extra field. * Intro a request to lazily compute default definition types The new request, DefaultDefinitionTypeRequest, is triggered by calling AssociatedTypeDecl::getDefaultDefinitionType. * api-digester: remove node comparison cache because it may consume too much memory * api-digester: disable objc interop when building on linux. SR-10539 * [Windows] Add initial implementation for TaskQueue * [Const Evaluator] Fix a minor bug in the copy constructor deletion of `ConstExprStepEvaluator`. * [Test] Add runtime 9999-availability check for a new test in Swift 5.1 The testEncodingMultipleNestedContainersWithTheSameTopLevelKey check is new in Swift 5.1 and will not pass when running with a 5.0 stdlib. rdar://problem/50151131 * Replace AccessedStorage projection with an index. Further simplify AccessedStorage. Shrink it to two words. Remove the Projection abstraction and streamline the projection logic. * Update ARCOptimization.rst (apple#24724) * Update ARCOptimization.rst * Update ARCOptimization.rst * benchmark: NIOChannelPipeline imitation adds a benchmark that imitates SwiftNIO's ChannelPipeline. Recently, Swift master regressed on this benchmark, therefore I believe adding it to Swift provides value as it seems to be different enough to the existing benchmarks. * Update .mailmap * api-digester: use target triple to check platform info * Update NIOChannelPipeline.swift * cmake: specify only one component toolchain-tools for swift-api-digester * Revert "[SIL Optimization] Add a mandatory pass for optimizing the new os log APIs based on string interpolation." * api-digester: diagnose adding conformances to existing protocols. rdar://48131686 * Simplify swift::getInheritedForPrinting to take a PrintOptions This lets us make some more assumptions in the next commit, but I think it's also just a nice cleanup to /not/ allow random predicates here. There were three callers of this API: - PrintAST, which was using PrintOptions::shouldPrint but /also/ incorrectly notifying listeners that a declaration would be skipped. - (IDE) Interface generation, which uses PrintOptions::shouldPrint to count how many "inherits" there will be. - SwiftDocSupport's reportRelated, which does no filtering at all. Creating a PrintOptions here is a little more expensive, but still. No intended functionality change. * Don't print extensions to conform to protocols that aren't printed Try a little harder to avoid printing empty extensions by seeing if any of the inherited protocols are actually going to be printed. Previously this just made things a little prettier, but with implementation-only imports it's a correctness issue, since there may be extensions of implementation-only types that do in fact conform to non-public protocols. rdar://problem/50748072 * Sema: Build type checked bodies for observer setters * Sema: Use an 'if let' instead of a hasValue/! in lazy property getter We used to generate this: let tmp1 = storage if tmp1.hasValue { return tmp1! } Instead we now generate this: if let tmp1 = storage { return tmp1 } * Sema: Fold Solution::convertOptionalToBool() into its only remaining caller * Sema: Check warning messages in test/Compatibility/attr_override_lazy.swift * Sema: Build type checked bodies for lazy getters * Sema: Remove support code for building non-type checked accessors * AST: ProtocolConformanceRef::getTypeWitnessByName() should be an instance method * Add tests and validate Data and DispatchData as sequences * [ConstraintSystem] Detect and diagnose conversion failures related to collection element types Detect and diagnose a contextual mismatch between expected collection element type and the one provided (e.g. source of the assignment or argument to a call) e.g.: ```swift let _: [Int] = ["hello"] func foo(_: [Int]) {} foo(["hello"]) ``` * [SIL Optimization] Add a mandatory optimization pass for optimizing the new os log APIs based on string interpolation. * AST: Add ProtocolConformanceRef::getWitnessByName() * Add @_disfavoredOverload attribute to affect overload resolution. Introduce an attribute @_disfavoredOverload that can be used to state that a particular declaration should be avoided if there is a successful type-check for a non-@_disfavoredOverload. It's a way to nudge overload resolution away from particular solutions. * [libSyntax] Represent raw string delimiters * Revert "[Foundation] Fix availability of NSValue.value(of:)" * Deprecate nearbyint and rint on CGFloat (apple#24784) These functions have never actually been supported in Swift, because Swift does not model the dynamic floating point environment. They may have worked occasionally in the past, but that was only accidental. Deprecate them with an explanatory message. * vim: highlight `lazy` `lazy` can modify the `var` definition. Add that as a modifier. * [ASTMangler] Mangle nested imported error structs correctly Error structs synthesized by ClangImporter can be renamed using SWIFT_NAME() to syntactically appear anywhere in the type hierarchy with any name, but they should always be mangled as `__C_Synthesized.related decl ‘e’ of <Objective-C enum name>`. Unforunately, when SWIFT_NAME() was used to nest the error struct inside another type, an ASTMangler bug would cause it to be mangled as `<parent type>.related decl ‘e’ of <Objective-C enum name>`, and an ASTDemangler bug would also require a valid parent type. This created a mismatch between the compiler’s and runtime’s manglings which caused crashes when you tried to match the imported error struct in a `catch`. This PR corrects the compiler bugs so that it generates the mangling the runtime expects. This is theoretically ABI-breaking, but as far as I can determine nobody has shipped the incorrectly mangled names, presumably because they crash when you try to use them. Fixes <rdar://problem/48040880>. * Opaque types require a newer Swift runtime. Check the availability of decls that declare an opaque return type to ensure they deploy to a runtime that supports opaque types. rdar://problem/50731151 * Added missing Linux POSIX errors * [CodeCompletion] Enable context type analysis for implict member expression At argument part of implict member expression, we need context type analysis to complete arguments. rdar://problem/50696432 * [silgen] Change ManagedValue::copyInto to have same paramter order as ManagedValue::{forward,assign}Into. ManagedValue::{forward,assign}Into both have the signature SILGenFunction &, SILLocation, SILValue. For some reason copyInto has SILLocation and SILValue swapped. This commit standardizes copyInto to match the others. * Sema: Fix 'for ... in ...' over a sequence of DynamicSelfType * Sema: Simplify for ... in ... type checking * [ConstraintSystem] Improve contextual mismatch diagnostics for `for ... in <expr>` loop * Driver: use `-Xlinker` rather than `-Wl` (NFC) This is just nicer to read and makes the option standout better. NFC. * [Type checker] Fix assertion/spin with ill-formed property delegate initialization Fixes rdar://problem/50822051. * api-digester: avoid looking up node update table to collect renamed declarations We could simply get the new name from the node annotation of the decl before renaming. * [CodeCompletion] Enable call signature completion for unresolved member rdar://problem/50696432 * [CodeCompletion] Look through ApplyExpr to get referenced decl For example: let x: MyClass = .create(<#COMPLETE#>) This expression ends up with: (call_expr (dot_syntax_self_apply_expr (decl_ref_expr decl='C.create(_:arg1)' (type_expr type=MyClass)))) So we need to look through 'DotSyntaxSelfApplyExpr' to get the decl. * [CodeCompletion] Add test cases for call arg completion Static methods, implicit member.
Document the required behavior for
trailingZeroBitCount
when the value is zero. Namely, in that scenario,trailingZeroBitCount
should be equal tobitWidth
.Resolves SR-10657.