Skip to content

Commit d3abe34

Browse files
Merge branch 'master' of https://github.com/apple/swift into SR-11295-warning-unecessary-casts
2 parents 48fdd58 + 40e5924 commit d3abe34

File tree

9 files changed

+80
-41
lines changed

9 files changed

+80
-41
lines changed

docs/WindowsBuild.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ Visual Studio 2017 or newer is needed to build swift on Windows.
2222
1. Clone `apple/swift-lldb` into a folder named `lldb`
2323
1. Clone `apple/swift-llbuild` into a folder named `llbuild`
2424
1. Clone `apple/swift-package-manager` info a folder named `swift-package-manager`
25-
1. Clone `curl` into a folder named `curl`
26-
1. Clone `libxml2` into a folder named `libxml2`
2725

28-
- Currently, other repositories in the Swift project have not been tested and
29-
may not be supported.
26+
- Currently, other repositories in the Swift project have not been tested and may not be supported.
3027

3128
This guide assumes your sources live at the root of `S:`. If your sources live elsewhere, you can create a substitution for this:
3229

@@ -47,8 +44,6 @@ git clone https://github.com/apple/swift-corelibs-xctest
4744
git clone https://github.com/apple/swift-lldb lldb
4845
git clone https://github.com/apple/swift-llbuild llbuild
4946
git clone -c core.autocrlf=input https://github.com/apple/swift-package-manager
50-
git clone https://github.com/curl/curl.git
51-
git clone https://gitlab.gnome.org/GNOME/libxml2.git
5247
```
5348

5449
## 3. Acquire ICU, SQLite3, curl, libxml2
@@ -183,7 +178,7 @@ cmake -G Ninja^
183178
-DClang_DIR="S:/b/llvm/lib/cmake/clang"^
184179
-DSwift_DIR="S:/b/swift/lib/cmake/swift"^
185180
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
186-
-DLLDB_ALLOW_STATIC_BINDINGS=YES^
181+
-DLLDB_USE_STATIC_BINDINGS=YES^
187182
-DLLVM_ENABLE_ASSERTIONS=ON^
188183
-DPYTHON_HOME="%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64"^
189184
S:\lldb

lib/AST/Type.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,8 +3572,6 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
35723572
if (auto *ownerClass = dyn_cast<ClassDecl>(ownerNominal))
35733573
baseTy = baseTy->getSuperclassForDecl(ownerClass);
35743574

3575-
assert(ownerNominal == baseTy->getAnyNominal());
3576-
35773575
// Gather all of the substitutions for all levels of generic arguments.
35783576
auto genericSig = dc->getGenericSignatureOfContext();
35793577
if (!genericSig)
@@ -3583,6 +3581,9 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
35833581
unsigned n = params.size();
35843582

35853583
while (baseTy && n > 0) {
3584+
if (baseTy->is<ErrorType>())
3585+
break;
3586+
35863587
// For a bound generic type, gather the generic parameter -> generic
35873588
// argument substitutions.
35883589
if (auto boundGeneric = baseTy->getAs<BoundGenericType>()) {

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,16 @@ Type swift::getMemberTypeForComparison(ASTContext &ctx, ValueDecl *member,
7777
SubscriptDecl *subscript = dyn_cast_or_null<SubscriptDecl>(abstractStorage);
7878

7979
auto memberType = member->getInterfaceType();
80+
if (memberType->is<ErrorType>())
81+
return memberType;
82+
8083
if (derivedDecl) {
8184
auto *dc = derivedDecl->getDeclContext();
8285
auto owningType = dc->getDeclaredInterfaceType();
8386
assert(owningType);
8487

8588
memberType = owningType->adjustSuperclassMemberDeclType(member, derivedDecl,
8689
memberType);
87-
if (memberType->hasError())
88-
return memberType;
8990
}
9091

9192
if (method) {

test/SILGen/default_arguments.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,9 @@ func stupidGames(x: Int = 3) -> Int {
383383
return x
384384
}
385385
stupidGames(x:)()
386+
387+
func genericMagic<T : ExpressibleByStringLiteral>(x: T = #file) -> T {
388+
return x
389+
}
390+
391+
let _: String = genericMagic()

test/decl/circularity.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,32 @@ extension SIMD3 {
5555
extension SIMD3 where SIMD3.Scalar == Float {
5656
static let pickMe = SIMD3(.pickMe)
5757
}
58+
59+
// Test case with circular overrides
60+
protocol P {
61+
associatedtype A
62+
// expected-note@-1 {{protocol requires nested type 'A'; do you want to add it?}}
63+
func run(a: A)
64+
}
65+
66+
class C1 {
67+
func run(a: Int) {}
68+
}
69+
70+
class C2: C1, P {
71+
override func run(a: A) {}
72+
// expected-error@-1 {{circular reference}}
73+
// expected-note@-2 2{{through reference here}}
74+
}
75+
76+
// Another crash to the above
77+
open class G1<A> {
78+
open func run(a: A) {}
79+
}
80+
81+
class C3: G1<A>, P {
82+
// expected-error@-1 {{type 'C3' does not conform to protocol 'P'}}
83+
// expected-error@-2 {{use of undeclared type 'A'}}
84+
override func run(a: A) {}
85+
// expected-error@-1 {{method does not override any method from its superclass}}
86+
}

utils/build-script

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,40 @@ class BuildScriptInvocation(object):
132132
"--legacy-impl is incompatible with building packages needing "
133133
"a toolchain (%s)" % ", ".join(targets_needing_toolchain))
134134

135+
@staticmethod
136+
def default_stdlib_deployment_targets(args):
137+
"""
138+
Return targets for the Swift stdlib, based on the build machine.
139+
If the build machine is not one of the recognized ones, return None.
140+
"""
141+
142+
host_target = StdlibDeploymentTarget.host_target()
143+
if host_target is None:
144+
return None
145+
146+
# OS X build machines configure all Darwin platforms by default.
147+
# Put iOS native targets last so that we test them last
148+
# (it takes a long time).
149+
if host_target == StdlibDeploymentTarget.OSX.x86_64:
150+
targets = [host_target]
151+
if args.build_ios and args.build_ios_simulator:
152+
targets.extend(StdlibDeploymentTarget.iOSSimulator.targets)
153+
if args.build_ios and args.build_ios_device:
154+
targets.extend(StdlibDeploymentTarget.iOS.targets)
155+
if args.build_tvos and args.build_tvos_simulator:
156+
targets.extend(StdlibDeploymentTarget.AppleTVSimulator.targets)
157+
if args.build_tvos and args.build_tvos_device:
158+
targets.extend(StdlibDeploymentTarget.AppleTV.targets)
159+
if args.build_watchos and args.build_watchos_simulator:
160+
targets.extend(StdlibDeploymentTarget.AppleWatchSimulator.targets)
161+
if args.build_watchos and args.build_watchos_device:
162+
targets.extend(StdlibDeploymentTarget.AppleWatch.targets)
163+
return targets
164+
else:
165+
# All other machines only configure their host stdlib by default.
166+
return [host_target]
167+
168+
135169
@staticmethod
136170
def apply_default_arguments(toolchain, args):
137171
# Infer if ninja is required
@@ -144,7 +178,7 @@ class BuildScriptInvocation(object):
144178
# Set the default stdlib-deployment-targets, if none were provided.
145179
if args.stdlib_deployment_targets is None:
146180
stdlib_targets = \
147-
StdlibDeploymentTarget.default_stdlib_deployment_targets()
181+
BuildScriptInvocation.default_stdlib_deployment_targets(args)
148182
args.stdlib_deployment_targets = [
149183
target.name for target in stdlib_targets]
150184

utils/build-script-impl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,6 @@ for host in "${ALL_HOSTS[@]}"; do
24542454
-DLLDB_PATH_TO_SWIFT_SOURCE:PATH="${SWIFT_SOURCE_DIR}"
24552455
-DLLDB_IS_BUILDBOT_BUILD:BOOL="${LLDB_IS_BUILDBOT_BUILD}"
24562456
-DLLDB_BUILD_DATE:STRING="\"${LLDB_BUILD_DATE}\""
2457-
-DLLDB_ALLOW_STATIC_BINDINGS:BOOL=1
24582457
-DLLDB_INCLUDE_TESTS:BOOL=$(false_true ${BUILD_TOOLCHAIN_ONLY})
24592458
-DLLDB_TEST_USER_ARGS="${DOTEST_ARGS}"
24602459
)

utils/build-windows.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ call :build_swift %exitOnError%
6565

6666
call :build_lldb %exitOnError%
6767

68-
path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
68+
path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
6969
call :test_swift %exitOnError%
7070

7171
goto :end
@@ -279,7 +279,7 @@ cmake "%source_root%\lldb"^
279279
-DClang_DIR:PATH=%build_root%\llvm\lib\cmake\clang^
280280
-DSwift_DIR:PATH=%build_root%\swift\lib\cmake\swift^
281281
-DLLVM_ENABLE_ASSERTIONS:BOOL=YES^
282-
-DLLDB_ALLOW_STATIC_BINDINGS:BOOL=YES^
282+
-DLLDB_USE_STATIC_BINDINGS:BOOL=YES^
283283
-DPYTHON_HOME:PATH=%PYTHON_HOME%^
284284
-DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
285285
-DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -228,32 +228,6 @@ def host_target():
228228
raise NotImplementedError('System "%s" with architecture "%s" is not '
229229
'supported' % (system, machine))
230230

231-
@staticmethod
232-
def default_stdlib_deployment_targets():
233-
"""
234-
Return targets for the Swift stdlib, based on the build machine.
235-
If the build machine is not one of the recognized ones, return None.
236-
"""
237-
238-
host_target = StdlibDeploymentTarget.host_target()
239-
if host_target is None:
240-
return None
241-
242-
# OS X build machines configure all Darwin platforms by default.
243-
# Put iOS native targets last so that we test them last
244-
# (it takes a long time).
245-
if host_target == StdlibDeploymentTarget.OSX.x86_64:
246-
return [host_target] + \
247-
StdlibDeploymentTarget.iOSSimulator.targets + \
248-
StdlibDeploymentTarget.AppleTVSimulator.targets + \
249-
StdlibDeploymentTarget.AppleWatchSimulator.targets + \
250-
StdlibDeploymentTarget.iOS.targets + \
251-
StdlibDeploymentTarget.AppleTV.targets + \
252-
StdlibDeploymentTarget.AppleWatch.targets
253-
else:
254-
# All other machines only configure their host stdlib by default.
255-
return [host_target]
256-
257231
@classmethod
258232
def get_target_for_name(cls, name):
259233
return cls._targets_by_name.get(name)

0 commit comments

Comments
 (0)