Skip to content

Commit f8ffa08

Browse files
committed
---
yaml --- r: 347455 b: refs/heads/master c: 2ae0ebc h: refs/heads/master i: 347453: f4ea297 347451: 384251f 347447: ef08211 347439: df24e56 347423: 678c49d 347391: 15a21f2
1 parent 29c1f31 commit f8ffa08

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 67c4211041515506fa70eaf5acfae9ecaae72c25
2+
refs/heads/master: 2ae0ebc49cff1da15b1e6e3c0653e5d3f7a0d176
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ class Verifier : public ASTWalker {
18191819

18201820
// The base of a member reference cannot be an existential type.
18211821
if (E->getBase()->getType()->getWithoutSpecifierType()
1822-
->isAnyExistentialType()) {
1822+
->isExistentialType()) {
18231823
Out << "Member reference into an unopened existential type\n";
18241824
E->dump(Out);
18251825
Out << "\n";

trunk/lib/Sema/CSApply.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,10 @@ namespace {
811811
// Figure out the actual base type, and whether we have an instance of
812812
// that type or its metatype.
813813
bool baseIsInstance = true;
814+
bool isExistentialMetatype = false;
814815
if (auto baseMeta = baseTy->getAs<AnyMetatypeType>()) {
815816
baseIsInstance = false;
817+
isExistentialMetatype = baseMeta->is<ExistentialMetatypeType>();
816818
baseTy = baseMeta->getInstanceType();
817819
}
818820

@@ -900,11 +902,15 @@ namespace {
900902
base, selfParamTy, member, semantics,
901903
locator.withPathElement(ConstraintLocator::MemberRefBase));
902904
} else {
903-
// Convert the base to an rvalue of the appropriate metatype.
904-
base = coerceToType(base,
905-
MetatypeType::get(isDynamic ? selfTy : containerTy),
906-
locator.withPathElement(
907-
ConstraintLocator::MemberRefBase));
905+
if (!isExistentialMetatype || openedExistential) {
906+
// Convert the base to an rvalue of the appropriate metatype.
907+
base = coerceToType(base,
908+
MetatypeType::get(
909+
isDynamic ? selfTy : containerTy),
910+
locator.withPathElement(
911+
ConstraintLocator::MemberRefBase));
912+
}
913+
908914
if (!base)
909915
return nullptr;
910916

trunk/test/Constraints/protocols.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ protocol P : Initable {
107107
func bar(_ x: Int)
108108
mutating func mut(_ x: Int)
109109
static func tum()
110+
111+
typealias E = Int
112+
typealias F = Self.E
110113
}
111114

112115
protocol ClassP : class {
@@ -216,6 +219,13 @@ func staticExistential(_ p: P.Type, pp: P.Protocol) {
216219
// Static member of metatype -- not allowed
217220
_ = pp.tum // expected-error{{static member 'tum' cannot be used on protocol metatype 'P.Protocol'}}
218221
_ = P.tum // expected-error{{static member 'tum' cannot be used on protocol metatype 'P.Protocol'}}
222+
223+
// Access typealias through protocol and existential metatypes
224+
_ = pp.E.self
225+
_ = p.E.self
226+
227+
_ = pp.F.self
228+
_ = p.F.self
219229
}
220230

221231
protocol StaticP {

0 commit comments

Comments
 (0)