Files
swift-mirror/test/decl/protocol/conforms/Inputs/placement_2.swift
Joe Groff 6d9a40f455 Sema: Treat the implicit RawRepresentable conformance for enums as Synthesized again.
This reverts part of #4038 which made the compiler consider it to be an `Explicit` conformance, breaking source code that was accepted in Swift 3.0 which declared a raw type as well as explicit conformance to `RawRepresentable` (reported as rdar://problem/30386658). While I'm here, a couple of spot fixes:

- Ensure an enum's raw value exprs are type-checked before checking conformances of any of its extensions, since the RawRepresentable conformance derivation will blow up if the raw value exprs haven't been checked. Fixes an order dependency issue if `extension Foo: RawRepresentable {}` gets checked before `enum Foo: Int { ... }`.
- Don't display the custom `enum_declares_rawrep_with_raw_type` diagnostic if the source location for the enum's inheritance clause is invalid, so that we don't emit a dislocated diagnostic.
2017-02-08 15:31:17 -08:00

45 lines
1.7 KiB
Swift

// ---------------------------------------------------------------------------
// Multiple explicit conformances to the same protocol
// ---------------------------------------------------------------------------
extension MFExplicit1 : P1 { }
struct MFExplicit2 : P1 { } // expected-note{{'MFExplicit2' declares conformance to protocol 'P1' here}}
// ---------------------------------------------------------------------------
// Multiple implicit conformances, with no ambiguities
// ---------------------------------------------------------------------------
struct MFMultipleImplicit1 : P2a { }
struct MFMultipleImplicit3 : P4 { }
struct MFMultipleImplicit4 : P4 { }
struct MFMultipleImplicit5 : P2a { }
// ---------------------------------------------------------------------------
// Explicit conformances conflicting with inherited conformances
// ---------------------------------------------------------------------------
class MFExplicitSub1 : ImplicitSuper1 { } // expected-note{{'MFExplicitSub1' inherits conformance to protocol 'P1' from superclass here}}
// ---------------------------------------------------------------------------
// Suppression of synthesized conformances
// ---------------------------------------------------------------------------
extension MFSynthesizedClass1 : AnyObject { }
class MFSynthesizedClass2 { }
class MFSynthesizedClass3 : AnyObjectRefinement { }
class MFSynthesizedSubClass2 : MFSynthesizedClass2 { } // expected-note{{'MFSynthesizedSubClass2' inherits conformance to protocol 'AnyObject' from superclass here}}
class MFSynthesizedSubClass3 : MFSynthesizedClass1 { }
extension MFSynthesizedSubClass4 : AnyObjectRefinement { }
enum MFSynthesizedEnum1 : Int { case a }
extension MFSynthesizedEnum2 : RawRepresentable { }