Commit Graph

731 Commits

Author SHA1 Message Date
Slava Pestov
8e97340816 Fix a compiler_crasher test to not depend on specific diagnostics 2016-06-16 22:39:26 -07:00
Slava Pestov
ac6e335afa XFAIL a compiler_crashers regression
This now fails with the infamous 'Assertion failed: ((conforms ||
replacement->is<ErrorType>() || firstArchetype->getIsRecursive() ||
isOpenedAnyObject(replacement) || replacement->is<GenericTypeParamType>())
&& "Constraint system missed a conformance?")' error.

The actual problem is something with unbound generics and inference
of generic parameters. Here's a minimal test case:

protocol A {}

struct B<f> {}

func a<T:A>() {
  class AA {
    var t:B=B()
  }
}

I'll fix it soon.
2016-06-13 01:22:54 -07:00
Slava Pestov
bbefeb2fc5 Sema: Better support for nested generic functions
There was a weird corner case with nested generic functions that
would fail in the SIL verifier with some nonsense about archetypes
out of context.

Fix this the "right" way, by re-working Sema function declaration
validation to assign generic signatures in a more principled way.

Previously, nested functions did not get an interface type unless
they themselves had generic parameters.

This was inconsistent with methods nested inside generic types,
which did get an interface type even if they themselves did not
have a generic parameter list.

There's some spill-over in SILGen from this change. Mostly it
makes things more consistent and fixes some corner cases.
2016-06-13 01:22:43 -07:00
Slava Pestov
08d5e29ca2 This test no longer crashes after previous patches 2016-06-11 18:15:28 -07:00
Slava Pestov
3127264376 AST: When performing qualified lookup of a member type, filter out non-types earlier
With the previous resolveTypeInContext() patch, a few compiler
crashers regressed with this problem, presumably because we were now
performing lookups in more contexts than before.

This is a class of problems where we would attempt a recursive
validation:

1) Generic signature validation begins for type T
2) Name lookup in type context finds a non-type declaration D nested in T
3) Generic signature validation begins for D
4) The outer generic context of D is T, but T doesn't have a generic
   signature yet

The right way to break such cycles is to implement the iterative
decl checker design. However when the recursion is via name lookup,
we can try to avoid the problem in the first place by not validating
non-type declarations if the client requested a type-only lookup.

Note that there is a small semantic change here, where programs that
were previously rejected as invalid because of name clashes are
now valid. It is arguable if we want to allow stuff like this or not:

class A {
  func A(a: A) {}
}

or

class Case {}
enum Foo {
  case Case(Case)
}

However at the very least, the new behavior is better because it
gives us an opportunity to add a diagnostic in the right place
later. The old diagnostics were not very good, for example the
second example just yields "use of undeclared type 'Case'".
In other examples, the undeclared type diagnostic would come up
multiple times, or we would generate a cryptic "type 'A' used within
its own definition".

As far as I understand, this should not change behavior of any existing
valid code.
2016-06-11 16:27:43 -07:00
Slava Pestov
e8abf54a9a Sema: Fixes for protocol typealiases
This is a big refactoring of resolveTypeInContext() which makes
the function clearer to understand by merging various special
cases and generalizing the logic for walking parent and superclass
contexts to cover more cases.

This improves typealiases in protocols a bit:

1) Previously a typealias in a protocol either had to be concrete,
   or consist of a single path of member types from Self, eg
   Self.A.B. Lift this restriction, so we can now write things like

protocol Fireworks {
  associatedtype Exploding
  typealias Exploder = Exploding -> [Exploding]
}

2) Protocol typealiases can now be accessed via qualified lookup
   on concrete types. Getting this working for unqualified lookup
   requires further refactorings which will be in a subsequent
   patch.
2016-06-11 16:24:14 -07:00
Dmitri Gribenko
14d0be2099 Revert "Sema: Clean up resolveTypeInContext() and generalize typealiases in protocols"
This reverts commit 586288312c.  It broke
tests:

    Swift :: IDE/complete_override_access_control.swift
    Swift :: IDE/complete_value_expr.swift
    Swift :: SourceKit/DocSupport/doc_swift_module.swift
    Swift :: decl/typealias/associated_types.swift
    Swift :: decl/typealias/typealias.swift
2016-06-09 00:06:06 -07:00
Slava Pestov
586288312c Sema: Clean up resolveTypeInContext() and generalize typealiases in protocols
Previously a typealias in a protocol either had to be concrete,
or consist of a single path of member types from Self, eg
Self.A.B. Lift this restriction.

Fix a few other corner cases that came up in the validation
suite, and clean up the function in general.
2016-06-08 20:17:59 -07:00
Argyrios Kyrtzidis
318abe0920 [validation-test] Move a 'compiler_crashers' test to 'compiler_crashers_fixed'.
This may have non-deterministic behavior, but it's not crashing now.
2016-06-06 11:02:01 -07:00
swift-ci
e484845613 Merge pull request #2803 from gregomni/compile-flag 2016-06-01 15:48:40 -07:00
swift-ci
59e247c38a Merge pull request #2637 from JaSpa/inheritance-clause-diags 2016-06-01 15:01:23 -07:00
gregomni
2f9ac3444e Disable typealiases in protocols and add frontend flag to re-enable.
Goes back to Swift 2.2 behavior of treating the 'typealias' keyword inside a protocol as a deprecated form of an associatedtype. To get the newer (but still partly buggy) behavior of treating it as an actual typealias, add "-Xfrontend -enable-protocol-typealiases" to the compile invocation. 'decl/typealias/typealias.swift' now uses this flag to continue testing the enabled behavior.
2016-06-01 14:11:56 -07:00
Chris Lattner
dbbd153759 My recent patch "broke" these tests, but allowing the syntax in them to trigger existing generics bugs. 2016-05-30 16:16:49 -07:00
Erik Eckstein
268ce83460 Revert "Turn off typealiases in protocols."
This reverts commit bda398306b.

It breaks the internal compiler build
2016-05-28 16:04:07 -07:00
gregomni
bda398306b Turn off typealiases in protocols.
Since there still are some holes in this feature, and I haven't had time to
fill them lately: Go back to the 2.2 behavior of treating 'typealias' keyword
in protocols as an associated type, and emit a deprecation warning.

Commented out tests specifically for typealiases in protocols for now, and
random validation tests that crash or not based on whether keyword is interpreted as associatedtype or typealias updated.
2016-05-27 11:38:17 -07:00
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