Skip to content

Commit dd2e348

Browse files
committed
Add a test case for AST verification of loaded modules in WMO.
Prior to the following commit, the SILVerifier will assert on this test case. PR: 14250 <#14250> commit deebe8b Author: Andrew Trick <[email protected]> Date: Mon Jan 29 15:22:28 2018 performTypeChecking: Defer verifyAllLoadedModules in WMO mode.
1 parent 8246d9c commit dd2e348

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Cocoa
2+
extension Notification.Name {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty swift source file.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: %target-swift-frontend -swift-version 4 -emit-module -o %t/rdar36801676.swiftmodule %S/Inputs/rdar36801676.swift
4+
// RUN: %target-swift-frontend -swift-version 4 -emit-silgen -enable-objc-interop -I %t -emit-silgen %S/Inputs/rdar36801676_empty.swift %s | %FileCheck %s
5+
// REQUIRES: OS=macosx
6+
7+
// If AST loaded module verification is run after type checking the empty source
8+
// file (rdar36801676_empty.swift), but before type checking this source file,
9+
// then the importer caches the declaration for PasteboardType's constructor
10+
// without synthesizing it's body. Eventually, the SILVerifier will raise a linkage error:
11+
// SIL verification failed: external declarations of SILFunctions with shared
12+
// visibility is not allowed: SingleFunction ||
13+
// !hasSharedVisibility(RefF->getLinkage()) || RefF->hasForeignBody()
14+
15+
import Cocoa
16+
import rdar36801676
17+
18+
let objCSynthesizedEnum = NSPasteboard.PasteboardType(rawValue: "MyPboardType")
19+
extension Notification.Name {}
20+
21+
// NSPasteboardType.init(rawValue:)
22+
// - just make sure it has a body.
23+
// CHECK-LABEL: sil shared [transparent] [serializable] @$SSo16NSPasteboardTypea8rawValueABSS_tcfC : $@convention(method) (@owned String, @thin NSPasteboard.PasteboardType.Type) -> @owned NSPasteboard.PasteboardType {
24+
// CHECK: bb0(%0 : $String, %1 : $@thin NSPasteboard.PasteboardType.Type):
25+
// CHECK: return %{{.*}} : $NSPasteboard.PasteboardType
26+
// CHECK-LABEL: } // end sil function '$SSo16NSPasteboardTypea8rawValueABSS_tcfC'

0 commit comments

Comments
 (0)