Commit Graph

805 Commits

Author SHA1 Message Date
Pavel Yaskevich
9b635833cc Merge pull request #26424 from LucianoPAlmeida/sr-8467-invalid-read-get-extra-info
SR-8467: Fixing crash on AnyFunctionType::getExtInfo
2019-07-30 19:56:46 -07:00
Luciano Almeida
1a21811797 SR-8467: Fixing crash on AnyFunctionType::getExtInfo 2019-07-30 22:08:47 -03:00
Suyash Srijan
2339b5f9bd [CSDiagnostics] Move check inside getDeclContext() 2019-07-30 20:27:25 +01:00
Suyash Srijan
e50050b0fb [CSDiagnostics] Don't crash if we don't have access to the generic param's decl 2019-07-30 19:47:27 +01:00
Doug Gregor
e1b359b8a4 [Type checker] Substitute into alternate properties when trying to fix wrapped property refereces
Fixes SR-11149 / rdar://problem/53204113
2019-07-19 15:40:20 -07:00
Doug Gregor
ac5e2f9dce Add now-fixed test case from rdar://problem/53183030 2019-07-19 10:30:36 -07:00
Doug Gregor
118a557304 [SE-0258] Check for a NULL type.
Within invalid code, we might encounter expressions without type
information yet. Check for NULL here.

Fixes crash from rdar://problem/53120878.
2019-07-19 10:26:26 -07:00
Doug Gregor
9f0bc69edc [Type checker] Classes don't need backing properties to create their implicit constructors
Fixes a crash caused by an undiagnosed cycle, rdar://problem/52679284.
2019-07-19 06:53:53 -07:00
Slava Pestov
84b026753e Add test case for SR-9583
https://bugs.swift.org/browse/SR-9583 / rdar://problem/47097468
2019-07-17 18:07:03 -04:00
Slava Pestov
ed3e4dc931 Sema: Add implicit constructors before checking members 2019-07-17 18:07:03 -04:00
Pavel Yaskevich
7add7446d7 Merge pull request #26074 from theblixguy/fix/SR-11074
[CS] Don't crash when default argument is magic literal and types don't match
2019-07-17 10:20:49 -07:00
Slava Pestov
48bee3825c Add regression test for rdar://48994748 2019-07-17 01:18:01 -04:00
Suyash Srijan
1a1bff46d8 [CS] Don't crash when using magic literals as default arg
Squash all commits into one
2019-07-17 01:20:25 +01:00
Doug Gregor
bee789e277 [SE-0258] Check for an invalid property wrapper type definition.
Fixes the crash-on-invalid in rdar://problem/52081852.
2019-07-08 16:07:51 -07:00
Slava Pestov
7434e37605 Sema: Fix crash with circular property initial values
Fixes <rdar://45313700>, <https://bugs.swift.org/browse/SR-9015>.
2019-06-27 23:13:46 -04:00
Slava Pestov
0a9e1c2176 Sema: Merge two places where we resolve 'Self' 2019-06-26 01:12:27 -04:00
Suyash Srijan
1ce8cdead2 [Test] Adds a test case 2019-06-24 21:58:33 +01:00
Pavel Yaskevich
6605d56781 Merge pull request #25431 from xedin/rdar-48937223
[CSApply] Don't try to transform editor placeholder if it's type is invalid
2019-06-13 16:48:50 -07:00
Pavel Yaskevich
26d0324318 [CSApply] Don't try to transform editor placeholder if it's type is invalid
CSDiag could re-typecheck closure or other expression which has editor
placeholder inside allowing type variables be bound to unresolved
type, which doesn't really form a valid solution to be applied to AST.
So we need to guard against trying to transform placeholder into a call
to `_undefined` in such case, otherwise in asserts build it's going to
crash with an assert but in release build it would crash in some other
place e.g. xSILGen or trying to type-check captures.

Resolves: rdar://problem/48937223
Resolves: rdar://problem/51599529
2019-06-13 10:55:43 -07:00
Doug Gregor
0216e3b9d3 [Type checker] Compute correct contextual substitutions for local generics.
When applying generic arguments to a local generic type within a generic
function, ensure that we correctly produce the contextual substitutions from
the generic function. Fixed with Pavel, who painstakingly tracked down
the bogus substitution.

Fixes SR-9954 / rdar://problem/48223824.
2019-06-12 16:31:32 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Slava Pestov
865b79c516 Add regression test for fixed crasher 2019-05-17 23:08:31 -04:00
Joe Groff
cec9e9e33a Opaque types require a newer Swift runtime.
Check the availability of decls that declare an opaque return type to ensure they deploy to a
runtime that supports opaque types.

rdar://problem/50731151
2019-05-15 11:39:53 -07:00
swift-ci
ed90f333de Merge pull request #24588 from DougGregor/pattern-type-check-crash 2019-05-07 15:01:31 -07:00
Doug Gregor
90d9721473 [Type checker] Fix a crash-on-invalid in pattern type checking.
Fixes rdar://problem/49731284.
2019-05-07 13:58:30 -07:00
Doug Gregor
24d24c0e63 [AST] Allocate GenericSignature(Builders) in the arena
Opaque result type archetypes can involve type variables, which
then get introduced into GenericSignatureBuilders and the
generated GenericSignatures. Allocate them in the proper arena
So we don’t end up with use-after-free errors.

