Commit Graph

9116 Commits

Author SHA1 Message Date
Doug Gregor
5c5c9ac183 Merge pull request #12609 from DougGregor/suppress-eager-init-nscoding-availability
Suppress inference of @_staticInitializeObjCMetadata for "newer" classes
2017-10-25 22:03:15 -07:00
Doug Gregor
587cd4e463 Suppress inference of @_staticInitializeObjCMetadata for "newer" classes.
If a class was introduced in an OS newer than the deployment target,
suppress the inference of @_staticInitializeObjCMetadata, because
the resulting eager initialization will crash when run on older OS's.
This is a stop-gap solution; we want the eager initialization code to
check availability before registering the class, but that requires more
effort.

Fixes the main part of SR-6203 / rdar://problem/35161939.
2017-10-25 17:05:11 -07:00
Slava Pestov
b39a6eda1d Sema: Coerce base to rvalue when calling a DeclViaBridging overload kind
This code path is only used for a special purpose hack to make
NSString members available on String. Since it is rarely
exercised, it was broken.
2017-10-24 20:45:49 -07:00
Graydon Hoare
30b6fdce83 Merge pull request #12429 from graydon/named-lazy-member-loading
Named lazy member loading 1/N
2017-10-24 14:27:04 -07:00
Doug Gregor
44cef72121 Merge pull request #12536 from DougGregor/gsb-requirement-source-without-potential-archetypes
[GSB] Reduce use of potential archetypes when describing constraints
2017-10-23 21:48:20 -07:00
Doug Gregor
a510e9b56d [GSB] Eliminate most uses of PotentialArchetype::getBuilder().
The remaining two uses after this refactor are... stubborn.
2017-10-23 10:39:21 -07:00
Slava Pestov
d2e486b4bd Merge pull request #12573 from slavapestov/validate-fewer-class-members
Validate fewer class members
2017-10-23 00:14:28 -07:00
Slava Pestov
50fa92c8a7 Merge pull request #12567 from gregomni/diagnosis
[Sema] Better ambiguity diagnosis in overloaded function calls
2017-10-22 22:49:39 -07:00
Slava Pestov
31176d713a Sema: Only validate all members of a class if we access one of its members
... Or if we subclass it, or define an extension of it.
2017-10-22 20:05:01 -07:00
Slava Pestov
f34164971e Sema: Ensure that validateDecl() is not called with imported or deserialized declarations 2017-10-22 20:05:01 -07:00
Slava Pestov
d23e2bce62 Sema: Fix a failure to emit a diagnostic in pre-check expression pass
This has been broken for four years at least. What a bummer.

Fixes <rdar://problem/35116378>.
2017-10-22 20:05:00 -07:00
Slava Pestov
58dee864ee Sema: Ensure that checkExtensionGenericParams() and validateGenericTypeSignature() are only called once 2017-10-22 20:05:00 -07:00
gregomni
345c4a933d Save unresolved arg number from callee candidate info, use it to diagnose ambiguity sooner and
more specifically.
2017-10-22 10:32:11 -07:00
Robert Widmann
8bdfb9161c [NFC] Move the non-materializable variable check
Move this from the validation phase into the phase where we check the
binding.  The type checker no longer has to reset the specifier for
VarDecls.
2017-10-22 04:22:09 -04:00
Robert Widmann
ebdd126a2c [NFC] Remove more uses of <InOutType> 2017-10-22 02:00:07 -04:00
Greg Titus
e05f7c992a Merge pull request #12556 from gregomni/diagnosis
[Sema] Fix for wrong callee candidate evaluation for complex args with unresolved parts.
2017-10-21 20:59:20 -07:00
gregomni
cdce937c51 Beginning changes to provide more info out about unresolved params, but even
changing is<UnresolvedType> to hasUnresolvedType turns out is enough to fix a
radar.
2017-10-21 19:33:36 -07:00
Greg Titus
abb6156eb9 Merge pull request #12553 from gregomni/6198
[Sema] When subscripting with a keypath, check for the path being an IUO.
2017-10-21 16:42:27 -07:00
Greg Titus
d2720e3557 Merge pull request #12516 from gregomni/6175
[Sema] Improve subscript diagnostics in assignment destinations
2017-10-21 16:37:10 -07:00
gregomni
a76d74b6d4 When subscripting with a keypath, check for the path being an IUO. 2017-10-21 16:12:28 -07:00
gregomni
18a113e584 We can produce better diagnostics for subscript candidates by noticing when the
subscript is on the destination side of an assignment and restricting matching
overload candidates to only the set-able members.

