// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -DREVERSED %s

// REQUIRES: objc_interop

// Do not import Foundation! This tests indirect visibility.
#if REVERSED
import Redeclaration
import AppKit
#else
import AppKit
import Redeclaration
#endif

let encoding: UInt = NSUTF8StringEncoding

let viaTypedef: Redeclaration.NSPoint = AppKit.NSPoint(x: 0, y: 0)
Redeclaration.NSStringToNSString(AppKit.NSStringToNSString("abc")) // expected-warning {{result of call to 'NSStringToNSString' is unused}}

/// The following error should soon be introduced by https://github.com/apple/llvm-project/pull/3497.
let viaStruct: Redeclaration.FooStruct1 = AppKit.FooStruct1() // expected-error * {{module 'AppKit' has no member named 'FooStruct1'}}
let forwardDecl: Redeclaration.Tribool = AppKit.Tribool() // expected-error {{no type named 'Tribool' in module 'Redeclaration'}}

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -DREVERSED %s

// REQUIRES: objc_interop

// Do not import Foundation! This tests indirect visibility.
#if REVERSED
import Redeclaration
import AppKit
#else
import AppKit
import Redeclaration
#endif

let encoding: UInt = NSUTF8StringEncoding

let viaTypedef: Redeclaration.NSPoint = AppKit.NSPoint(x: 0, y: 0)
Redeclaration.NSStringToNSString(AppKit.NSStringToNSString("abc")) // expected-warning {{result of call to 'NSStringToNSString' is unused}}

let viaStruct: Redeclaration.FooStruct1 = AppKit.FooStruct1()
let forwardDecl: Redeclaration.Tribool = AppKit.Tribool() // expected-error {{no type named 'Tribool' in module 'Redeclaration'}}

Revert "[ClangImporter] Don't expect unmodularized structs to appear in 2 modules"
Revert "[ClangImporter] Don't expect unmodularized structs to appear in 2 modules"

This reverts commit c8c3f9b67ef7d2c7f0764d9b6da1e05189361ada.

With `isThisDeclarationADemotedDefinition` flag we expect the same
struct to be available in multiple modules.