Fixes rdar://problem/50309503.
2019-05-07 06:56:42 -07:00
Slava Pestov
39a22f3d6a AST: Remove ParameterTypeFlags::Escaping
Escapingness is a property of the type of a value, not a property of a function
parameter. Having it as a separate parameter flag just meant one more piece of
state that could get out of sync and cause weird problems.

Instead, always look at the noescape bit in a function type as the canonical
source of truth.

This does mean that '@escaping' is now printed in a few diagnostics where it was
not printed before; we can investigate these as separate issues, but it is
correct to print it there because the function types in question are, in fact,
escaping.

Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
2019-04-15 00:25:03 -04:00
Slava Pestov
0f53290cb2 Add regression test for fixed bugs
<rdar://problem/39826863>, and <https://bugs.swift.org/browse/SR-9508>.
2019-04-02 19:00:01 -04:00
Slava Pestov
88e41231cc Sema: Skip non-single-expression closure bodies in MiscDiagnostics
This is a defensive move to avoid duplicated work and guard against crashes
when a multi-expression closure body or TapExpr has not been type checked yet.

Fixes <rdar://problem/48852402>.
2019-04-02 00:25:24 -04:00
Pavel Yaskevich
8e420496b2 [ConstraintSystem] Delay adding contextual requirements until parent type is opened
`openUnboundGenericType` eagerly tries to add conditional requirements
associated with chain of parents of the given type if type has been
declared inside of constrained extension. But one of the parent types
might be unbound e.g. `A.B` which means it has to be opened, which
by itself, would add such requirements.

Resolves: rdar://problem/49371608
2019-03-28 22:08:33 -07:00
Suyash Srijan
676d914e7c [csapply] do not proceed with a key path whose base type is AnyObject 2019-03-22 20:42:58 +00:00
Jordan Rose
ce0178fc13 Merge pull request #23357 from theblixguy/fix/SR-10108
[Sema] Fix a crash when attempting to synthesise raw representable conformance
2019-03-19 07:30:48 -07:00
Suyash Srijan
146f705087 [test] prefix the RUN arguments with 2019-03-18 22:40:50 +00:00
Suyash Srijan
4eebc8e46f [Sema] Don't attempt to derive raw representable conformance if the enum elements have a payload 2019-03-16 23:39:13 +00:00
Suyash Srijan
e21430a6af [typechecker] disallow default argument to inout parameter 2019-03-12 02:57:28 +00:00
Ben Cohen
0f339d3663 Merge branch 'master' into safe-conversion 2019-02-11 12:58:51 -08:00
Joe Shajrawi
9e560ce785 [LoadableByAddress] handle functions that return a closure in a tuple 2019-02-04 17:25:49 -08:00
Ben Cohen
2010f02e8a Remove overly-permissive UnsafePointer init 2019-01-31 18:05:11 -08:00
swift-ci
4544476851 Merge pull request #21656 from DougGregor/gsb-source-invalid-source-locs 2019-01-04 21:54:47 -08:00
Doug Gregor
05fc089af6 [Generic Signature Builder] Sort invalid source locations properly.
Fixes SR-9496 / rdar://problem/46699008.
2019-01-04 20:56:43 -08:00
Doug Gregor
8d5971e81e [Type checker] Be more careful when checking @_implements.
Fixes rdar://problem/46678653.
2019-01-04 20:22:34 -08:00
Pavel Yaskevich
5239edfc99 [TypeChecker] Add a test-case for rdar://problem/46497155 2018-12-13 21:14:53 -08:00
Brent Royal-Gordon
eb81efe369 Update two diagnostics in validation tests 2018-12-12 13:01:38 -08:00
Slava Pestov
4c0b391537 Sema: Ensure that even invalid extensions still have a generic parameter list
This helps maintain invariants, such as the presence of a generic
parameter list implying the presence of a generic signature.

Fixes <rdar://problem/45317855>.
2018-12-11 17:48:52 -05:00
Slava Pestov
f5eb7087aa Add a couple of regression tests 2018-12-10 00:00:49 -05:00
Slava Pestov
c29ae74e4d Add validation test for fixed crasher 2018-11-16 01:43:50 -05:00
Pavel Yaskevich
66a79301b4 [CSDiagnostics] Diagnose contextual closure result mismatches via fixes
Let's keep track of type mismatch between type deduced
for the body of the closure vs. what is requested
contextually, it makes it much easier to diagnose
problems like:

```swift
func foo(_: () -> Int) {}
foo { "hello" }
```

Because we can pin-point problematic area of the source
when the rest of the system is consistent.

Resolves: rdar://problem/40537960
2018-11-07 14:28:50 -08:00
Jordan Rose
bc18397456 [test] Add a fixed crasher test for SR-9199 (#20386) 2018-11-07 09:16:47 -08:00
Doug Gregor
5e439f7647 [Mangling] Mangle types as generic only when they have generic arguments.
The `isSpecialized()` check didn’t account for the possibility that a
typealias in a parent of a nominal type could be non-generic when the
parent declaration was generic, leading to incorrect mangling that stated
that they were generic but had no generic arguments.

Fixes SR-8930 / rdar://problem/45216653 and rdar://problem/45813164.
2018-11-05 23:31:32 -08:00
Brent Royal-Gordon
4ddd82f990 Add regression test for fixed crasher (#20098)
In Swift 4.2, this example crashed. In Swift 5, it incorrectly diagnoses a type error. Eventually, it should actually succeed. For now, let's make sure we don't backslide to crashing.
2018-10-29 17:04:58 -07:00