Commit Graph

566 Commits

Author SHA1 Message Date
Janek Spaderna
7819da76d1 [Parse] Improve diagnostics in inheritance clauses
Before, a keyword in an inheritance clause would lead to a long list of errors
not really showing what was wrong.
A special case is added to handle protocol composition; in inheritance clauses
the protocols don't have to be composed with 'protocol<>'.
2016-05-25 14:47:51 +02:00
Slava Pestov
55f0791a10 Actually, this test only fails on Darwin platforms...
https://bugs.swift.org/browse/SR-1584
2016-05-21 13:11:30 -07:00
Slava Pestov
0ff0f3c5b9 Sema: Generic classes and subclasses of generic classes now inherit required initializers
Initializers are inherited by synthesizing an implicit decl which
delegates to super.init(). Previously this was only done if the
class and superclass were concrete.

The only thing missing was that we weren't computing an interface
type for the synthesized constructor. There are two steps to this:

- First, we must map the contextual types of the superclass
  initializer's ParamDecls to the subclass generic context.

- Second, we must set the interface type by calling the new
  configureInterfaceType() method, extracted from from
  validateGenericSignature().

Note that configureInterfaceType() now uses the new
AbstractFunctionDecl::hasThrows() flag to set the 'throws' bit on
the function type. Previously, validateGenericFuncSignature()
would look at getThrowsLoc().isValid(), which is not correct for
imported, implicitly-generated or de-serialized decls that 'throw',
because none of those have source location information.

We still don't allow inheriting initializers which have their
own generic parameter list, like 'init<T>(t: T) {...}'. That
requires a little bit more refactoring.

Progress on <rdar://problem/23376955>.
2016-05-21 12:51:51 -07:00
Slava Pestov
09c57d32c7 AST: Fix some nested generics issues exposed by generic initializer inheritance
BoundGenericType::getSubsitutions() would only look at the bound
generic arguments of the innermost type, ignoring parent types.
However, it would then proceed to walk the AllArchetypes list
of all outer generic parameter lists when forming the final
result.

The gatherAllSubstitutions() would also walk through parent types.
As a result, outer generic parameters would appear multiple
times.

Simplify gatherAllSubstitutions() to just skip to the innermost
BoundGenericType, and delegate to getSubsitutions() for the rest.

Most calls to gatherAllSubstitutions() are from SILGen it seems,
and fix only fixes one compiler_crasher.

However an upcoming patch adds a new call to gatherAllSubstitutions()
which caused some crashers to regress, so I'm going to fix it
properly here.
2016-05-21 12:51:50 -07:00
Ted Kremenek
e50069221a XFAIL 00429-vtable.swift because of an assertion failure (SR-1584). 2016-05-21 11:37:49 -07:00
Doug Gregor
e7c81c527c Bail out earlier when we try to recursively validate a generic signature.
Fixes one of the crashers I recently regressed.
2016-05-09 23:22:54 -07:00
Doug Gregor
48ae0fdcfa Temporarily disable tests harder 2016-05-09 22:06:22 -07:00
Doug Gregor
be437713e4 [Evil hack] Temporarily call these crashing while I investigate. 2016-05-09 21:39:06 -07:00
Chris Lattner
684e660b84 remove -verify mode from a validation test, and add its parens. 2016-05-06 21:45:09 -07:00
Mark Lacey
0eb8d01b38 Fix a crasher in the archetype builder.
This particular crasher very rarely didn't crash, causing mayhem with
false failures on the builders.

