Skip to content

Commit d1b753c

Browse files
committed
Sema: Remove a workaround for an accessibility problem in the standard library
1 parent 10598af commit d1b753c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,9 +2268,7 @@ void ConformanceChecker::recordTypeWitness(AssociatedTypeDecl *assocType,
22682268
aliasDecl->getAliasType()->setRecursiveProperties(
22692269
type->getRecursiveProperties());
22702270

2271-
Type interfaceTy = aliasDecl->getAliasType();
2272-
if (interfaceTy->hasArchetype())
2273-
interfaceTy = ArchetypeBuilder::mapTypeOutOfContext(DC, type);
2271+
auto interfaceTy = DC->mapTypeOutOfContext(aliasDecl->getAliasType());
22742272
aliasDecl->setInterfaceType(MetatypeType::get(interfaceTy));
22752273

22762274
aliasDecl->setImplicit();

stdlib/public/core/Arrays.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ extension ${Self} {
17691769
public mutating func replaceSubrange<C>(
17701770
_ subrange: Range<Int>,
17711771
with newElements: C
1772-
) where C : Collection, C.Iterator.Element == _Buffer.Element {
1772+
) where C : Collection, C.Iterator.Element == Element {
17731773
% if Self in ['Array', 'ContiguousArray']:
17741774
_precondition(subrange.lowerBound >= self._buffer.startIndex,
17751775
"${Self} replace: subrange start is negative")
@@ -2289,7 +2289,7 @@ extension ${Self} {
22892289
public mutating func replaceRange<C>(
22902290
_ subRange: Range<Int>,
22912291
with newElements: C
2292-
) where C : Collection, C.Iterator.Element == _Buffer.Element {
2292+
) where C : Collection, C.Iterator.Element == Element {
22932293
Builtin.unreachable()
22942294
}
22952295

test/Sema/accessibility.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,21 @@ internal struct AssocTypeOuterProblem2 {
637637
fileprivate typealias Assoc = Int // expected-error {{type alias 'Assoc' must be as accessible as its enclosing type because it matches a requirement in protocol 'AssocTypeProto'}} {{5-16=internal}}
638638
}
639639
}
640+
641+
// This code was accepted in Swift 3
642+
public protocol P {
643+
associatedtype Element
644+
645+
func f() -> Element
646+
}
647+
648+
struct S<T> : P {
649+
func f() -> T { while true {} }
650+
}
651+
652+
public struct G<T> {
653+
typealias A = S<T> // expected-note {{type declared here}}
654+
655+
public func foo<U : P>(u: U) where U.Element == A.Element {}
656+
// expected-error@-1 {{instance method cannot be declared public because its generic requirement uses an internal type}}
657+
}

0 commit comments

Comments
 (0)