Commit Graph

731 Commits

Author SHA1 Message Date
Slava Pestov
e58ae766a3 Fix and un-XFAIL regressed crashers from recent stdlib change 2017-05-17 05:51:51 -07:00
Doug Gregor
cf5424b617 [GSB] Move the Recursive(Concrete|Superclass)Type bits into EquivalenceClass.
Recursive concrete and superclass constraints are detected
per-equivalence-class; record them that way.

Use that information to drop recursive concrete and superclass
constraints from the resulting signature, which frees the canonical
generic signature builder from having to worry about such recursive
constraints. This eliminates the invalid-code crashes introduced in
the prior commit that disabled finalization for the canonical GSBs, as
well as fixing one other random crash-on-invalid.
2017-05-15 22:05:07 -07:00
practicalswift
6fc2efbe49 Merge pull request #9572 from practicalswift/gardening-20170513
[gardening] Remove assert requirement from fixed crashers. Fix spacing. Remove unused variables.
2017-05-15 14:00:21 +02:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
practicalswift
4f05554682 [gardening] Remove assert requirement from fixed crashers 2017-05-13 10:57:05 +02:00
swift-ci
cd61cf6d1b Merge pull request #9494 from DougGregor/common-return-type-cleanup 2017-05-11 09:46:49 -07:00
Doug Gregor
ecdc993881 [Type checker] Tolerate invalid expressions in the error-handling checker.
When errors occur in the processing of expressions, we can end up with
invalid ASTs where the application of an operator declared within a
type is missing its "self" argument. Tolerate such ASTs in the
error-handling checker.
2017-05-11 08:57:29 -07:00
Roman Levenstein
f860741b05 Update tests 2017-05-10 16:31:08 -07:00
swift-ci
6f0ddedfaf Merge pull request #9219 from xedin/closure-arg-diag 2017-05-08 23:58:36 -07:00
Pavel Yaskevich
ddaccf88bb [QoI] Properly diagnose closure parameter distructuring after SE-0110
Swift 3 supported limited argument destructuring when it comes to
declaring (trailing) closures. Such behavior has been changed by
SE-0110. This patch aims to provide better error message as well
as fix-it (if structure of the expected and actual arguments matches)
to make the migration easier and disambiguate some of the common
mistakes.

Resolves: SR-4738, SR-4745, rdar://problem/31892961.
2017-05-08 23:04:37 -07:00
practicalswift
59cf379b17 [gardening] Remove "REQUIRES: asserts" from fixed crashers 2017-05-08 21:51:50 +02:00
Slava Pestov
2fe863266c AST: Fix crashes when name lookup finds declarations outside of a protocol or extension that's nested in another type
When performing a name lookup from inside of a protocol
or extension, skip directly to the source file context
when we are done visiting the protocol or extension.

Otherwise, if we have invalid code where the protocol
or extension is nested inside another type, we might
find a member whose type contains generic parameters
of the outer type; these parameters will not resolve,
since we do not model protocols or extensions nested
inside generic contexts (yet?).

This supercedes an earlier workaround for a similar
issue; the new workaround fixes more crashes.

This is needed to avoid crasher regressions with an
upcoming patch.
2017-05-07 03:01:47 -07:00
Doug Gregor
3dbfa9789f [Associated type inference] Check solutions against full requirement signature
When we have a potential assignment of associated types to type
witnesses during associated type inference, check that set of type
witnesses against the requirements in the requirement signature, so
that we can reject any solutions that fail some of the protocol's
requirements.

