Commit Graph

184 Commits

Author SHA1 Message Date
Doug Gregor
93435d17d6 [Substitution Map] Handle substitutions of generic parameters made concrete.
If SubstitutionMap is asked to form a substitution for a generic
parameter that has been made concrete by the generic signature,
substitute into the concrete type. This allows us to better deal with
non-canonical types.
2017-04-28 16:22:07 -07:00
Doug Gregor
29a15ce402 [Stdlib] Apply SE-0142 to fix ABI FIXME #92, part of ABI FIXME #99. 2017-04-19 23:15:33 -07:00
Slava Pestov
60998cbb50 Merge pull request #8842 from slavapestov/new-test
Add a regression test
2017-04-18 14:58:47 -07:00
Slava Pestov
b450552c26 Add a regression test 2017-04-18 14:10:56 -07:00
Doug Gregor
d21d6f1585 [Generic environment] Only substitute top-level archetypes.
The core substitution routine for the archetypes-to-interface types
substitution was attempting to provide mappings for nested archetypes,
when in fact these archetypes would (1) always be resolvable via their
parent, and (2) could in fact cause infinite recursion, as with the
new test case. Fixes SR-4617 / rdar://problem/31673819.
2017-04-18 13:19:21 -07:00
Max Moiseev
9b53efd72c Merge branch 'master' into new-integer-protocols 2017-04-17 09:53:44 -07:00
Doug Gregor
4ed8bf5532 New test requires ObjC support 2017-04-17 06:15:25 -07:00
Doug Gregor
a892e89922 [GSB] Simplify and clean up RequirementSource::isSelfDerivedSource().
Reimplement isSelfDerivedSource() in terms of the new
visitPotentialArchetypesAlongPath(). Aside from being clearer and
shorter, this formulation eliminates some hackery (the direct
"NestedType" lookup) that was mostly masking a bug in
updateNestedTypeForConformance() where we created a
nested-type-name-match source with an incorrect source for the
purposes of concretizing the nested type.

Fixes SR-4458 / rdar://problem/31375569.
2017-04-16 23:05:28 -07:00
Doug Gregor
8dfc25edc7 [GSB] Filter out conformance constraints derived from concrete conformance.
When an otherwise abstract conformance constraint is derived from a
concrete conformance, retain the abstract conformance by removing the
requirement source that involves the concrete conformance. This
eliminates our reliance on the concrete conformance, which is not
retained as part of the generic signature.

Fixes rdar://problem/31163470 and rdar://problem/31520386.
2017-04-16 23:05:23 -07:00
Max Moiseev
022665547b Merge branch 'master' into new-integer-protocols 2017-04-07 14:42:53 -07:00
Slava Pestov
51d7723640 Add regression test for a bug that's already fixed 2017-04-06 15:56:41 -07:00
Max Moiseev
8fe28b4e32 Merge branch 'master' into new-integer-protocols 2017-04-06 10:22:37 -07:00
Doug Gregor
44c2f849d6 [Type checker] Continue validating requirements after an error.
We want to validate both type in same-type or conformance constraints,
even when the first type is ill-formed, so we don't leave null types
around for later phases to crash on.

Fixes rdar://problem/31093854.
2017-04-05 14:05:59 -07:00
Max Moiseev
52882c47b4 Merge branch 'master' into new-integer-protocols 2017-04-05 11:26:13 -07:00
Roman Levenstein
75c8274fd9 Fix tests 2017-04-04 13:10:43 -07:00
Max Moiseev
42095bfbaa Merge branch 'master' into new-integer-protocols 2017-04-04 11:00:47 -07:00
Slava Pestov
9db6b10059 AST: Targeted fix for conformance lookup issue
When substituting a type like T.A.B where A and B are
associated types and the conformance requirement on T.A
is implied by conformance requirements on T, we would
crash.

The problem is that we have no way of representing an
abstract conformance with nested concrete types.

This patch adds a workaround that we can live with until
ConformanceAccessPaths are plumbed through all the way.

Fixes <rdar://problem/30737546> and
<https://bugs.swift.org/browse/SR-3500>.

Possibly fixes <rdar://problem/31334245>.
2017-04-03 15:35:10 -07:00
Max Moiseev
969b4814e2 Merge branch 'master' into new-integer-protocols 2017-03-27 20:40:15 -07:00
Slava Pestov
19b12aa3b1 Sema: Fix convenience init delegation to a convenience init in a generic base class
While in the constraint system, the delegation is modeled as
returning an instance of the derived class, in the AST we type
the reference as returning an instance of the base class, and
insert a downcast, because in SILGen we're calling the base
class initializer which is typed as returning the base class.

