Skip to content

[pull] swiftwasm-release/5.3 from release/5.3 #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d48e50f
GSB: Concretize nested types when adding a superclass constraint
slavapestov May 16, 2020
7d2a240
[Diagnostics] Diagnose that we cannot infer the key path type when bi…
LucianoPAlmeida May 11, 2020
cd20d14
[CS] Don't leave key path with holes unsolved
hamishknight May 15, 2020
9ff09b0
[5.3] IRGen: Only replace opaque result types of function result type…
aschwaighofer May 15, 2020
12a5243
Merge pull request #31836 from slavapestov/gsb-superclass-nested-type…
slavapestov May 18, 2020
12693d5
[AST] Restore getSourceRange() on DefaultArgumentExpr.
May 18, 2020
ea0af30
Merge pull request #31862 from hamishknight/solved-holistically-5.3
tkremenek May 18, 2020
c1dac75
Merge pull request #31858 from aschwaighofer/opaque_result_type_dyn_r…
tkremenek May 18, 2020
bf1774b
[SIL] Use Limit::OnDemand for an enum element in SILDeclRef::getLinkage
theblixguy May 18, 2020
6e4c88d
[TBDGen] Emit case symbols only if enum is resilient and some other f…
theblixguy May 18, 2020
f72232e
[Test] Add some TBDGen test cases for enum case witnesses
theblixguy May 18, 2020
ebe40b0
[Test] Update a SILGen test
theblixguy May 19, 2020
01106c5
SIL: Fix witness visibility hack to handle non-serialized declarations.
jckarter Apr 28, 2020
a0fa529
No dummy constraint in the public swiftinterface for SPI extensions
xymus May 19, 2020
4eac5a1
Merge pull request #31886 from theblixguy/fix/SR-12821-5.3
tkremenek May 19, 2020
43a607c
Merge pull request #31873 from nathawes/default-arg-location-sourcelo…
tkremenek May 19, 2020
deefd5e
Merge pull request #31897 from xymus/fix-dummy-constraint-5.3
DougGregor May 20, 2020
0a23698
[CodeCompletion] Avoid suggesting duplicated module names
rintaro May 19, 2020
dbca463
[5.3] IRGen: Correctly compute the offset for a non-fixed field after…
aschwaighofer May 18, 2020
ac783dd
Merge pull request #31917 from rintaro/5.3-ide-completion-duplicatedm…
tkremenek May 20, 2020
b981b7e
Merge pull request #31924 from aschwaighofer/irgen_fix_heaplayout_emp…
aschwaighofer May 20, 2020
325e1aa
[5.3] IRGen: Fix enumPayload value witness emission for huge types
aschwaighofer May 20, 2020
9676d66
[Typechecker] Emit a specialized diagnostic for redeclaration errors …
theblixguy May 20, 2020
51183c2
[Test] Update existing tests
theblixguy May 20, 2020
17d1ce9
[Typechecker] Diagnose the original wrapped property instead of the n…
theblixguy May 20, 2020
cc61a3b
[Typechecker] Do not diagnose redeclarations when both declarations a…
theblixguy May 20, 2020
2c64c47
[Test] Update existing tests
theblixguy May 20, 2020
65a35bc
[SourceKit/CodeFormat] Don't column-align PatternBindingDecl entries …
May 21, 2020
a242ad8
Merge pull request #31938 from theblixguy/fix/SR-12839-5.3
tkremenek May 21, 2020
63f91d1
PrintAsObjC: Fix crash when printing typedef that was imported inside…
slavapestov May 21, 2020
508b217
Merge pull request #31935 from aschwaighofer/irgen_enum_witness_huge_…
tkremenek May 21, 2020
20dbf50
[Property Wrappers] Fix ParamDecl::getDefaultValueStringRepresentation
hborla May 21, 2020
f8cf96e
[Property Wrappers] For properties that are implicitly default initia…
hborla May 21, 2020
90b03aa
[NFC] Fix 'Traling' typo
xwu May 21, 2020
9e77c9a
Merge pull request #31958 from hborla/5.3-property-wrapper-default-init
hborla May 22, 2020
8397013
Merge pull request #31948 from slavapestov/print-as-objc-generic-type…
tkremenek May 22, 2020
32b2521
Merge pull request #31945 from nathawes/pattern-binding-decl-indentat…
tkremenek May 22, 2020
1a5d3bf
Merge pull request #31959 from xwu/tralala-5.3
tkremenek May 22, 2020
3de36cb
[ConstraintSystem] Disallow use of enum case as a key path component …
theblixguy May 22, 2020
8bca08c
ASTDemangler: Add support for member types of opaque result types
slavapestov May 23, 2020
7b01206
Merge pull request #31990 from slavapestov/demangle-nested-type-of-op…
slavapestov May 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5217,6 +5217,12 @@ class VarDecl : public AbstractStorageDecl {
Optional<PropertyWrapperMutability>
getPropertyWrapperMutability() const;

/// Returns whether this property is the backing storage property or a storage
/// wrapper for wrapper instance's projectedValue. If this property is
/// neither, then it returns `None`.
Optional<PropertyWrapperSynthesizedPropertyKind>
getPropertyWrapperSynthesizedPropertyKind() const;

/// Retrieve the backing storage property for a property that has an
/// attached property wrapper.
///
Expand Down
16 changes: 16 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ ERROR(could_not_find_value_dynamic_member_corrected,none,
ERROR(could_not_find_value_dynamic_member,none,
"value of type %0 has no dynamic member %2 using key path from root type %1",
(Type, Type, DeclNameRef))
ERROR(cannot_infer_contextual_keypath_type_specify_root,none,
"cannot infer key path type from context; consider explicitly specifying a root type", ())
ERROR(cannot_infer_keypath_root_anykeypath_context,none,
"'AnyKeyPath' does not provide enough context for root type to be inferred; "
"consider explicitly specifying a root type", ())

ERROR(could_not_find_type_member,none,
"type %0 has no member %1", (Type, DeclNameRef))
Expand Down Expand Up @@ -552,6 +557,9 @@ ERROR(expr_keypath_mutating_getter,none,
ERROR(expr_keypath_static_member,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to static member %0",
(DeclName, bool))
ERROR(expr_keypath_enum_case,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to enum case %0",
(DeclName, bool))
ERROR(expr_keypath_empty,none,
"empty key path does not refer to a property", ())
ERROR(expr_unsupported_objc_key_path_component,none,
Expand Down Expand Up @@ -755,12 +763,20 @@ ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
ERROR(invalid_redecl_init,none,
"invalid redeclaration of synthesized %select{|memberwise }1%0",
(DeclName, bool))
ERROR(invalid_redecl_implicit,none,
"invalid redeclaration of synthesized "
"%select{%0|implementation for protocol requirement}1 %2",
(DescriptiveDeclKind, bool, DeclName))
WARNING(invalid_redecl_swift5_warning,none,
"redeclaration of %0 is deprecated and will be an error in Swift 5",
(DeclName))

NOTE(invalid_redecl_prev,none,
"%0 previously declared here", (DeclName))
NOTE(invalid_redecl_implicit_wrapper,none,
"%0 synthesized for property wrapper "
"%select{projected value|backing storage}1",
(DeclName, bool))

ERROR(ambiguous_type_base,none,
"%0 is ambiguous for type lookup in this context", (DeclNameRef))
Expand Down
4 changes: 1 addition & 3 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4214,9 +4214,7 @@ class DefaultArgumentExpr final : public Expr {
DefaultArgsOwner(defaultArgsOwner), ParamIndex(paramIndex), Loc(loc),
ContextOrCallerSideExpr(dc) { }

SourceRange getSourceRange() const { return {}; }

SourceLoc getArgumentListLoc() const { return Loc; }
SourceRange getSourceRange() const { return Loc; }

ConcreteDeclRef getDefaultArgsOwner() const {
return DefaultArgsOwner;
Expand Down
18 changes: 17 additions & 1 deletion include/swift/SIL/SILDeclRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "swift/AST/ClangNode.h"
#include "swift/AST/TypeAlignments.h"
#include "swift/SIL/SILLinkage.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerUnion.h"
Expand All @@ -42,7 +43,6 @@ namespace swift {
class ASTContext;
class ClassDecl;
class SILFunctionType;
enum class SILLinkage : unsigned char;
enum IsSerialized_t : unsigned char;
enum class SubclassScope : unsigned char;
class SILModule;
Expand Down Expand Up @@ -413,6 +413,22 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SILDeclRef C) {
return OS;
}

// FIXME: This should not be necessary, but it looks like visibility rules for
// extension members are slightly bogus, and so some protocol witness thunks
// need to be public.
//
// We allow a 'public' member of an extension to witness a public
// protocol requirement, even if the extended type is not public;
// then SILGen gives the member private linkage, ignoring the more
// visible access level it was given in the AST.
inline bool
fixmeWitnessHasLinkageThatNeedsToBePublic(SILDeclRef witness) {
auto witnessLinkage = witness.getLinkage(ForDefinition);
return !hasPublicVisibility(witnessLinkage)
&& (!hasSharedVisibility(witnessLinkage)
|| !witness.isSerialized());
}

} // end swift namespace

namespace llvm {
Expand Down
14 changes: 0 additions & 14 deletions include/swift/SIL/SILLinkage.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,6 @@ inline SILLinkage effectiveLinkageForClassMember(SILLinkage linkage,
return linkage;
}

// FIXME: This should not be necessary, but it looks like visibility rules for
// extension members are slightly bogus, and so some protocol witness thunks
// need to be public.
//
// We allow a 'public' member of an extension to witness a public
// protocol requirement, even if the extended type is not public;
// then SILGen gives the member private linkage, ignoring the more
// visible access level it was given in the AST.
inline bool
fixmeWitnessHasLinkageThatNeedsToBePublic(SILLinkage witnessLinkage) {
return !hasPublicVisibility(witnessLinkage) &&
!hasSharedVisibility(witnessLinkage);
}

} // end swift namespace

#endif
29 changes: 22 additions & 7 deletions lib/AST/ASTDemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,20 +597,35 @@ Type ASTBuilder::createGenericTypeParameterType(unsigned depth,

Type ASTBuilder::createDependentMemberType(StringRef member,
Type base) {
if (!base->isTypeParameter())
return Type();
auto identifier = Ctx.getIdentifier(member);

if (auto *archetype = base->getAs<ArchetypeType>()) {
if (archetype->hasNestedType(identifier))
return archetype->getNestedType(identifier);

}

if (base->isTypeParameter()) {
return DependentMemberType::get(base, identifier);
}

return DependentMemberType::get(base, Ctx.getIdentifier(member));
return Type();
}

Type ASTBuilder::createDependentMemberType(StringRef member,
Type base,
ProtocolDecl *protocol) {
if (!base->isTypeParameter())
return Type();
auto identifier = Ctx.getIdentifier(member);

if (auto assocType = protocol->getAssociatedType(Ctx.getIdentifier(member)))
return DependentMemberType::get(base, assocType);
if (auto *archetype = base->getAs<ArchetypeType>()) {
if (archetype->hasNestedType(identifier))
return archetype->getNestedType(identifier);
}

if (base->isTypeParameter()) {
if (auto assocType = protocol->getAssociatedType(identifier))
return DependentMemberType::get(base, assocType);
}

return Type();
}
Expand Down
26 changes: 20 additions & 6 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5950,6 +5950,17 @@ VarDecl::getPropertyWrapperMutability() const {
None);
}

Optional<PropertyWrapperSynthesizedPropertyKind>
VarDecl::getPropertyWrapperSynthesizedPropertyKind() const {
if (getOriginalWrappedProperty(
PropertyWrapperSynthesizedPropertyKind::Backing))
return PropertyWrapperSynthesizedPropertyKind::Backing;
if (getOriginalWrappedProperty(
PropertyWrapperSynthesizedPropertyKind::StorageWrapper))
return PropertyWrapperSynthesizedPropertyKind::StorageWrapper;
return None;
}

VarDecl *VarDecl::getPropertyWrapperBackingProperty() const {
return getPropertyWrapperBackingPropertyInfo().backingVar;
}
Expand Down Expand Up @@ -6473,9 +6484,13 @@ ParamDecl::getDefaultValueStringRepresentation(
return getASTContext().SourceMgr.extractText(charRange);
}

// If there is no parent initializer, we used the default initializer.
auto parentInit = original->getParentInitializer();
if (!parentInit) {
// If there is no initial wrapped value, we used the default initializer.
Expr *wrappedValue = nullptr;
if (auto *parentInit = original->getParentInitializer())
if (auto *placeholder = findWrappedValuePlaceholder(parentInit))
wrappedValue = placeholder->getOriginalWrappedValue();

if (!wrappedValue) {
if (auto type = original->getPropertyWrapperBackingPropertyType()) {
if (auto nominal = type->getAnyNominal()) {
scratch.clear();
Expand All @@ -6490,9 +6505,8 @@ ParamDecl::getDefaultValueStringRepresentation(
return ".init()";
}

auto init =
findWrappedValuePlaceholder(parentInit)->getOriginalWrappedValue();
return extractInlinableText(getASTContext().SourceMgr, init, scratch);
auto &sourceMgr = getASTContext().SourceMgr;
return extractInlinableText(sourceMgr, wrappedValue, scratch);
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,10 @@ SourceRange TupleExpr::getSourceRange() const {
} else {
// Scan backwards for a valid source loc.
for (Expr *expr : llvm::reverse(getElements())) {
// Default arguments are located at the start of their parent tuple, so
// skip over them.
if (isa<DefaultArgumentExpr>(expr))
continue;
end = expr->getEndLoc();
if (end.isValid()) {
break;
Expand Down
31 changes: 29 additions & 2 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,13 @@ static void concretizeNestedTypeFromConcreteParent(
GenericSignatureBuilder &builder) {
auto parentEquiv = parent->getEquivalenceClassIfPresent();
assert(parentEquiv && "can't have a concrete type without an equiv class");

bool isSuperclassConstrained = false;
auto concreteParent = parentEquiv->concreteType;
if (!concreteParent) {
isSuperclassConstrained = true;
concreteParent = parentEquiv->superclass;
}
assert(concreteParent &&
"attempting to resolve concrete nested type of non-concrete PA");

Expand All @@ -2544,8 +2550,14 @@ static void concretizeNestedTypeFromConcreteParent(
"No conformance requirement");
const RequirementSource *parentConcreteSource = nullptr;
for (const auto &constraint : parentEquiv->conformsTo.find(proto)->second) {
if (constraint.source->kind == RequirementSource::Concrete) {
parentConcreteSource = constraint.source;
if (!isSuperclassConstrained) {
if (constraint.source->kind == RequirementSource::Concrete) {
parentConcreteSource = constraint.source;
}
} else {
if (constraint.source->kind == RequirementSource::Superclass) {
parentConcreteSource = constraint.source;
}
}
}

Expand Down Expand Up @@ -4264,6 +4276,15 @@ bool GenericSignatureBuilder::updateSuperclass(
for (const auto &conforms : equivClass->conformsTo) {
(void)resolveSuperConformance(type, conforms.first);
}

// Eagerly resolve any existing nested types to their concrete forms (others
// will be "concretized" as they are constructed, in getNestedType).
for (auto equivT : equivClass->members) {
for (auto nested : equivT->getNestedTypes()) {
concretizeNestedTypeFromConcreteParent(equivT, nested.second.front(),
*this);
}
}
};

// If we haven't yet recorded a superclass constraint for this equivalence
Expand Down Expand Up @@ -7156,6 +7177,12 @@ void GenericSignatureBuilder::dump(llvm::raw_ostream &out) {
pa->dump(out, &Context.SourceMgr, 2);
}
out << "\n";

out << "Equivalence classes:\n";
for (auto &equiv : Impl->EquivalenceClasses) {
equiv.dump(out, this);
}
out << "\n";
}

void GenericSignatureBuilder::addGenericSignature(GenericSignature sig) {
Expand Down
13 changes: 10 additions & 3 deletions lib/Frontend/ModuleInterfaceSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,18 @@ class InheritedProtocolCollector {
/// in \p map.
///
/// \sa recordConditionalConformances
static void collectSkippedConditionalConformances(PerTypeMap &map,
const Decl *D) {
static void collectSkippedConditionalConformances(
PerTypeMap &map,
const Decl *D,
const PrintOptions &printOptions) {
auto *extension = dyn_cast<ExtensionDecl>(D);
if (!extension || !extension->isConstrainedExtension())
return;

// Skip SPI extensions in the public interface.
if (!printOptions.PrintSPIs && extension->isSPI())
return;

const NominalTypeDecl *nominal = extension->getExtendedNominal();
if (!isPublicOrUsableFromInline(nominal))
return;
Expand Down Expand Up @@ -496,8 +502,9 @@ bool swift::emitSwiftInterface(raw_ostream &out,

if (!D->shouldPrintInContext(printOptions) ||
!printOptions.shouldPrint(D)) {

InheritedProtocolCollector::collectSkippedConditionalConformances(
inheritedProtocolMap, D);
inheritedProtocolMap, D, printOptions);
continue;
}

Expand Down
12 changes: 9 additions & 3 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6196,6 +6196,8 @@ void CodeCompletionCallbacksImpl::doneParsing() {
break;
}

llvm::SmallPtrSet<Identifier, 8> seenModuleNames;

for (auto &Request: Lookup.RequestedCachedResults) {
// Use the current SourceFile as the DeclContext so that we can use it to
// perform qualified lookup, and to get the correct visibility for
Expand Down Expand Up @@ -6248,7 +6250,9 @@ void CodeCompletionCallbacksImpl::doneParsing() {
return; // already handled.
RequestedModules.push_back({std::move(K), TheModule,
Request.OnlyTypes, Request.OnlyPrecedenceGroups});
if (Request.IncludeModuleQualifier)

if (Request.IncludeModuleQualifier &&
seenModuleNames.insert(TheModule->getName()).second)
Lookup.addModuleName(TheModule);
}
};
Expand All @@ -6263,8 +6267,10 @@ void CodeCompletionCallbacksImpl::doneParsing() {
Lookup.getToplevelCompletions(Request.OnlyTypes);

// Add the qualifying module name
if (Request.IncludeModuleQualifier)
Lookup.addModuleName(CurDeclContext->getParentModule());
auto curModule = CurDeclContext->getParentModule();
if (Request.IncludeModuleQualifier &&
seenModuleNames.insert(curModule->getName()).second)
Lookup.addModuleName(curModule);

// Add results for all imported modules.
ModuleDecl::ImportFilter ImportFilter;
Expand Down
Loading