Files
swift-mirror/test/decl/protocol/conforms/nscoding_availability_osx.swift
Doug Gregor 587cd4e463 Suppress inference of @_staticInitializeObjCMetadata for "newer" classes.
If a class was introduced in an OS newer than the deployment target,
suppress the inference of @_staticInitializeObjCMetadata, because
the resulting eager initialization will crash when run on older OS's.
This is a stop-gap solution; we want the eager initialization code to
check availability before registering the class, but that requires more
effort.

Fixes the main part of SR-6203 / rdar://problem/35161939.
2017-10-25 17:05:11 -07:00

23 lines
770 B
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target x86_64-apple-macosx10.11 -verify
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target x86_64-apple-macosx10.11 -dump-ast 2> %t.ast
// RUN: %FileCheck %s < %t.ast
// REQUIRES: objc_interop
// REQUIRES: OS=macosx
import Foundation
// Nested classes that aren't available in our deployment target.
@available(OSX 10.12, *)
class CodingI : NSObject, NSCoding {
required init(coder: NSCoder) { }
func encode(coder: NSCoder) { }
}
@available(OSX 10.12, *)
class OuterCodingJ {
// CHECK-NOT: class_decl "NestedJ"{{.*}}@_staticInitializeObjCMetadata
class NestedJ : CodingI { }
}