This bit of fixup logic wasn't happening if the base class was
generic, and so we were not inserting the cast, which would
crash in SILGen with an assert.

Fixes <rdar://problem/31000248>.
2017-03-26 00:00:53 -07:00
Max Moiseev
ec8e286b5c Merge branch 'master' into new-integer-protocols 2017-03-24 14:14:00 -07:00
Doug Gregor
c4735314d1 Add test for SR-4016 / rdar://problem/30677848, which is now fixed. 2017-03-24 11:36:45 -07:00
Max Moiseev
b9fb3badc8 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-03-22 12:30:24 -07:00
Slava Pestov
a3a290eb60 Mangling: Fix bug in the logic for dropping same-type constraints
It's not correct to drop a constraint if one of the two types
structurally contains generic parameters at the method depth.
2017-03-21 00:15:18 -07:00
Doug Gregor
87dab47d5d [HACK] XFAIL a crasher that was passing due to bogus canonicalization
This test was passing for the wrong reasons before. We need to
correctly model cases where a nested type of an abstract conformance is
in fact concrete and, therefore, has concrete conformances. XFAIL for now.
2017-03-16 23:16:32 -10:00
John McCall
22382f7e15 Reimplement associated conformance IRGen using Doug's conformance
access path work.

Having done so, simplify archetype TypeInfos by removing a now-
unnecessary layer of abstraction.
2017-03-14 03:48:10 -04:00
Max Moiseev
7d73b2e1ca Arithmetic => Numeric 2017-03-13 11:50:02 -07:00
Slava Pestov
068f3a18da Sema: Fix crash if we try to look up constructors while validating a constructor
addImplicitConstructors() will crash if validateDecl() does not produce
a valid signature for one of the class's constructors because the
constructor is already being validated.

This was triggered during associated type inference in the test case
in the radar.

Fixes <rdar://problem/30751491>.
2017-03-13 01:50:41 -07:00
Slava Pestov
3ab7c7283d Sema: Allow protocol typealiases to witness associated type requirements
When resolving a type witness by lookup, also consider protocol members.

Fixes <rdar://problem/30442622>.
2017-03-13 01:19:45 -07:00
Max Moiseev
8ffbc81239 Fixing some validation tests 2017-03-10 17:09:28 -08:00
Doug Gregor
56ffacca7e Add fixed compiled crasher from rdar://problem/30702721. 2017-03-03 10:50:49 -08:00
Doug Gregor
f74763d933 [Type checker] Teach areOverrideCompatibleSimple() to look at initializers.
Apply the same is-generic check to initializers that we apply to
functions when establishing basic override compatibility. This is a
simple optimization for master, but fixes a crasher for Swift 3.1.

Fixes SR-4059.
2017-02-27 13:34:49 -08:00
Slava Pestov
412c71d8c2 Add some crashers
One is already fixed so let's make sure it won't regress again; the
other two are pending some improvements to GenericSignatureBuilder.
2017-02-25 16:17:28 -08:00
Slava Pestov
cd893ea84a AST: Fix GenericSignatureBuilder bug with protocol typealiases
If a nested type of a generic parameter was a typealias, and the
generic parameter was not at depth 0, index 0, we would resolve
the type down to the wrong PotentialArchetype, causing bogus
diagnostics and crashes.

Make sure we apply a substitution to the typealias's underlying
type before resolving it, to map it to the correct PotentialArchetype.

Note that the original test case in the radar works now, but the more
comprehensive test I added exposes an existing problem where generic
signature canonicalization is not idempotent. When this is fixed,
the RUN: line in the test can be changed from -typecheck to -emit-ir.

