Skip to content

Fix crash during type checking when adding members to an extension. #4053

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 1 commit into from
Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions lib/AST/NameLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,9 @@ void NominalTypeDecl::addedMember(Decl *member) {

void ExtensionDecl::addedMember(Decl *member) {
if (NextExtension.getInt()) {
if (getExtendedType()->is<ErrorType>())
return;

auto nominal = getExtendedType()->getAnyNominal();
if (nominal->LookupTable.getPointer()) {
// Make sure we have the complete list of extensions.
Expand Down
7 changes: 7 additions & 0 deletions test/decl/var/properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,13 @@ extension rdar17391625derived {
}
}

// <rdar://problem/27671033> Crash when defining property inside an invalid extension
public protocol rdar27671033P {}
struct rdar27671033S<Key, Value> {}
extension rdar27671033S : rdar27671033P where Key == String { // expected-error {{extension of type 'rdar27671033S' with constraints cannot have an inheritance clause}}
// expected-error@-1 {{same-type requirement makes generic parameter 'Key' non-generic}}
let d = rdar27671033S<Int, Int>() // expected-error {{extensions may not contain stored properties}}
}

// <rdar://problem/19874152> struct memberwise initializer violates new sanctity of previously set `let` property
struct r19874152S1 {
Expand Down