Files
swift-mirror/validation-test/Serialization/rdar29694978.swift
Jordan Rose 97b06445e3 Always desugar the base type of an extension when serializing. (#6336)
This "fixes" two issues:

- The name of a non-public typealias would leak into the public
  interface if the extension had any public members.

- A common pattern of defining a platform-specific typealias for an
  imported class and then extending that type would lead to
  circularity when trying to deserialize the typealias. We /shouldn't/
  be loading the extension at that point, but fixing that would be
  much harder.

The "right" answer is to (a) check that the typealias is public if the
extension has any public members, and (b) somehow ensure there is no
circularity issue (either by not importing the extension as a result
of importing the typealias, or by the extension being able to set its
sugared base type later).

rdar://problem/29694978
2016-12-19 16:44:35 -08:00

29 lines
1.3 KiB
Swift

// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/rdar29694978.h -emit-module -o %t/Library.swiftmodule
// RUN: %target-swift-ide-test -print-module -module-to-print=Library -source-filename=x -I %S/Inputs/ -I %t | %FileCheck %s
// REQUIRES: objc_interop
// This would be wonderful to fold into a larger test, but I'm worried that
// trying to do so would perturb the original conditions that cause it to
// crash: deserializing a typealias (1) to an imported Objective-C type (2)
// that has a protocol (3) that refines another protocol (4) which causes us
// to load all extensions, including one defined in this file (5) in terms of
// the original typealias (1).
//
// It's probably best to just leave this test about that.
import Foundation
// CHECK-DAG: typealias MyNonGenericType = NonGenericType
typealias MyNonGenericType = NonGenericType
// CHECK-DAG: extension NonGenericType
extension MyNonGenericType {}
// CHECK-DAG: typealias MyGenericType<T> = GenericType<T>
typealias MyGenericType<T: NSObject> = GenericType<T>
// CHECK-DAG: extension GenericType where Element : AnyObject
extension MyGenericType {}
// CHECK-DAG: extension GenericType where Element == NSObject
extension MyGenericType where Element == NSObject {}