Commit Graph

305 Commits

Author SHA1 Message Date
Owen Voorhees
77aa5642c3 [Diagnostics] Expand test coverage of existing edu notes 2020-04-09 18:18:25 -07:00
Artem Chikin
1b11e8798c [IRGen] Skip witness table query for protocols that do not require one
Some protocols, such as protocols marked with 'objc', do not have a Witness Table.
The code before this patch assumes all protocols do have a Witness Table when generating the layout of an OpaqueTypeDescriptor, causing an assert to be triggered for opaque return types that conform to an 'objc' protocol.

Fixes SR-12257 / rdar://problem/59740179
2020-03-31 10:56:20 -07:00
Pavel Yaskevich
0ecedfa5ea Revert "[ConstraintSystem] Make it possible to infer subtype bindings through argument conversions"
Reverts apple/swift#30006. It caused a regression that we'd like to address before re-landing:

```swift
struct X {
  var cgf: CGFloat
}

func test(x: X?) {
  let _ = (x?.cgf ?? 0) <= 0.5
}
```

This reverts commit 0a6b444b49.
This reverts commit ed255596a6.
This reverts commit 3e01160a2f.
This reverts commit 96297b7e39.

Resolves: rdar://problem/60185506
2020-03-07 20:16:56 -08:00
Pavel Yaskevich
b926250c70 Merge pull request #30006 from xedin/rdar-56212087
[ConstraintSystem] Make it possible to infer subtype bindings through argument conversions
2020-02-24 14:18:35 -08:00
Nate Cook
c6183ee71b Add RangeSet and discontiguous collection operations (#28161)
This adds the RangeSet and DiscontiguousSlice types, as well as collection
operations for working with discontiguous ranges of elements. This also adds
a COWLoggingArray type to the test suite to verify that mutable collection
algorithms don't perform unexpected copy-on-write operations when mutating
slices mid-operation.
2020-02-22 15:33:03 -06:00
Pavel Yaskevich
96297b7e39 [CSStep] Always attempt literal bindings in diagnostic mode
In case of contextual failures such bindings could produce
better solutions with fewer fixes.
2020-02-21 17:47:39 -08:00
Slava Pestov
eaee6faa00 Sema: Prefer an outer type named 'Self' over the SE-0068 behavior
This fixes a recent source break. We need to perform the normal
unqualified lookup before we handle the special case of 'Self',
because there might be a type named Self defined in an outer
context.

Fixes <https://bugs.swift.org/browse/SR-12133> / <rdar://problem/59216636>
2020-02-17 22:24:40 -05:00
Pavel Yaskevich
60a210b657 [ConstraintSystem] NFC: Fix a couple of typos in comments 2020-02-13 00:44:20 -08:00
Pavel Yaskevich
5437622d2d [Diagnostics] Diagnose ambiguity with conflicting arguments to generic parameters
It's done by first retrieving all generic parameters from each solution,
filtering boundings into distrinct set and diagnosing any differences.

For example:

```swift
func foo<T>(_: T, _: T) {}
func bar(x: Int, y: Float) {
  foo(x, y)
}
```
2020-02-12 17:53:31 -08:00
Holly Borla
651c27b50b [Diagnostics] Add CSFix::diagnoseForAmbiguity for diagnosing common
fixes that appear in all solutions.
2020-02-11 14:53:27 -08:00
Luciano Almeida
46092aff3e [tests] Adjusting tests under type/opaque 2020-02-10 07:48:34 -03:00
Pavel Yaskevich
0103041a30 [ConstraintSystem] Tidy up restriction handling in contextual failures
Delay "fixing" contextual conversion failures until restriction is applied
this helps to tidy up logic for superclass and existential conversions.

Too bad we have to "fix" in `simplifyRestrictedConstraintImpl` now but
we can't really do much about that because diagnostics need both top-level
types to be useful.
2020-02-05 12:11:01 -08:00
Slava Pestov
9bd638579d Sema: Fix duplicate diagnostic spam with 'Self' in properties
Fixes <https://bugs.swift.org/browse/SR-11681> / <rdar://problem/56747659>.
2020-01-29 22:11:20 -08:00
Pavel Yaskevich
e50756c10c [CSDiag] Obsolete function re-typecheck and diagnostics from visitApplyExpr 2020-01-27 17:18:30 -08:00
Suyash Srijan
8ee7fc7627 [Parse] Emit a fix-it to move 'some' to the beginning of protocol composition 2020-01-17 19:46:26 +00:00
Holly Borla
834eee6f4e [Diagnostics] Implement MissingArgumentsFailure::diagnoseAsNote in order
to diagnose ambiguities due to missing arguments.
2020-01-07 17:37:38 -08:00
Luciano Almeida
6093bafd8e [tests] Fix diagnostic (TODO) 2020-01-04 16:01:06 -03:00
Robert Widmann
c4f833ed5c Run checkPatternBindingCaptures on Extensions
Resolves rdar://57348897
2019-11-20 14:44:21 -08:00
Holly Borla
7f2d4c0a99 [CSApply] When applying constraint fixes for a solution, only coalesce
fixes of the same kind.
2019-11-11 10:08:25 -08:00
Pavel Yaskevich
cb3a0fbcc8 [ConstraintSystem] Extend use of the treat r-value as l-value fix to more cases
Cover not only immutability but also type mismatch cases and clarify
behavior when one of the sides of the type conversion is optional.
2019-11-05 12:38:13 -08:00
Pavel Yaskevich
58329e0c27 Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. " 2019-10-25 01:05:07 -07:00
Luciano Almeida
5d1eeacbe4 Resolving conflicts 2019-10-23 07:25:55 -03:00
Luciano Almeida
86ca3454d6 Fixing warning UnnecessaryCoercion tests 2019-10-21 23:11:21 -03:00
Jordan Rose
91664f203e Merge pull request #27732 from JGiola/SR-6717
SR-6717 Builtin types are always be printed with Builtin prefix
2019-10-21 09:42:06 -07:00
Jacopo Andrea Giola
afca797192 Builtin types are always be printed with Builtin prefix
ASTPrinter now ignore the Options.FullyQualifiedTypesIfAmbiguous
value if the containing module is the builtin one.
2019-10-19 10:39:16 +02:00
Holly Borla
e5c99cace6 Merge pull request #27769 from hborla/anyobject-conformance-failure
[ConstraintSystem] Diagnose missing AnyObject conformance using the MissingConformance constraint fix.
2019-10-18 22:10:21 -04:00
Holly Borla
ea7c13e506 [Diagnostics] For now, don't diagnose layout requirement failures
in MissingConformanceFailure::diagnoseTypeCannotConform.
2019-10-18 14:00:18 -07:00
Holly Borla
ef0ecc41e5 [ConstraintSystem] Diagnose missing AnyObject conformance using
the MissingConformance constraint fix.
2019-10-16 20:38:00 -07:00
Luciano Almeida
73dcc4b5e8 Merge branch 'master' of https://github.com/apple/swift into force-downcast-fix-explicit-coercion 2019-10-15 19:18:46 -03:00
Rintaro Ishizaki
e00fc0ce73 Revert "Merge pull request #27040 from rintaro/syntaxparse-rdar55075237"
This reverts commit 6e49443a91, reversing
changes made to 99d8042a70.
2019-10-14 13:42:58 -07:00
Pavel Yaskevich
d90117bb8a [Diagnostics] Remove argument handling from conformance failures
Argument-to-Parameter mismatch handles conformance failures
related to arguments, so the logic in `MissingConformanceFailure`
which wasn't entirely correct is now completely obsolete.

Resolves: rdar://problem/56234611
2019-10-14 00:34:37 -07:00
Luciano Almeida
8f7e929c93 Fixing tests under test/ClangImporter 2019-10-12 23:45:17 -03:00
Holly Borla
bf80250c84 Merge remote-tracking branch 'upstream/master' into type-cannot-conform-diag 2019-09-17 11:54:03 -07:00
Holly Borla
7687293b7b [Diagnostics] Adjust the description of existential types for the
type_cannot_conform diagnostic message.
2019-09-17 11:52:43 -07:00
Holly Borla
2a7e0099d2 [Diagnostics] Add notes for the type_cannot_conform error that point
to the declaration that requires protocol conformance.
2019-09-17 09:22:07 -07:00
Holly Borla
173e4526ee [Diagnostics] Adjust wording of type_cannot_conform error message. 2019-09-16 14:55:38 -07:00
Pavel Yaskevich
88c39db0c3 [Diagnostics] NFC: Fix improved test-cases related to argument-to-parameter mismatches 2019-09-13 22:35:53 -07:00
Pavel Yaskevich
25d7a07323 [ConstraintSystem] Adjust a couple of places not to fail immediately in diagnostic mode
Some spots of constraint simplification logic are too eager to
fail right away without giving repair logic to run in diagnostic
mode and attempt to fix the problem. Failing early in diagnostic
mode means solver wouldn't be able to reach some possible
solutions which leads to subpar diagnostics.
2019-09-13 22:35:52 -07:00
Pavel Yaskevich
a1643d94f7 [Diagnostics] NFC: Update all of the improved test-cases 2019-09-13 22:35:52 -07:00
Holly Borla
40985b6eb7 [Diagnostics] Generalize the "protocol type cannot conform" error to
work for all types that cannot conform to protocols.
2019-09-13 14:51:17 -07:00
Holly Borla
0434d58ff0 Merge pull request #27123 from hborla/missing-conformance-diag
[ConstraintSystem] Allow fixing missing conformance failures for `Void` and uninhabited types.
2019-09-12 17:41:19 -07:00
Doug Gregor
1d6af84a63 [Type checker] Allow 'Self' reference in a lazy initializer.
Fixes rdar://problem/51561208
2019-09-12 08:36:03 -07:00
Holly Borla
85f367909e [Test] Add a simple test case for a method with an opaque return type
and no return statements.
2019-09-11 12:35:21 -07:00
Holly Borla
b9367d10cf [ConstraintSystem] Allow fixing missing conformance failures for
`Void` and uninhabited types.
2019-09-11 12:10:19 -07:00
Rintaro Ishizaki
dba6514092 [SyntaxParse] Set token kind as 'identifier' in consumeIdentifierSyntax
rdar://problem/55075237
2019-09-05 11:51:51 -07:00
Pavel Yaskevich
589ebac1b2 [Diagnostics] Lift all restrictions from invalid generic arguments fix expect to optional types
This helps us to better diagnose failures related to generic
requirements like `T == [Int]` as well as protocol compositions,
which require deep equality check.
2019-08-20 10:50:17 -07:00
Pavel Yaskevich
129092eea4 [Diagnostics] NFC: Adjust couple of regressed diagnostics related to protocol composition 2019-08-13 18:33:29 -07:00
Arnold Schwaighofer
1d891fe64e Sema: Compare canonical bound signatures when comparing opaque type archetypes for dynamic replacement
rdar://53610474
2019-08-08 11:49:01 -07:00
Joe Groff
378eb96555 Sema: Fix substitution of opaque types with generic base class constraints.
They weren't always mapped out of context before building the interface type for the opaque
type decl, and we failed to substitute the base class constraint when forming an opaque archetype
with specific substitutions. Fixes rdar://problem/53318811.
2019-07-29 12:30:12 -07:00
Jordan Rose
d3193f8e23 Merge pull request #26149 from theblixguy/fix/SR-11134
[Parser] Diagnose use of subscript inside an array literal
2019-07-18 10:04:22 -07:00