We were keeping a reference to a vector that could be reallocated in a
recursive call back into the same function. Instead, tend towards
looking up the vector in the map each time we need it.
2016-05-05 16:09:54 -07:00
Doug Gregor
04f4552d07 Fixed a crasher... 2016-04-28 22:47:00 -07:00
Dmitri Gribenko
263d6a4135 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-26 21:15:13 -07:00
Joe Pamer
75f1dce6c1 Update crasher fixed by 2cdd7d64e1 2016-04-26 18:20:26 -07:00
Dmitri Gribenko
cfea1a3f58 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-14 17:00:46 -07:00
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Manav Gabhawala
8f4f37f072 [Sema] Fixes infinite recursion when inheriting from a member of the same type 2016-04-13 18:18:09 -04:00
John McCall
0d77281556 This test doesn't crash anymore. 2016-04-11 15:14:43 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Dmitri Gribenko
6985b958fd Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-04 11:42:17 -07:00
practicalswift
6a3af35c36 [crashers] Remove crash cases without explicit Apache license header. 2016-04-01 23:48:37 +02:00
practicalswift
3bf9216764 [crashers] Add license headers. 2016-03-31 21:33:11 +02:00
Dave Abrahams
8e4f85277b Merge remote-tracking branch 'refs/remotes/origin/master' into merge 2016-03-29 09:19:34 -07:00
Ted Kremenek
5c1806e2ab Change test to run, but disabled under ASan. 2016-03-26 08:51:27 -07:00
Ted Kremenek
19b0a09f05 Try to *really* disable tests by moving them out of the same folder. 2016-03-26 08:20:37 -07:00
Ted Kremenek
dcc093f179 Try and disable these two tests for real. 2016-03-26 07:55:41 -07:00
Ted Kremenek
59f96454c9 Note that test is disabled due to ASan failure, tracked by SR-1070. 2016-03-25 18:48:51 -07:00
Ted Kremenek
f202ffac77 Temporarily disable testing '28277-swift-archetypebuilder-getgenericsignature.swift' because of ASan failure. 2016-03-25 18:41:58 -07:00
gregomni
45fa88c72d [AST/Sema] Typealias in protocol further corner fixes.
Don’t try to find a conformation witness for typealias declarations in
protocols.

Fixed a bug with same type constraint between an alias and a concrete
type - just a bad assumption on my part. Added test for that.

Made archetype builder more resilient in constructing PA trees: it will
work correctly now if the alias destination is a dependent member type
instead of an archetype type. It also handles the case of finding
multiple aliases with the same name along with an associatedtype with
that name, fixing up all the representative ptrs.

Extensions/Nominals that tried to use a protocol's typealias would get a
dependent type as resolved with the protocol's base instead of with the 'Self'
base type of the current extension/nominal, resulting in spurious conformance
failures. So resolve aliases to protocol assoctypes based on the 'Self'
in which they are used.

Also fixed tests to not use common stdlib names, added tests for
typealias in protocol extension and self & recursive aliases. One recent
crasher also fixed.
2016-03-22 07:36:16 -07:00
Dave Abrahams
f493b54e44 [stdlib] indexing model: Interval/Range merge
This is step 1; we still need to introduce ClosedRange.
2016-03-16 15:59:10 -07:00
practicalswift
2a08c13cee [crashers] Add license headers.
Approvals given in #1649.
2016-03-14 21:59:04 +01:00
practicalswift
defe364a59 Merge pull request #1668 from practicalswift/add-apache-license-header-to-crashers
[crashers] Add license header: Apache License v2.0 with Runtime Library Exception
2016-03-14 21:51:03 +01:00
practicalswift
7f5266dea8 [crashers] Add full license header. 2016-03-14 20:53:10 +01:00
practicalswift
e6813aa825 [crashers] Update credits. 2016-03-14 20:53:03 +01:00
Chris Lattner
e1ad6d80ee fix 28270-swift-constraints-constraintsystem-diagnosefailureforexpr.swift 2016-03-14 11:56:32 -07:00
gregomni
03f5c713fd My last commit a11e911 accidentally fixed this recently added crash. 2016-03-13 22:54:08 -07:00
Janek Spaderna
8bca045718 [AST] Fail to compute the EnumElementDecl type in case of an ErrorType
If the resulting function type contains an ErrorType, this is an indicator that
something else is wrong. Bail out in this case.
This happened if an enum case was referenced inside the where-clause and treated
as a type.
2016-03-12 11:53:16 +01:00
practicalswift
4ad5ed4ada [crashers] License: Apache License v2.0 with Runtime Library Exception 2016-03-11 22:35:33 +01:00
gregomni
78216b2990 Change all remaining tests that use typealias in a protocol to use associatedtype. 2016-03-09 18:08:52 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Slava Pestov
6812b6926b Sema: Cleanups and minor fixes for protocol 'Self' types
We had four duplicated implementations of checking how a protocol
requirement uses 'Self', all slightly wrong or incomplete:

