Skip to content

Commit acd6099

Browse files
authored
---
yaml --- r: 335831 b: refs/heads/rxwei-patch-1 c: 3ce5a8a h: refs/heads/master i: 335829: 9c92fb0 335827: 22b6005 335823: d4825b1
1 parent 012a0bb commit acd6099

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 3d7123e6136a0954de307b7f3a5a9324d8266431
1018+
refs/heads/rxwei-patch-1: 3ce5a8a74d140348381f339146387c07397a5e71
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/lib/Sema/TypeCheckType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,10 @@ static Type diagnoseUnknownType(TypeResolution resolution,
10631063
AbstractFunctionDecl *methodDecl = dc->getInnermostMethodContext();
10641064
bool declaringMethod = methodDecl &&
10651065
methodDecl->getDeclContext() == dc->getParentForLookup();
1066+
bool isPropertyOfClass = insideClass &&
1067+
options.is(TypeResolverContext::PatternBindingDecl);
10661068

1067-
if (((!insideClass || !declaringMethod) &&
1069+
if (((!insideClass || !declaringMethod) && !isPropertyOfClass &&
10681070
!options.is(TypeResolverContext::GenericRequirement)) ||
10691071
options.is(TypeResolverContext::ExplicitCastExpr)) {
10701072
Type SelfType = nominal->getSelfInterfaceType();

branches/rxwei-patch-1/test/Index/Store/output-failure.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: mkdir %t/idx
3+
// UNSUPPORTED: OS=windows-msvc
34

45
// Before indexing, do a dry-run to ensure any clang modules are cached. We
56
// want to isolate the error that comes from swift's indexing support, not

branches/rxwei-patch-1/test/type/self.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ class A<T> {
7070
// expected-warning@-1 {{conditional cast from 'Self' to 'Self' always succeeds}}
7171
// expected-warning@-2 {{conditional downcast from 'Self?' to 'A<T>' is equivalent to an implicit conversion to an optional 'A<T>'}}
7272
}
73+
func copy() -> Self {
74+
let copy = Self.init(a: 11)
75+
return copy
76+
}
77+
78+
var copied: Self { // expected-error {{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'A'?}}
79+
let copy = Self.init(a: 11)
80+
return copy
81+
}
7382
}
7483

7584
class B: A<Int> {
@@ -88,6 +97,14 @@ class B: A<Int> {
8897
override class func y() {
8998
print("override \(Self.self).\(#function)")
9099
}
100+
override func copy() -> Self {
101+
let copy = super.copy() as! Self // supported
102+
return copy
103+
}
104+
override var copied: Self { // expected-error {{'Self' is only available in a protocol or as the result of a method in a class; did you mean 'B'?}}
105+
let copy = super.copied as! Self // unsupported
106+
return copy
107+
}
91108
}
92109

93110
class C {
@@ -121,6 +138,15 @@ struct S2 {
121138
// expected-warning@-1 {{conditional cast from 'S2.S3<T>' to 'S2.S3<T>' always succeeds}}
122139
}
123140
}
141+
func copy() -> Self {
142+
let copy = Self.init()
143+
return copy
144+
}
145+
146+
var copied: Self {
147+
let copy = Self.init()
148+
return copy
149+
}
124150
}
125151

126152
extension S2 {

0 commit comments

Comments
 (0)