diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index c927b5975a21..266c493f3498 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -4108,6 +4108,13 @@ TypeBase::getContextSubstitutions(const DeclContext *dc, continue; } + // There are no subtitutions to apply if the type is still unbound, + // continue looking into the parent. + if (auto unboundGeneric = baseTy->getAs()) { + baseTy = unboundGeneric->getParent(); + continue; + } + // Assert and break to avoid hanging if we get an unexpected baseTy. assert(0 && "Bad base type"); break; diff --git a/lib/Sema/TypeCheckPropertyWrapper.cpp b/lib/Sema/TypeCheckPropertyWrapper.cpp index 96e9f60abc1b..293f28d05731 100644 --- a/lib/Sema/TypeCheckPropertyWrapper.cpp +++ b/lib/Sema/TypeCheckPropertyWrapper.cpp @@ -565,6 +565,8 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate( (void)var->getInterfaceType(); if (!binding->isInitializerChecked(index)) TypeChecker::typeCheckPatternBinding(binding, index); + if (binding->isInvalid()) + return Type(); } else { using namespace constraints; auto dc = var->getInnermostDeclContext(); diff --git a/validation-test/IDE/crashers_2_fixed/rdar64141399-complete_generic_property_wrapper_initialization.swift b/validation-test/IDE/crashers_2_fixed/rdar64141399-complete_generic_property_wrapper_initialization.swift new file mode 100644 index 000000000000..d8ba29864920 --- /dev/null +++ b/validation-test/IDE/crashers_2_fixed/rdar64141399-complete_generic_property_wrapper_initialization.swift @@ -0,0 +1,35 @@ +// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE_GENERIC -source-filename=%s +// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE_IN_GENERIC_CONTEXT -source-filename=%s + +struct Foo { + static let bar: Foo +} + +@propertyWrapper public struct GenericWrapper { + public var wrappedValue: Value + public var projectedValue: Int + + public init(wrappedValue: Value) { + self.wrappedValue = wrappedValue + self.projectedValue = 1 + } +} + +public struct GenericContext { + @propertyWrapper public struct GenericWrapper { + public var wrappedValue: Value + public var projectedValue: Int + + public init(wrappedValue: Value) { + self.wrappedValue = wrappedValue + self.projectedValue = 1 + } + } +} + +public struct MyStruct { + @GenericWrapper var someProperty = #^COMPLETE_GENERIC^# +} +public struct MyStruct2 { + @GenericContext.GenericWrapper var someProperty2 = #^COMPLETE_IN_GENERIC_CONTEXT^# +}