diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 2e41a0cbd6aa6..444c1a202e1a3 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -3487,8 +3487,6 @@ TypeBase::getContextSubstitutions(const DeclContext *dc, if (auto *ownerClass = dyn_cast(ownerNominal)) baseTy = baseTy->getSuperclassForDecl(ownerClass); - assert(ownerNominal == baseTy->getAnyNominal()); - // Gather all of the substitutions for all levels of generic arguments. auto genericSig = dc->getGenericSignatureOfContext(); if (!genericSig) @@ -3498,6 +3496,9 @@ TypeBase::getContextSubstitutions(const DeclContext *dc, unsigned n = params.size(); while (baseTy && n > 0) { + if (baseTy->is()) + break; + // For a bound generic type, gather the generic parameter -> generic // argument substitutions. if (auto boundGeneric = baseTy->getAs()) { diff --git a/stdlib/public/core/Array.swift b/stdlib/public/core/Array.swift index 44260a599c5cf..866c5815b2c6a 100644 --- a/stdlib/public/core/Array.swift +++ b/stdlib/public/core/Array.swift @@ -1911,54 +1911,50 @@ internal struct _ArrayAnyHashableBox } // SWIFT_ENABLE_TENSORFLOW -extension Array where Element : Differentiable { +// TODO(TF-938): Add 'Element : Differentiable' constraint. +extension Array { /// The view of an array as the differentiable product manifold of `Element` /// multiplied with itself `count` times. @frozen - public struct DifferentiableView : Differentiable { - private var _base: [Element] - - /// The viewed array. - // I'm implementing this as a computed property instead of directly - // exposing `_base` because the `@differentiable` annotation does not make - // the stored property actually differentiable. I think this is a bug. - // Maybe it's related to `@frozen`? - // TODO: Determine if that is a bug, and fix. - public var base: [Element] { - @differentiable(wrt: self, vjp: _vjpBase) - get { return _base } - _modify { yield &_base } - } + public struct DifferentiableView { + var _base: [Element] + } +} - @usableFromInline - func _vjpBase() -> - ([Element], (Array.TangentVector) -> TangentVector) { - return (base, { $0 }) - } +extension Array.DifferentiableView : Differentiable where Element : Differentiable { + /// The viewed array. + public var base: [Element] { + @differentiable(wrt: self, vjp: _vjpBase) + get { return _base } + _modify { yield &_base } + } - /// Creates a differentiable view of the given array. - @differentiable(wrt: base, vjp: _vjpInit) - public init(_ base: [Element]) { self._base = base } + @usableFromInline + func _vjpBase() -> + ([Element], (Array.TangentVector) -> TangentVector) { + return (base, { $0 }) + } - @usableFromInline - static func _vjpInit(_ base: [Element]) -> - (Array.DifferentiableView, (TangentVector) -> TangentVector) { - return (Array.DifferentiableView(base), { $0 }) - } + /// Creates a differentiable view of the given array. + @differentiable(wrt: base, vjp: _vjpInit) + public init(_ base: [Element]) { self._base = base } - // MARK: - Differentiable conformance. + @usableFromInline + static func _vjpInit(_ base: [Element]) -> + (Array.DifferentiableView, (TangentVector) -> TangentVector) { + return (Array.DifferentiableView(base), { $0 }) + } - public typealias TangentVector = - Array.DifferentiableView + public typealias TangentVector = + Array.DifferentiableView - public mutating func move(along direction: TangentVector) { - precondition( - base.count == direction.base.count, - "cannot move Array.DifferentiableView with count \(base.count) along " + - "direction with different count \(direction.base.count)") - for i in base.indices { - base[i].move(along: direction.base[i]) - } + public mutating func move(along direction: TangentVector) { + precondition( + base.count == direction.base.count, + "cannot move Array.DifferentiableView with count \(base.count) along " + + "direction with different count \(direction.base.count)") + for i in base.indices { + base[i].move(along: direction.base[i]) } } } diff --git a/stdlib/public/core/KeyPathIterable.swift b/stdlib/public/core/KeyPathIterable.swift index bd674fcd32f25..8ad9268bd790f 100644 --- a/stdlib/public/core/KeyPathIterable.swift +++ b/stdlib/public/core/KeyPathIterable.swift @@ -104,13 +104,20 @@ extension Array : KeyPathIterable { } } -extension Array.DifferentiableView : KeyPathIterable { +// TODO(TF-938): Remove 'Element : Differentiable' constraint. +extension Array.DifferentiableView : KeyPathIterable where Element : Differentiable { public typealias AllKeyPaths = [PartialKeyPath] public var allKeyPaths: [PartialKeyPath] { return [\Array.DifferentiableView.base] } } +// TODO(TF-938): Remove this. +// This is neccessary now because otherwise the compiler complains: +// error: conditional conformance of type 'Array.DifferentiableView' to protocol +// 'KeyPathIterable' does not imply conformance to inherited protocol '_KeyPathIterableBase' +extension Array.DifferentiableView : _KeyPathIterableBase where Element : Differentiable {} + extension Dictionary : KeyPathIterable { public typealias AllKeyPaths = [PartialKeyPath] public var allKeyPaths: [PartialKeyPath] { diff --git a/utils/update_checkout/update-checkout-config.json b/utils/update_checkout/update-checkout-config.json index 2e89fc5e7387e..06e52f8dccbbd 100644 --- a/utils/update_checkout/update-checkout-config.json +++ b/utils/update_checkout/update-checkout-config.json @@ -489,7 +489,7 @@ "clang-tools-extra": "swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a", "libcxx": "swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a", "tensorflow": "7c7d924821a8b1b20433c2f3f484bbd409873a84", - "tensorflow-swift-apis": "f4f88d924d71eedb0709e26d0d5e4b7cfe94d830", + "tensorflow-swift-apis": "e70b979b7a3c2ebd38457b8d4058a0b310b4e4b0", "tensorflow-swift-quote": "62c0a88dc64a201497a66cbbc087c0c7771edabc", "indexstore-db": "swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a", "sourcekit-lsp": "swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a" diff --git a/validation-test/ParseableInterface/verify_all_overlays.py b/validation-test/ParseableInterface/verify_all_overlays.py index ffb76a2c9df0d..4cfbf5b2f2d3c 100755 --- a/validation-test/ParseableInterface/verify_all_overlays.py +++ b/validation-test/ParseableInterface/verify_all_overlays.py @@ -50,7 +50,8 @@ continue # SWIFT_ENABLE_TENSORFLOW - # FIXME(TF-489): Re-enable this test after fixing `.swiftinterface` errors. + # TODO(TF-939): Enable this on DifferentiationUnittest, Python, and + # TensorFlow. if module_name in ["Swift", "SwiftLang", "DifferentiationUnittest", "Python", "TensorFlow"]: continue diff --git a/validation-test/ParseableInterface/verify_stdlib.swift b/validation-test/ParseableInterface/verify_stdlib.swift index d34c2a21474d8..9b4e1da91e176 100644 --- a/validation-test/ParseableInterface/verify_stdlib.swift +++ b/validation-test/ParseableInterface/verify_stdlib.swift @@ -1,10 +1,6 @@ // Note that this test should still "pass" when Swift.swiftinterface has not // been generated. -// SWIFT_ENABLE_TENSORFLOW -// FIXME(TF-489): Re-enable this test after fixing `.swiftinterface` errors. -// UNSUPPORTED: nonexecutable_test - // RUN: %empty-directory(%t) // RUN: not ls %platform-module-dir/Swift.swiftmodule/%target-cpu.swiftinterface || %target-swift-frontend -build-module-from-parseable-interface %platform-module-dir/Swift.swiftmodule/%target-cpu.swiftinterface -parse-stdlib -o %t/Swift.swiftmodule