This is most of rdar://problem/31830524 --- but gets thwarted by the
inability of associated type inference to work across multiple
protocols.
2017-05-04 00:21:52 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Slava Pestov
0d4a0b7dc1 AST: Update ProtocolDecl::requiresClass() for primitive AnyObject 2017-05-01 16:43:51 -07:00
Ben Cohen
deb8a8889a Delete old test that no longer makes sense (#9021) 2017-04-26 05:41:56 -07:00
Maxim Moiseev
1c1b2b966d [stdlib] String : RangeReplaceableCollection & BidirectionalCollection (#8921)
* [stdlib] String : RangeReplaceableCollection & BidirectionalCollection

* Add source compatibility hack for Swift.max

* Add source compatibility hack for Swift.min

* Remove redundant conformance in benchmarks

* Fix stupid typo I thought I'd already pushed

* XFAIL testing now-redundant conformance

* XFAIL an IDE test for now
2017-04-23 20:04:54 -07:00
Slava Pestov
aaca0badf9 Sema: Diagnose invalid references to type alias members of unbound generic types
Consider the following setup:

struct GenericStruct<T> {
  typealias Dependent = T
  typealias Concrete = Int
}

We have no way to model 'GenericStruct.Dependent' in the AST, so the
reference would crash. Instead, produce a diagnostic suggesting to
insert generic parameters, like 'GenericStruct<Int>.Dependent'.

The reference 'GenericStruct.Concrete' is fine though, and should
not crash; add a test that it works.

Fixes <https://bugs.swift.org/browse/SR-4390>, <rdar://problem/31480755>.
2017-04-23 00:02:30 -07:00
practicalswift
52fd78a5fc [gardening] Remove assert requirement for fixed crasher 2017-04-18 19:15:42 +02:00
Slava Pestov
9319a531f2 AST: Stricter contract for Type::subst()
Fix an odd corner case when UseErrorTypes was off; we would
return the empty type if dependent member type substitution
failed, but otherwise return the original type if it was a
generic type parameter or an archetype.

Now, if UseErrorTypes is off, return the empty type in both
cases, even if the original type is 'primary'.
2017-04-17 18:04:05 -07:00
practicalswift
288aff04e9 [gardening] Remove assert requirement for fixed crasher 2017-04-14 17:33:24 +02:00
Doug Gregor
0f0a5906d7 [GSB] Put conformance requirements on the proper potential archetype.
We were putting conformance requirements on the representative of the
equivalence class, rather than directly on the potential archetype on
which the conformance requirement was specified. This violates the
invariant used when forming protocol-requirement sources that we never
reseat a requirement onto the representative (which would
have become a problem when implementing recursive protocol
constreaints) as well as masking a GSB idempotency issue that comes
from same-type requirements where the right-hand side was not
guaranteed to refer to the archetype anchor *within* that subcomponent.
2017-04-11 14:15:46 -07:00
Slava Pestov
011fb8117a Sema: Fix a compiler crasher 2017-04-10 17:04:35 -07:00
Doug Gregor
5c89eb84f0 [AST] Drop substitutions from type witnesses.
Nobody is using the actual substitutions, but we sure did a lot of
work to cope with them.
2017-04-05 11:21:38 -07:00
David Hart
ecdcac5aa2 Resolve crasher 28704 (#8158)
This crash happens because shouldAddSelfFixit (a check for the expected_self_before_reference diagnotic) performs name lookup inside the parser, which causes a search for extensions, which triggers the mangler, which can get confused if we are in an unfinished declaration (a PatternBindingInitilizer in this case).

A cleaner fix would be to move that logic inside Sema, but it would require much more refactoring that I don’t feel comfortable doing. Instead, this band-aid checks if the innermost type is inside a local context. If that’s the case, we can ignore the search for extensions.
2017-03-17 18:43:23 -07:00
swift-ci
242a177e73 Merge pull request #8093 from hartbit/fix-crasher 2017-03-17 13:19:12 -07:00
practicalswift
b3a1f3f6d4 [gardening] Remove "// REQUIRES: asserts" from fixed crasher 2017-03-17 08:08:12 +01:00
David Hart
732ae1b2c2 Removed requires assert 2017-03-17 07:37:52 +01:00
Rintaro Ishizaki
f4f5d1d063 Mark a crasher fixed (#8150)
28722-swift-genericsignaturebuilder-resolvearchetype-swift-type.swift
has been fixed by c2224f3 #8112
2017-03-17 00:50:54 +09:00
swift-ci
34ed6b0347 Merge pull request #8067 from practicalswift/swiftc-28720-swift-typebase-getcanonicaltype 2017-03-15 16:38:57 -07:00
practicalswift
0a187da3c9 Mark as fixed. 2017-03-15 14:39:44 +01:00
David Hart
ba13a894c0 Fixed crasher 28707
The @_versioned accessibility check is done against the formal access. But the diagnostics is printed with getAccessForDiagnostics. In cases where the effective access is internal, the diagnostics will crash. Example:

```
class A { // implicitly internal
    @_versioned public var a: Int = 0 // explicity public
}
```
2017-03-15 07:38:53 +01:00
Slava Pestov
1248f8054e Sema: Fix another compiler_crasher regression from associated type where clause work
If a protocol's signature is not valid yet, don't attempt a
conformance check.
2017-03-14 00:10:44 -07:00
Slava Pestov
f0e3459068 AST: Fix compiler_crasher regression from associated type where clause work
New GenericTypeParamDecls should always be created with an
InvalidDepth, to prevent canonicalization before the generic
parameter list has been type checked.
2017-03-14 00:10:43 -07:00
Robert Widmann
6543405e2d [SR-4219] Resolve non-deterministic compiler crashes
These were leftover from the #8059, which plugged a type variable leak
caused by type checking invalid default argument expressions.
2017-03-14 00:46:50 -04:00
Robert Widmann
1367b0cb36 Invalidate default argument exprs if typechecking fails
If typechecking fails, the expression will have unsolved type variables
written into it.  This Crashes The Compiler.

In that case, there’s no reason to keep a tree of dangling references
around.  Detach the initializer expression from the AST, but continue
to typecheck it to see if we can get some useful diagnostics out of it.
2017-03-13 23:27:02 -04:00
practicalswift
811d990e5d [gardening] Mark as regressions 2017-03-13 11:39:59 +01:00
Ben Langmuir
548e956261 Attempt to fix bots that are seeing XPASS on two tests
These passed on a no-asserts bot, so add a requirement so they don't
XPASS.
2017-03-01 09:54:03 -08:00
Huon Wilson
2716c760f9 [Test] XFAIL two compiler crashers.
These are badly broken and aren't worth my timing to fix now. :(
2017-02-24 19:40:45 -08:00
practicalswift
05aa57f458 [gardening] Remove asserts from fixed crashers 2017-02-21 14:20:34 +01:00
Doug Gregor
042e6510c3 [AST] Drop ProtocolDecl's "inherited protocols" list.
The list of directly inherited protocols of a ProtocolDecl is already
encoded in the requirement signature, as conformance constraints where
the subject is Self. Gather the list from there rather than separately
computing/storing the list of "inherited protocols".
2017-02-20 09:41:00 -08:00
practicalswift
14bc16417a [gardening] Remove REQUIRES lines from fixed crashers 2017-02-15 15:46:19 +01:00
Mark Lacey
f1f9e88360 Cache expression types in failure diagnosis.
After we call into typeCheckExpression() we need to cache the
resulting types in the constraint system type map because we later
call into code that reads the types out of the type map.

Fixes rdar://problem/30376186 as well as a couple crashers.
2017-02-14 19:22:41 -08:00
practicalswift
e9c6f0a318 [gardening] Remove "REQUIRES: asserts" from fixed crasher 2017-02-13 14:47:01 +01:00
Rintaro Ishizaki
49d134f1a9 [Parse] Stop lying about QuestionLoc of implicit OptionalTypeRepr (#7384)
In conditional statement let/var patterns.
Set invalid location instead.
2017-02-11 13:39:51 +09:00
Jacob Bandes-Storch
e1fd8aa6c7 [Parse] Fix crash in conditional compilation parsing (#7331) 2017-02-08 23:10:26 -08:00
Rintaro Ishizaki
ff826e3491 [Parse] Limit max nesting level of StructureMarkerRAII (#7330)
The threshold is 256, for now.
2017-02-09 15:04:09 +09:00
practicalswift
07fa66ceeb Remove "REQUIRES: asserts" from fixed crashers. 2017-02-03 09:52:34 +01:00
Slava Pestov
f2d159940c Sema: Fix corner case with @_fixed_layout diagnostic
We allow a member of a type to be more accessible than the type
itself. In this case, the broader accessibility is ignored, and
the effective access of the member is constrained by the
accessibility of its parent type.
2017-01-29 23:04:12 -08:00
Slava Pestov
fd317471a9 Sema: Fix crash with @IBDesignatable attribute on an invalid extension 2017-01-29 22:43:41 -08:00