diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 167f25c810899..c3c53d87a2214 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -9446,23 +9446,26 @@ applySolutionToInitialization(SyntacticElementTarget target, Expr *initializer, // If this property has an opaque result type, set the underlying type // substitutions based on the initializer. if (auto var = resultTarget.getInitializationPattern()->getSingleVar()) { - SubstitutionMap substitutions; - if (auto opaque = var->getOpaqueResultTypeDecl()) { - resultTarget.getAsExpr()->forEachChildExpr([&](Expr *expr) -> Expr * { - if (auto coercionExpr = dyn_cast(expr)) { - auto newSubstitutions = - coercionExpr->substitutions.mapReplacementTypesOutOfContext(); - if (substitutions.empty()) { - substitutions = newSubstitutions; - } else { - assert(substitutions.getCanonical() == - newSubstitutions.getCanonical()); + if (!var->getParsedAccessor(AccessorKind::Get)) { + if (auto opaque = var->getOpaqueResultTypeDecl()) { + SubstitutionMap substitutions; + + resultTarget.getAsExpr()->forEachChildExpr([&](Expr *expr) -> Expr * { + if (auto coercionExpr = dyn_cast(expr)) { + auto newSubstitutions = + coercionExpr->substitutions.mapReplacementTypesOutOfContext(); + if (substitutions.empty()) { + substitutions = newSubstitutions; + } else { + assert(substitutions.getCanonical() == + newSubstitutions.getCanonical()); + } } - } - return expr; - }); + return expr; + }); - opaque->setUniqueUnderlyingTypeSubstitutions(substitutions); + opaque->setUniqueUnderlyingTypeSubstitutions(substitutions); + } } } diff --git a/lib/Sema/TypeOfReference.cpp b/lib/Sema/TypeOfReference.cpp index b92a6e8f0cf97..f21f5c970e3c0 100644 --- a/lib/Sema/TypeOfReference.cpp +++ b/lib/Sema/TypeOfReference.cpp @@ -1758,6 +1758,9 @@ static bool isExistentialMemberAccessWithExplicitBaseExpression( Type ConstraintSystem::getMemberReferenceTypeFromOpenedType( Type type, Type baseObjTy, ValueDecl *value, ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup) { + if (isa(value) || type->is()) + return ErrorType::get(getASTContext()); + auto *outerDC = value->getDeclContext(); // Cope with dynamic 'Self'. diff --git a/validation-test/IDE/crashers/08fb80df278d76cd.swift b/validation-test/IDE/crashers_fixed/08fb80df278d76cd.swift similarity index 72% rename from validation-test/IDE/crashers/08fb80df278d76cd.swift rename to validation-test/IDE/crashers_fixed/08fb80df278d76cd.swift index b2588b1ed8096..20db925a8258a 100644 --- a/validation-test/IDE/crashers/08fb80df278d76cd.swift +++ b/validation-test/IDE/crashers_fixed/08fb80df278d76cd.swift @@ -1,5 +1,5 @@ // {"kind":"complete","original":"098f0ede","signature":"swift::constraints::ConstraintSystem::getMemberReferenceTypeFromOpenedType(swift::Type, swift::Type, swift::ValueDecl*, swift::constraints::ConstraintLocator*, bool, bool)","signatureAssert":"Assertion failed: (isa(Val) && \"cast() argument of incompatible type!\"), function cast"} -// RUN: not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s +// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s enum a { c=d#^^# macro d() } diff --git a/validation-test/compiler_crashers_2/511f277d722d94a4.swift b/validation-test/compiler_crashers_2_fixed/511f277d722d94a4.swift similarity index 87% rename from validation-test/compiler_crashers_2/511f277d722d94a4.swift rename to validation-test/compiler_crashers_2_fixed/511f277d722d94a4.swift index 5b2c0e253157d..8d52b0c6b8ed3 100644 --- a/validation-test/compiler_crashers_2/511f277d722d94a4.swift +++ b/validation-test/compiler_crashers_2_fixed/511f277d722d94a4.swift @@ -1,5 +1,5 @@ // {"kind":"typecheck","original":"098f0ede","signature":"swift::constraints::ConstraintSystem::getMemberReferenceTypeFromOpenedType(swift::Type, swift::Type, swift::ValueDecl*, swift::constraints::ConstraintLocator*, bool, bool)","signatureAssert":"Assertion failed: (isa(Val) && \"cast() argument of incompatible type!\"), function cast"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s enum a { c = d macro d() } diff --git a/validation-test/compiler_crashers_2/88e136b5aa17e82f.swift b/validation-test/compiler_crashers_2_fixed/88e136b5aa17e82f.swift similarity index 84% rename from validation-test/compiler_crashers_2/88e136b5aa17e82f.swift rename to validation-test/compiler_crashers_2_fixed/88e136b5aa17e82f.swift index 88eb41a7dece8..62510db6f471b 100644 --- a/validation-test/compiler_crashers_2/88e136b5aa17e82f.swift +++ b/validation-test/compiler_crashers_2_fixed/88e136b5aa17e82f.swift @@ -1,5 +1,5 @@ // {"kind":"typecheck","original":"3a2652c9","signature":"(anonymous namespace)::OpaqueUnderlyingTypeChecker::check()","signatureAssert":"Assertion failed: (!UniqueUnderlyingType.has_value() && \"resetting underlying type?!\"), function setUniqueUnderlyingTypeSubstitutions"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s var a: some Any = 0.0 { 0 }