Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0126-sr5905.swift
Doug Gregor 8b58b0dbb4 [Type checker] Make redeclaration checking validate fewer declarations.
Redeclaration checking was validating all declarations with the same
base name as the given declaration (and in the same general nominal
type), even when it was trivial to determine that the declarations
could not be conflicting. Separate out the easy structural checks
(based on kind, full name, instance vs. non-instance member, etc.) and
perform those first, before validation.

Fixes SR-6558, a case where redeclaration checking caused some
unnecessary recursion in the type checker.
2017-12-30 23:27:04 -08:00

29 lines
864 B
Swift

// RUN: %target-swift-frontend %s -emit-ir -o /dev/null
protocol VectorIndex {
associatedtype Vector8 : Vector where Vector8.Index == Self, Vector8.Element == UInt8
}
enum VectorIndex1 : VectorIndex {
case i0
typealias Vector8 = Vector1<UInt8>
}
protocol Vector {
associatedtype Index: VectorIndex
associatedtype Element
init(elementForIndex: (Index) -> Element)
subscript(index: Index) -> Element { get set }
}
struct Vector1<Element> : Vector {
//typealias Index = VectorIndex1 // Uncomment this line to workaround bug.
var e0: Element
init(elementForIndex: (VectorIndex1) -> Element) {
e0 = elementForIndex(.i0)
}
subscript(index: Index) -> Element {
get { return e0 }
set { e0 = newValue }
}
}
extension Vector where Index == VectorIndex1 {
init(_ e0: Element) { fatalError() }
}