Commit Graph

384 Commits

Author SHA1 Message Date
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
swift-ci
9ed658b0e2 Merge pull request #20124 from DougGregor/test-for-rdar-45557325 2018-10-29 10:59:55 -07:00
Doug Gregor
3e2e81d8a3 Add already-fixed test case from rdar://problem/45557325. 2018-10-29 09:57:39 -07:00
Slava Pestov
add4185b83 AST: Fix infinite recursion with recursive same-type constraints
We diagnose and flag these in finalize(), but we can encounter one
even earlier through resolveDependentMemberTypes(). Do the same
thing there that we already do in EquivalenceClass::getTypeInContext().

Fixes <rdar://problem/45328122>, <https://bugs.swift.org/browse/SR-9022>.
2018-10-28 23:30:19 -04:00
Greg Titus
4f8e3f3597 Merge pull request #19879 from gregomni/8757
[Sema] Omit protocol match diagnosis for constructors with differing names.
2018-10-16 09:36:16 -07:00
gregomni
85baf3f6c6 Diagnosis changes in fixed crasher 2018-10-15 10:36:37 -07:00
Greg Titus
5f2400580e Merge pull request #19830 from gregomni/8813
[Sema] When resolving type declarations, if there is an error with a typealias,...
2018-10-13 21:39:10 -07:00
Greg Titus
c7ae3e6736 Crasher fixed. 2018-10-13 20:13:35 -07:00
Slava Pestov
3178d6d8ac Merge pull request #19760 from gregomni/8902
[Sema]Allow associated type inference for requirement returning dynamic Self...
2018-10-13 15:14:47 -07:00
Slava Pestov
38072b9ec8 Add regression test for fixed crasher 2018-10-11 21:48:06 -07:00
Doug Gregor
59543a10da [Type checker] Only "use" bridging conformances when there is a type checker.
Works around rdar://problem/45047761 and rdar://problem/45058722.
2018-10-08 09:55:41 -07:00
gregomni
ca53b27595 validation test now builds cleanly 2018-10-07 15:58:24 -07:00
Doug Gregor
ae5acb9147 [Type checker] Check for recursion when evaluating @objc on a property.
Fixes crash from rdar://problem/33093935.
2018-10-06 23:21:00 -07:00
Doug Gregor
83e41daaa6 [AST] Ill-formed @objc protocols might have associated types.
As an optimization, we don't even look for associated types in @objc
protocols. However, this could lead to broken invariants like "every
associated type has a witness" in ill-formed @objc protocols that do
have associated types.

Implement this optimization by checking whether the protocol has a
Clang node. Fixes rdar://problem/41425828 / SR-8094.
2018-10-06 10:35:07 -07:00
Slava Pestov
2f38584b3a Add regression test for fixed crasher 2018-10-03 02:30:29 -04:00
Slava Pestov
2d4b25960d Sema: Type variables for opened generic parameters store the generic parameter type and not an archetype
There's no need to instantiate archetypes in the generic environment
of the declaration being opened.

A couple of diagnostics changed. They were already misleading, and the
new diagnostics, while different, are not any more misleading than
before.
2018-09-27 20:49:23 -07:00
Pavel Yaskevich
bd527c114e [CSBindings] Don't consider dependent member types even if they are wrapped in optionals
Because binding producer is going to attempt to unwrap optionals
and try the type, which would lead to infinite recursion because
dependent member types aren't bindable.

Resolves: rdar://problem/44770297
2018-09-25 20:59:58 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Slava Pestov
8ddd2c02c4 Serialization: Serialize both the substituted and unsubstituted type for a NameAliasType 2018-09-14 14:31:46 -07:00
Doug Gregor
8a2ce9bdf7 [Associated type inference] Never infer a type involving archetypes and interface types.
Works around an oddity of the associated type inference when the
potential witness is generic and returns (e.g.) Self.

Associated type inference needs to move off of archetypes for the
implementation to become sane. For now, this eliminates a crash.

Fixes rdar://problem/43591024.
2018-09-07 14:20:41 -07:00
Doug Gregor
9e2ebd01db Merge pull request #19021 from DougGregor/sr-8642
[Conformance lookup] Don’t form an inherited conformance to an error type.
2018-08-28 17:05:41 -07:00
Slava Pestov
865b613d5e Sema: Stop using FunctionType::getOld() in CSDiag
We were building the following constraint, where $member and
$input are type variables and 'result' is a concrete type:

- Conversion($member, $input -> result)

When $member was fixed to a function type of arbitrary
arity, this would simplify to a conversion between $member's
result type and 'result'.

Instead, express this using the newly-added FunctionResult
constraint:

- FunctionResult($member, $result)
- Conversion($result, result)

I wasn't expecting this to change diagnostics, but it looks
like it did; I'm not going to bother investigating why,
because Pavel is going to rewrite contextual diagnostics soon
anyway. All but one are clear improvements.

Fixes <rdar://41416346> and <rdar://41416647>, two cases where
diagnostics regressed from -swift-version 3 to -swift-version 4.
2018-08-28 14:38:00 -07:00