Commit Graph

804 Commits

Author SHA1 Message Date
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
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Doug Gregor
a4d464fb94 [Conformance lookup] Don’t form an inherited conformance to an error type.
Fixes SR-8642, a crash-on-invalid.
2018-08-28 09:55:45 -07:00
Doug Gregor
92d622ab41 [Type checker] Eliminate TypeResolverContext::GenericSignature.
The name-lookup behavior that avoids looking for members of a nominal type
or extension therefore when resolving the inheritance clause is now
handled by UnqualifiedLookup, so remove it from the type checker itself.

Fixes rdar://problem/39130543.
2018-08-14 23:17:57 -07:00
Rintaro Ishizaki
5217b68f08 [Parse] Set ErrorType to invalid ParamDecl
TypeChecker assumes invalid decl has valid type.

https://bugs.swift.org/browse/SR-8475
rdar://problem/43057057
2018-08-09 15:55:33 +09:00
Doug Gregor
3018becde7 [Type checker] Eliminate type checking from early extension binding.
Use ExtensionDecl::getExtendedNominal() to wire up extensions to their
nominal types early in type checking (the bindExtensions()) operation,
rather than going through type validation to do so.
2018-08-03 11:26:49 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
Mark Lacey
78d83e5703 Use %target-typecheck-verify-swift where possible. 2018-07-26 23:13:43 -07:00
Doug Gregor
b421d08955 [GSB] Use resolved type when looking for a representative constraint.
When looking for a representative superclass constraint, take into
account other same-type constraints by comparing against the resolved
superclass constraint type rather than the type as spelled.

Fixes SR-8179 / rdar://problem/41851224.
2018-07-26 12:42:29 -07:00
Ben Cohen
345879429b [stdlib] Take several underscored stdlib functions private (#18134)
* Make _sanityCheck internal

* Make _debugPrecondition internal

* Make Optional._unsafelyUnwrappedUnchecked internal.

* Make _precondition internal

* Switch Foundation _sanityChecks to assertions

* Update file check tests

* Remove one more _debugPrecondition

* Update Optimization-with-check tests
2018-07-24 18:26:19 -07:00
Doug Gregor
5c008ab2ce [Type checker] Don't substitute into unresolved types.
Unresolved types are formed in a few specific places within the type
checker's recovery path; don't let them bleed into the substitution
logic. Fixes rdar://problem/42448618.
2018-07-24 16:56:43 -07:00
Huon Wilson
7c088beadc Merge pull request #18057 from huonw/sr8240
[test] Stop a test relying on inconsistent formatting of an error message.
2018-07-19 13:24:20 +10:00
Huon Wilson
db04e817cc [test] Stop a test relying on inconsistent formatting of an error message.
Fixes rdar://problem/42351773.
2018-07-19 09:39:06 +10:00
Huon Wilson
c12bb46145 Merge pull request #18004 from huonw/sr8240
[AST] Member lookup in the GSB needs to understand equivalence classes with concrete types.
2018-07-18 12:46:08 +10:00
Slava Pestov
42a3ad3bf0 AST: Fix over-eager collapseSpecializedConformance()
It's possible that the conforming type is equal to the generic
conformance type, but some of the substitutions replace an
abstract conformance with a concrete one.

In this case we cannot collapse away the specialized conformance,
because we lose information that way.

Fixes <rdar://problem/40164371>.
2018-07-17 14:41:49 -07:00
Huon Wilson
ea1560f43b [AST] Member lookup in the GSB needs to understand equivalence classes with concrete types.
A constraint like `Parameter == SomethingConcrete` means references to
`Parameter` in that context behave like `SomethingConcrete`, including for name
resolution. Handling the parameter as just a parameter type means that it won't
find any non-protocol nested types (i.e. things other than associated types and
protocol typealiases are invisible).

Fixes rdar://problem/42136457 and SR-8240.
2018-07-17 22:54:22 +10:00
Slava Pestov
a78209610c Add test case for crasher that's already fixed on master 2018-07-04 00:42:33 -07:00
Slava Pestov
308463af38 Add test case for bug that's already fixed 2018-07-03 16:03:07 -07:00
Slava Pestov
28b0606b46 'Migrate' compiler crashers to Swift 4 2018-07-03 16:03:07 -07:00
Pavel Yaskevich
2ce5ae34c1 [Parser] Make sure to add implicit parens to call for prefix/postfix operators when needed
Currently when call involving prefix/postfix operator is formed we
don't wrap argument in implicit parens (like we do with other calls)
when user didn't provide any explicitly, this is bad because
argument-to-parameter matcher requires multiple special cases to handle
such behavior, so let's start wrapping arguments in implicit parens instead.

Resolves: rdar://problem/40722855
Resolves: [SR-7840](https://bugs.swift.org/browse/SR-7840)
2018-07-02 06:07:15 -07:00
Doug Gregor
932e9bef2f [Type checker] Look through optional injections when checking for rethrows.
Fixes SR-5427.
2018-06-29 09:35:01 -07:00
Anthony Latsis
092666526c Update fixed crasher validation test 2018-06-22 05:23:15 +03:00
Huon Wilson
92189c6079 Merge pull request #17356 from huonw/lazier-conditional-requirements
More errors instead of crashes for conditional conformances that are invalid or involve hard-to-resolve recursion
2018-06-21 11:59:49 +10:00
Huon Wilson
a21a7798d8 [Sema] Be more resilient about unavailable conditional requirements in error cases.
When we're trying to diagnose something, it's a bad look if we crash
instead. This changes the bad-associated-type recovery path to not require that
the conditional requirements have been computed, and instead detects that as a
possible error.

Fixes https://bugs.swift.org/browse/SR-8033.
2018-06-21 10:53:30 +10:00
Huon Wilson
10b30fef78 [GSB] Explicit error on unsupported conditional conformance recursion.
This doesn't fix the fundamental problem of correctly handling such cases, but
it is better than the "error message" that occurred previously:

    Assertion failed: ((bool)typeSig == (bool)extensionSig && "unexpected generic-ness mismatch on conformance").

Fixes the crash rdar://problem/41281406 (that in
https://bugs.swift.org/browse/SR-6569 (rdar://problem/36068136)),
https://bugs.swift.org/browse/SR-8019 (rdar://problem/41216423) and
https://bugs.swift.org/browse/SR-7989 (rdar://problem/41126254).
2018-06-21 10:53:30 +10:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Slava Pestov
e6c4a3825e Update a few tests to pass with -swift-version 4 2018-06-19 23:23:20 -07:00
Robert Widmann
0b33a69540 Merge pull request #17195 from brentdax/label-fable
Implicit tuple interpolations, take two
2018-06-18 15:54:30 -07:00
Pavel Yaskevich
969fb35f60 Merge pull request #17270 from xedin/rdar-41141944
[TypeChecker] When formatting witness type for diagnostics don't assu…
2018-06-16 01:21:35 -07:00
Pavel Yaskevich
235ed55004 [TypeChecker] When formatting witness type for diagnostics don't assume it's always valid
Sometimes witness candidates have error type e.g. when re-declaration checking
marks them as `invalid`, so formatting of the diagnostic
should account of potential witnesses not having a valid type.

Resolves: rdar://problem/41141944
2018-06-15 19:50:25 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00