- When deciding if the protocol type can be used as an existential.
  This one would just ignore 'Self' in the return type of a method
  completely, which was incorrect for cases where 'Self' is
  contravariant but part of the return value, for example:

  func foo() -> (Self -> ())

- When deciding if a member access can be performed on an existential
  value. This is distinct from the former, because the member may
  have been defined in a protocol extension, in which case it cannot
  be used even if the protocol type can be used as an existential.
  Unfortunately, this implementation was overly conservative, and
  would reject uses of 'Self' where Sema could in fact erase the
  existential type, for example:

  func foo() -> Self??
  func foo() -> Self.Type
  func foo() -> (Self, Self)

  This function handled function return types correctly, effectively
  plugging the leak in the previous code. It did lead to inconsistent
  behavior with protocols that had contravariant Self in requirements
  though; sometimes we would diagnose uses of the existential type,
  other times we would only complain about specific members.

- When deciding if a method in a non-final class can model a protocol
  requirement. This one was the most elaborate one, but here
  contravariance and uses of associated types are actually okay, so
  it was written to pick up covariant 'Self' only. However, it also
  did not handle metatypes and tuples.

- When opening the type of member of an existential, we would check
  if the return value was 'Self' or an optional of 'Self', but again
  this check was too conservative, so after the previous three were
  fixed, we could reference members on existentials that did not
  have a correct opened type.

Now, these have been combined into one check. To fix some crashes,
Sema's implementation of erasing existentials now relies on
coerceToType() instead of hand-rolling a few coercions of its own,
and wrapping the rest in CovariantFunctionConversionExpr, which
didn't make much sense if the result was not a function type.

SILGen still does not support function type conversions where an
existential return value is being erased; these would silently
miscompile before, but crash with an assertion now, because they
are correctly modeled as a FunctionConversionExpr, and not
CovariantFunctionConversionExpr.
2016-02-28 23:52:35 -08:00
Daniel Duan
2bc78b8c09 [stdlib] update for 'inout' adjustment (SE-0031) 2016-02-26 12:02:29 -08:00
Max Moiseev
0b759a409c Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-23 14:26:14 -08:00
Max Moiseev
481bcabcba [stdlib] API naming guidelines applied to split and join
- `separator` label for first argument of `split`
- `join` and related types are renamed to `joined`
2016-02-22 15:43:33 -08:00
Daniel Duan
e0cc095063 [Parser] updated tests for "expected declaration" companion note 2016-02-19 11:05:03 -08:00
Dmitri Gribenko
98561f6137 stdlib: joinWithSeparator(_:) => join(separator:) 2016-02-18 22:30:57 -08:00
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Slava Pestov
27aad39c79 This test already passes on master 2016-02-11 23:51:47 -08:00
Slava Pestov
3aacf5d805 ArchetypeBuilder: Allow generic signature superclass constraints to contain type parameters
There was a diagnostic to catch these, but it wasn't triggered
reliably, and it sounds like users were already relying on this
feature working in the few cases where it did.

So instead, just map an archetype's superclass into context
when building the archetype.

Recursion is still not allowed and is diagnosed, for example
<T, U where T : C<U>, U : C<T>>.

Note that compiler_crashers_fixed/00022-no-stacktrace.swift no
longer produces a diagnostic in Sema, despite the fact that the
code is invalid. It does diagnose in IRGen when we map the
type into context. Diagnosing in Sema requires fixing the
declaration checker to correctly handle recursion through a
generic signature. Right now, if recursion is detected, we bail
out, but do not always diagnose. Alternatively, we could
prohibit unbound generic types from appearing in generic
signatures.

This is a more principled fix for rdar://problem/24590570.
2016-02-11 23:23:26 -08:00