mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Make sure the destination type actually conforms to the corresponding builtin literal protocol before attempting to import it. We may want to consider allowing any type that conforms to the non-builtin literal protocol, but I want to keep this patch low risk and just ensure we at least don't crash for now. rdar://156524292
29 lines
955 B
Swift
29 lines
955 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
// RUN: %target-swift-frontend -typecheck -verify %t/main.swift -I %t -verify-additional-file %t/cmodule.h
|
|
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: OS=macosx
|
|
|
|
//--- cmodule.h
|
|
#import <CoreGraphics/CoreGraphics.h>
|
|
#define intLiteralCGFloat ((CGFloat)0)
|
|
// expected-note@-1 {{invalid numeric literal}}
|
|
// expected-note@-2 {{macro 'intLiteralCGFloat' unavailable (cannot import)}}
|
|
#define floatLiteralCGFloat ((CGFloat)0.0)
|
|
// expected-note@-1 {{invalid numeric literal}}
|
|
// expected-note@-2 {{macro 'floatLiteralCGFloat' unavailable (cannot import)}}
|
|
|
|
//--- module.modulemap
|
|
module CModule [system] {
|
|
header "cmodule.h"
|
|
export *
|
|
}
|
|
|
|
//--- main.swift
|
|
import CModule
|
|
|
|
// Make sure we don't crash when attempting to import these.
|
|
_ = intLiteralCGFloat // expected-error {{cannot find 'intLiteralCGFloat' in scope}}
|
|
_ = floatLiteralCGFloat // expected-error {{cannot find 'floatLiteralCGFloat' in scope}}
|