Commit Graph

5899 Commits

Author SHA1 Message Date
Slava Pestov
b183c69d4d Add regression test for https://bugs.swift.org/browse/SR-13141 2020-08-18 23:53:55 -04:00
Slava Pestov
876fe2f639 Sema: Redeclaration checking should not mark implicit decls as invalid
If both the 'other' and 'current' declarations are implicit, we don't
emit a diagnostic unless they are both derived from property wrappers
or lazy property storage.

However, we would still call setInvalid() unconditionally, which splats
an ErrorType into the interface type, which would crash in the AST
verifier if no other diagnostic was emitted.

Fixes <rdar://problem/67259506>.
2020-08-18 23:45:52 -04:00
Slava Pestov
d50e3b00bf Add regression test for rdar://problem/62268062 2020-08-18 18:13:31 -04:00
Meghana Gupta
d463c7933e Merge pull request #33520 from meg-gupta/disabletestforasan
Disable test verify_all_overlays.py for asan builds
2020-08-18 11:21:18 -07:00
Meghana Gupta
ee1d975da0 Disable test for asan builds
Raises a stackoverflow error in some asan builds even though it is not a
runaway recursion.
2020-08-17 19:28:40 -07:00
Rintaro Ishizaki
f470902f42 Merge pull request #33492 from rintaro/ide-completion-rdar67102611
[CodeCompletion] Skip an ASTScope assertion for labeled statements
2020-08-17 09:18:15 -07:00
Slava Pestov
6d84c18ba4 Sema: Check 'where' clause requirements on type witnesses
In the included test case, conformance checking of Wrapper : B would
pick up typealias Foo as a witness for the associated type B.Foo.

However, this typealias Foo is defined in a constrained extension where
T : A, and the underlying type references the associated type A.Foo
on T.

The resulting substitution is invalid when the conformance Wrapper : B
is used in a context where T does not conform to A.

Instead, we should ignore this typealias entirely, since it appears
in an unusable constrained extension.

Fixes <rdar://problem/60219705>, <https://bugs.swift.org/browse/SR-12327>,
<https://bugs.swift.org/browse/SR-12663>.
2020-08-15 01:43:13 -04:00
Rintaro Ishizaki
d9a9b59634 [CodeCompletion] Skip an ASTScope assertion for labeled statements
Code completion performs 'typeCheckASTNodeAtLoc()' which ignores
'StmtChecker::ActiveLabeledStmts'. Since this is not necessary for code
completions, skip an assertion to verify the correctness of ASTScope.

rdar://problem/67102611
2020-08-14 16:01:47 -07:00
Slava Pestov
5ad4fa8b07 SIL: Don't canonicalize struct field and enum element types against the wrong signature
The replacement types of the substitution map are either going
to be contextual types, or interface types using some generic
signature. There is no requirement that this generic signature
is the generic signature of the type declaration itself.

By using the generic signature of the type declaration, we
could incorrectly canonicalize generic parameters to concrete
types if the type itself was defined in a constrained extension,
as in the test case here.

Fixes <rdar://problem/65272763>.
2020-08-11 22:54:19 -04:00
Holly Borla
4096a62b2a [ConstraintSystem] Don't update the work list when merging type variables
in addJoinConstraint.
2020-08-10 19:56:00 -07:00
Mishal Shah
ac6683994a [Disable] SILOptimizer test (66807959) 2020-08-10 17:22:26 -07:00
Robert Widmann
aada983ceb Replace supersuperclassConformsTo
This more powerful primitive is capable of
1) Detecting invalid classes
2) Detecting invalid superclasses
3) Detecting circularity in inheritance hierarchies

The attached crasher demonstrates the reason we need to validate all of these predicates. Simply put, a circular class hierarchy is always going to report the superclass conforms to any protocol with a declaration in the source. Leveraging this, one could construct any circular class hierarchy, and a conformance to Codable would immediately crash because we got as far as trying to build a CodingKeys enum with an absolutely nonsensical structure.

This also has the added benefit of de-complecting an enormous amount of codable conformance code.

