Commit Graph

9 Commits

Author SHA1 Message Date
Michael Gottesman
d4e09b0944 [silgen] Add an extra swift-version 5 run to initializer tests.
We currently run these in swift-version 4 by default. This caused us to miss
some bugs that only occur in swift-version 5 due to initializer changes
happening in swift 5. This at least will allow us to catch such issues in the
future.

NOTE: I am also going to change objc_throwing_initializers.swift in the same
way, but after I fix the bugs that adding -swift-version 5 exposes therein
(which is actually <rdar://problem/59830255>)
2020-05-19 11:47:08 -07:00
Arnold Schwaighofer
6eca97add6 Codesign test/Interpreter 2018-08-10 06:58:40 -07:00
Erik Eckstein
2da8a2dece tests: re-enable test/Interpreter/protocol_initializers.swift for linux
And update Jira link for test/stdlib/ErrorHandling.swift
2018-03-08 10:37:27 -07:00
Erik Eckstein
6cf75f592f tests: disable 2 tests on linux which fail in optimized mode.
Until we fix this, I'd like to enable optimized mode testing on linux
2018-03-07 17:28:38 -07:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Slava Pestov
09b59c5336 DI: More tests 2017-10-20 16:10:32 -07:00
Slava Pestov
c22c208a67 Correctly pass -swift-version 5 in test/Interpreter/protocol_initializers.swift 2017-08-26 02:04:07 -07:00
Slava Pestov
6f6974654a Sema: Fix type safety hole with convenience initializers which delegate to protocol extension initializers
A protocol extension initializer creates a new instance of the
static type of Self at the call site.

However a convenience initializer in a class is expected to
initialize an instance of the dynamic type of the 'self' value,
because convenience initializers can be inherited by subclasses.

This means that when a convenience initializer delegates to a
protocol extension initializer, we have to substitute the
'Self' type in the protocol extension generic signature with
the DynamicSelfType, and not the static type.

Since the substitution is formed from the type of the 'self'
parameter in the class convenience initializer, the solution is
to change the type of 'self' in a class convenience initializer
to DynamicSelfType, just like we do for methods that return
'Self'.

This fixes cases where we allowed code to type check that
should not type check (if the protocol extension initializer
has 'Self' in contravariant position, and we pass in an
instance of the static type).

It also fixes a miscompile with valid code -- if the protocol
extension initializer was implemented by calling 'Self()',
it would again use the static type and not the dynamic type.

Note that the SILGen change is necessary because Sema now creates
CovariantReturnExprs that convert a static class type to
DynamicSelfType, but the latter lowers to the former at the
SIL level, so we have to peephole away unnecessary unchecked_ref_cast
instructions in this case.

Because this change breaks source compatibility, it is guarded
by a '-swift-version 5' check.
2017-08-26 01:18:35 -07:00
Slava Pestov
960b8e9cd0 DI: New way of modeling factory initializers
Previously, we were only able to detect factory initializers
dispatched through class_method. This didn't work for
factory initializers defined in protocol extensions.

The end result would be that we would strong_release an
uninitialized class instance, which could cause crashes.

Fix DI to correctly release the old instance using
dealloc_partial_ref instead.

Fixes <rdar://problem/27713221>.
2016-08-13 01:51:45 -07:00