Also, if we are left with a single candidate, we can recheck unresolved index
expressions with better parameter info.
2017-10-21 14:02:58 -07:00
Timothy J. Wood
a3bd4cf944 Fix formatting. 2017-10-21 09:35:31 -07:00
Timothy J. Wood
cffd2c33e4 Only skip unavailability diagnostics if the platforms match.
Add TypeChecker::isInsideCompatibleUnavailableDeclaration().
Pass in the call site's AvailableAttr and compare its platform to those
in the enclosing lexical scopes.

Added some basic tests.
2017-10-21 09:35:31 -07:00
Timothy J. Wood
cf4d7b711e Possible fix for SR-1226.
Allow calls to explicitly unavailable code when the caller has the
same unavailability.

For example, in a framework compiled with `-application-extension`, this should
be allowed:

	@available(iOSApplicationExtension, unavailable)
	    func x() {
            _ = UIApplication.shared
	    }
	}

since the consumer of the framework, or other call sites within the same
framework will be unable to call the unsafe wrapper in the same situations they
couldn't call the original unsafe code.
2017-10-21 09:35:31 -07:00
Slava Pestov
f2cbe01014 Merge pull request #12547 from slavapestov/redundant-access-control-check
Sema: Remove redundant call to validateAccessControl()
2017-10-21 02:36:51 -07:00
Slava Pestov
2b820fbc2b Sema: Remove redundant call to validateAccessControl() 2017-10-21 01:45:31 -07:00
Slava Pestov
2d477d27eb Sema: Don't create redundant type variables for multiple references to the same closure parameter type 2017-10-20 23:29:17 -07:00
Graydon Hoare
e3f454059a [NamedLazyMemberLoading] Avoid checking protocol-existential conformances. 2017-10-20 22:48:44 -07:00
Slava Pestov
0af734cf1d Sema: Remove a bogus comment 2017-10-20 20:58:40 -07:00
Slava Pestov
7d8c696200 Merge pull request #12495 from gregomni/695
[Sema] Disallow override of dynamic Self return with non-dynamic.
2017-10-18 17:35:21 -07:00
gregomni
7073eb15a4 Disallow override of dynamic Self return type with non-dynamic in a subclass
unless that subclass is final.
2017-10-18 13:07:04 -07:00
Andrew Trick
d369aa4070 Support @noescape SIL function types. (#12420)
Support for @noescape SILFunctionTypes.

These are the underlying SIL changes necessary to implement the new
closure capture ABI.

Note: This includes a change to function name mangling that
primarily affects reabstraction thunks.

The new ABI will allow stack allocation of non-escaping closures as a
simple optimization.

The new ABI, and the stack allocation optimization, also require
closure context to be @guaranteed. That will be implemented as the
next step.

Many SIL passes pattern match partial_apply sequences. These all
needed to be fixed to handle the convert_function that SILGen now
emits. The conversion is now needed whenever a function declaration,
which has an escaping type, is passed into a @NoEscape argument.

In addition to supporting new SIL patterns, some optimizations like
inlining and SIL combine are now stronger which could perturb some
benchmark results.

These underlying SIL changes should be merged now to avoid conflicting
with other work. Minor benchmark discrepancies can be investigated as part of
the stack-allocation work.

* Add a noescape attribute to SILFunctionType.

And set this attribute correctly when lowering formal function types to SILFunctionTypes based on @escaping.

This will allow stack allocation of closures, and unblock a related ABI change.

* Flip the polarity on @noescape on SILFunctionType and clarify that
we don't default it.

* Emit withoutActuallyEscaping using a convert_function instruction.

It might be better to use a specialized instruction here, but I'll leave that up to Andy.

Andy: And I'll leave that to Arnold who is implementing SIL support for guaranteed ownership of thick function types.

* Fix SILGen and SIL Parsing.

* Fix the LoadableByAddress pass.

* Fix ClosureSpecializer.

* Fix performance inliner constant propagation.

* Fix the PartialApplyCombiner.

* Adjust SILFunctionType for thunks.

* Add mangling for @noescape/@escaping.

* Fix test cases for @noescape attribute, mangling, convert_function, etc.

* Fix exclusivity test cases.

* Fix AccessEnforcement.

* Fix SILCombine of convert_function -> apply.

* Fix ObjC bridging thunks.

* Various MandatoryInlining fixes.

* Fix SILCombine optimizeApplyOfConvertFunction.

* Fix more test cases after merging (again).

* Fix ClosureSpecializer. Hande convert_function cloning.

Be conservative when combining convert_function. Most of our code doesn't know
how to deal with function type mismatches yet.

* Fix MandatoryInlining.

Be conservative with function conversion. The inliner does not yet know how to
cast arguments or convert between throwing forms.

* Fix PartialApplyCombiner.
2017-10-17 13:07:25 -07:00
David Zarzycki
835906c543 [Sema] NFC: Simplify type coercion of ClosureExprs
* If we have an updatable ClosureExpr, then both fromEI.isAutoClosure()
  and toEI.isAutoClosure() must be false because the type system ensures
  that normal closures and functions do not convert to auto-closures.
* If we have a throwing ClosureExpr, then fromEI.throws() and
  toEI.throws() must be true, otherwise an erroneous throwing to
  non-throwing closure/function conversions would be possible. From a
  different perspective, updating the 'throws' bit would make sense if
  overloading on 'throws' wasn't possible.
2017-10-16 16:48:08 -04:00
Slava Pestov
d442fb86d4 Merge pull request #12446 from gregomni/6097
[Sema] Extend fix for reference storage types in protocol witnesses to include generics.
2017-10-15 19:03:11 -07:00
gregomni
0188e1cb65 Incorrect condition here resulted in incorrectly trying to optional-wrap for an optional chain to optional lvalue. 2017-10-15 15:31:06 -07:00
gregomni
bee86ea144 Had wrongly disregarded generic conformers in my original fix for sr-6097.
This commit extends that fix.
2017-10-15 02:27:18 -07:00
gregomni
48c57860b9 Disregard any reference storage types when inferring associated types from
witnesses. SR-6097.
2017-10-14 23:32:43 -07:00
Slava Pestov
05c6934609 Sema: Name lookup of protocol typealiases from expression context
Fixes <rdar://problem/34911524>.
2017-10-14 03:12:58 -07:00
Doug Gregor
cd3c63cbfd [AST] Stop including GenericSignature.h in other headers.
Except GenericEnvironment.h, because you can't meaningfully use a
GenericEnvironment without its signature. Lots less depends on
GenericSignature.h now. NFC
2017-10-12 14:23:46 -07:00
Greg Titus
bec95b2caa Merge pull request #12368 from gregomni/callee
[Sema] Some cleanup of CSDiag by splitting off the CalleeCandidateInfo class
2017-10-12 13:24:33 -07:00
gregomni
774dbdfa87 Some cleanup of CSDiag by splitting off the CalleeCandidateInfo class and
declaring a few formerly static methods that both files now need in a new
CSDiag.h.
2017-10-11 13:03:48 -07:00
Huon Wilson
ec6c83aa44 [Sema] Check conditional conformances for generic function calls early.
This allows for better (although not perfect) diagnostics, and more guarantees
of correctness.
2017-10-10 20:17:42 -07:00
Huon Wilson
1dee31fe2b [GSB] subst Requirements directly; no need for the extra argument. 2017-10-10 20:17:42 -07:00
Huon Wilson
a1b2cded09 [Sema] Add two FIXMEs. 2017-10-10 20:17:41 -07:00
Huon Wilson
f6729f17d6 [Sema] Add conditional requirements as CS constraints.
This tries to feed through the constraint system all the constraints
implied by a concrete type satisfying a conformance requirement.
2017-10-10 20:17:41 -07:00
Huon Wilson
8e50a1666f [AST&Sema] Add assertions for conditional conformances.
These are just places that may need updating for conditional
conformances, and so having them flag eagerly will help in future.
2017-10-10 20:17:41 -07:00
Huon Wilson
5ede600a6b [Sema/CS] Thread conditional requirements through specialization checking. 2017-10-10 20:17:41 -07:00
Huon Wilson
96172048d3 [Sema/CS] Convenience function for adding a Requirement as a constraint. 2017-10-10 20:17:40 -07:00
Huon Wilson
ade976893e [AST] Test conditional requirement selection by having -debug-generic-signatures include conformances.
And make conformances' dump include the conditional requirements too.
2017-10-10 20:17:39 -07:00
Huon Wilson
945f723d59 [AST] Compute conditional requirements in a conformance.
This allows determining which requirements make a conformance conditional; as
in, which requirements aren't known as part of the type itself.

Additionally, use this to assert that a few builtin protocols aren't
conditionally-conformed-to, something we won't support for now.
2017-10-10 20:17:39 -07:00