rdar://66588925
2020-08-10 14:38:29 -07:00
Stephen Canon
457b9990e9 Add checks that the endpoints of partial ranges are not-NaN. (#33378)
We can't actually check for NaN (because the notion doesn't exist for Comparable), but we can require that the endpoint is non-exceptional by checking if it equals itself.
2020-08-10 14:06:46 -04:00
Mishal Shah
bc2a8f41c1 Merge pull request #33354 from apple/shahmishal/codesign-tests
[Tests] Codesign the binary before executing the test
2020-08-07 19:33:20 -07:00
Holly Borla
9e818233f0 Merge pull request #33296 from hborla/merge-joined-literal-typevars
[ConstraintSystem] Add a type variable merging heuristic to addJoinConstraint
2020-08-07 09:07:19 -07:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Holly Borla
989a432898 [NFC] Update array literal type checking performance validation tests. 2020-08-06 12:30:45 -07:00
Suyash Srijan
3502e07bf0 [Mangling] Add a new mangling for opaque return type to use when mangling an ObjC runtime name (#33035)
* [Mangling] Add a new mangling to represent opaque return type for ObjC runtime name

* [Docs] Add the new 'Qu' mangling to 'Mangling.rst' document

* [Test] Update test invocation arguments
2020-08-05 05:03:45 +01:00
Erik Eckstein
5f3e79b84e StringOptimization: bug fixes
Fix some bugs in the optimization and in the test files.

rdar://problem/66283894
2020-07-30 11:32:39 +02:00
Augusto Noronha
a6e2f8b7a0 Conditionalize 'num_extra_inhabitants' in 64 bit platforms' tests (#33136) 2020-07-29 18:49:58 -07:00
Slava Pestov
6364a99123 Merge pull request #33176 from slavapestov/apply-generic-arguments-cleanup
Clean up declaration checker's modeling of generic arguments and parameter lists
2020-07-29 11:03:14 -04:00
Nate Cook
498969f64e XFAIL SILOptimizer/large_string_array.swift.gyb (#33157) 2020-07-28 11:09:57 -05:00
Slava Pestov
769c4c1911 Sema: Fix some crashes with invalid nesting of extensions and protocols
Make sure we consistently use getParentForLookup() and not getParent()
when looking at generic DeclContexts. This is because an extension or
protocol that is nested inside of another generic context must never
inherit generic parameters from the parent context.

We already had this invariant enforced in some places, but now that we
do it more consistently we can fix more crashes of this kind.

Fixes <rdar://problem/58813746>, <https://bugs.swift.org/browse/SR-13004>.
2020-07-28 02:07:16 -04:00
Augusto Noronha
0f8613711d Enable validation reflection tests passing on Linux (#33134) 2020-07-27 14:36:19 -07:00
Mishal Shah
2b18b5067c [XFAIL] Sema/SwiftUI/rdar57201781.swift and Constraints/trailing_closures_objc.swift to support Xcode 12 beta 3 2020-07-26 23:24:26 -07:00
Augusto Noronha
3cb8f9b6fc Add entrypoints to the runtime that exposes metadata necessary for reflection tests on Linux (#32339) 2020-07-24 15:26:15 -07:00
Andrew Trick
4b6641f15f Merge pull request #32860 from buttaface/skip-build
[build] Fix --skip-build-llvm so that its minimal targets, like tblgen, are still built
2020-07-20 20:43:18 -07:00
Butta
c969814a11 [build] Fix --skip-build-llvm so that its minimal targets, like tblgen, are still built 2020-07-18 03:45:17 +05:30
Butta
09e30ef00c [test] Enable standalone_build feature properly and fix three tests
Two tests were mislabeled and a third needed its output reordered.
2020-07-18 03:10:31 +05:30
Slava Pestov
2a0c8d1090 GSB: Fix use-after-free error when vending ResolvedType
The maybeResolveEquivalenceClass() method can deallocate equivalence
classes, because it calls updateNestedTypeForConformance(), which
calls addSameTypeRequirement().

Therefore, the EquivalenceClass stored inside a ResolvedType could
become invalid across calls to maybeResolveEquivalenceClass().

This was a problem in one place in particular, when adding a new
same-type constraint between two type parameters.

Fix this by not caching the equivalence class of a PotentialArchetype
in the ResolvedType implementation. The only time an equivalence class
is now stored is when returning an unresolved type, which is acted
upon immediately.

Fixes <https://bugs.swift.org/browse/SR-12812>, <rdar://problem/63422600>.
2020-07-16 23:31:33 -04:00
Rintaro Ishizaki
802754d432 Merge pull request #32900 from rintaro/ide-completion-ccexprremover-rdar65556791
[CodeCompletion] Fix a crash in CCExprRemover
2020-07-15 12:46:10 -07:00
Rintaro Ishizaki
f7fc1ed7b5 [CodeCompletion] Fix a crash in CCExprRemover
- Handle cases where getArgumentLabelLocs().size() == 0
- Add some assertions to verify invariants
- Explicit handling of 'llvm::Optional' for 'getUnlabeledTrailingClosureIndex()'
- Avoid walking into nodes after the removing happens

rdar://problem/65556791
2020-07-15 09:56:20 -07:00
Nate Chandler
0113849396 [Test] Disable two tests that hang asan bots.
The following tests are disabled here:

    compiler_crashers_2/0208-sr8751.swift
    compiler_crashers_2/0207-sr7371.swift

rdar://problem/65571199
2020-07-14 16:23:38 -07:00
Saleem Abdulrasool
7ec46f0d6d Merge pull request #32848 from compnerd/divide-and-conquer
validation: explicitly use integral division
2020-07-14 11:15:53 -07:00
Saleem Abdulrasool
8d5c010980 validation: explicitly use integral division
Division behaviour changed between Python 2 and Python 3.  Explicitly
indicate that we wish to use integral division here.
2020-07-13 23:46:00 +00:00
Saleem Abdulrasool
4cd81213c0 validation: make UnsafeBufferPointer Python3 friendly
The `<>` operator does not work in Python 3.  Switch it out for `!=`.
2020-07-13 15:56:07 +00:00
Nate Chandler
086e4a356e [Test] Don't use os stdlib for Runtime/rdar64672291.swift. 2020-07-11 09:30:13 -07:00
Robert Widmann
50c4b3fbf1 Merge pull request #32822 from CodaFi/totally-spaced-out
Handle Boolean Patterns Matching Against Invalid Constructor Forms
2020-07-10 23:20:25 -07:00
Robert Widmann
4369a71a03 Handle Boolean Patterns Matching Against Invalid Constructor Forms
The Space Engine maintains as one of its invariants that the AST it is
handed must at least typecheck. When swift typechecks patterns, the only
case one is allowed to form a Boolean pattern is when a literal is
expected, and the corresponding type of the pattern clause is exactly
Bool. This precludes the use of other types, including
ExpressibleByBooleanLiteral types, from matching. Thus, this code path
was never hit. That is, until we accidentally lifted the restriction on
enum case base name overloading too early. Now, it is possible for the
space engine to see the same constructor head that has subspaces with
different argument types. The space engine is relatively tolerant of
this bizarre situation, but in this one narrow case it was not.

This patch has a narrow fix to add the missing case to the
space engine. In the long term, we need to actually finish SE-0155 which
will make this crash structurally impossible once again.

Resolves rdar://65229620
2020-07-10 14:23:12 -07:00
Nate Chandler
c6812cee68 [Test] Mark executable test appropriately. 2020-07-10 06:21:11 -07:00
Dmitri Gribenko
2e0237701c Merge pull request #32783 from gribozavr/improve-synthesized-initializers-test
Rename synthesized initializer test to follow the pattern
2020-07-09 23:21:15 +02:00
Slava Pestov
a405da436e Merge pull request #32776 from slavapestov/fix-circularity-crash
Sema: Fix crash on circular reference in checkContextualRequirements()
2020-07-09 09:34:40 -04:00
Dmitri Gribenko
3de9e5ac77 Rename synthesized initializer test to follow the pattern
And also removed a test that is semantically a duplicate of the
synthesized initializer test.
2020-07-09 12:11:08 +02:00
swift-ci
a37593a214 Merge pull request #32772 from nate-chandler/rdar50648519 2020-07-08 20:48:12 -07:00
Slava Pestov
1f5433fe51 Add regression test for rdar://64759168 2020-07-08 23:08:40 -04:00
Slava Pestov
94e9263699 Sema: Fix crash on circular reference in checkContextualRequirements()
The call to getGenericSignature() might return nullptr if we encounter
a circular reference.

Fixes <rdar://problem/64992293>.
2020-07-08 23:08:39 -04:00
Nate Chandler
caca83e9e1 [Test] Un-XFAIL ParseableInterface/verify_all_overlays.py.
The test is passing now--un-XFAIL it.

rdar://problem/50648519
2020-07-08 18:01:46 -07:00
nate-chandler
80a5fb262a Merge pull request #32695 from nate-chandler/rdar64672291
[Runtime] Let existential types satisfy superclass requirements.
2020-07-08 09:37:57 -07:00
Anthony Latsis
2133fe27df Sema: Have TypeResolution accept an unbound generic type opener function 2020-07-08 13:39:34 +03:00
Holly Borla
063d420e50 Merge pull request #32672 from hborla/property-wrapper-diagnostics
[Property Wrappers] Improve diagnostics for property wrappers initialized out-of-line
2020-07-07 19:07:55 -07:00