Fixes <rdar://problem/30248571>.
2017-02-17 14:53:18 -08:00
Slava Pestov
129024e634 Add regression test for a bug that got fixed along the way 2017-02-12 00:51:25 -08:00
Slava Pestov
6874b89550 Add regression test for a bug that seems to be fixed 2017-02-08 15:45:27 -08:00
Slava Pestov
f166bb3295 Fix numbering compiler_crashers_2_fixed test cases 2017-02-08 15:43:08 -08:00
swift-ci
fabac930e9 Merge pull request #7304 from DougGregor/sr-3857 2017-02-07 10:03:42 -08:00
Doug Gregor
87b25ef4d3 Add test for fixed crasher in SR-3857 / rdar://problem/30361930.
Recent improvements fixed this crasher that manifested in
IRGen.
2017-02-07 06:21:48 -08:00
Jordan Rose
898940c2dd Extensions of imported classes never provide overriding initializers. (#7284)
This addresses a crash where the compiler asks if an imported class
inherits initializers from its superclass /during the SIL passes/. In
this particular arrangement of subclasses and initializers (see test
case), this leads to us importing members of an Objective-C class for
the first time well after we've destroyed the type checker, and then
checking to see if an initializer added in a Swift extension can
prevent initializer inheritance. That initializer hasn't been
type-checked (because it's in another file and isn't supposed to
affect anything), and so the compiler chokes. A spot fix would merely
check for 'resolver' here and skip over the initializer if it doesn't
have a type, but it's not clear what the right semantics are in that
case.

The real issue here is that we don't support importing new declarations
after the type checker has been torn down, and that keeps causing us
problems, but that's a much bigger thing to fix.

https://bugs.swift.org/browse/SR-3853
2017-02-06 16:26:13 -08:00
Rintaro Ishizaki
abeaaeb42f [Parse] Fix potential crasher regarding EndLoc of erroneous 'type(of:)' expr 2017-02-02 17:13:14 +09:00
Slava Pestov
f9789ce5a8 AST: Fix compareDependentTypes() for protocol typealiases
We must order protocol typealiases *after* other types, so that
if a protocol typealias is equal to an associated type, the
representative is chosen to be the associated type and not the
typealias.

Fixes <https://bugs.swift.org/browse/SR-3687> and
<rdar://problem/30118513>.
2017-01-26 21:33:25 -08:00
Jordan Rose
25e40d0a57 Use interface types when checking #keyPath. (#7028)
This avoids a crash when the path refers to a property in another
Swift module.

https://bugs.swift.org/browse/SR-3714
2017-01-25 19:29:42 -08:00
Slava Pestov
8ad5504fe0 SILGen: Relax assertion in tuple-to-optional function result conversion
Now that optional payloads can be re-abstracted, there's a case
where we need to do a tuple-to-tuple conversion on a direct result;
if the result is wrapped in an Optional. So I believe this assert
is not right.

Fixes <https://bugs.swift.org/browse/SR-3706>.
2017-01-24 18:47:21 -08:00
Slava Pestov
8109cf7187 Add regression test for a bug that's already been fixed 2017-01-23 23:54:50 -08:00
practicalswift
8c2b87bce0 [gardening] Add correct copyright notices 2017-01-07 20:32:18 +01:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Slava Pestov
51d4869473 Add a regression test for <https://github.com/apple/swift/pull/6536>
The PR added a Sema test with a minimal test case; add a bigger test
more closely resembling the original snippet and make sure it gets
all the way through IRGen.
2017-01-05 18:00:45 -08:00
Slava Pestov
58228d3a6e Add regression test for a radar that got fixed along the way 2017-01-05 18:00:39 -08:00
Slava Pestov
3cbc08cc4e AST/SIL: Fix problems if protocol requirement signature makes Self : P conformance implicit
Fixes assertion failures in SILGen and the optimizer with this
exotic setup:

protocol P {
  associatedtype T : Q
}

protocol Q {
  func requirement<U : P>(u: U) where U.T == Self
}

Here, we only have a U : P conformance, and not Self : Q,
because Self : Q is available as U.T : Q.

There were three problems here:

- The SIL verifier was too strict in verifying the generic signature.
  All that matters is we can get the Self parameter conformance, not
  that it's the first requirement, etc.

- GenericSignature::getSubstitutionMap() had a TODO concerning handling
  of same-type constraints -- this is the first test-case I've found
  that triggered the problem.

- GenericEnvironment::getSubstitutionMap() incorrectly ignored
  same-type constraints where one of the two types was a generic
  parameter.

Fixes <https://bugs.swift.org/browse/SR-3321>.
2017-01-04 02:28:55 -08:00
Slava Pestov
412559af79 Add test cases for a few bugs that seem to be fixed already
Cleaning out some old JIRAs, don't want these to regress...
2017-01-04 02:02:29 -08:00