diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index f12bd7a6c03cf..64378e2ae4c67 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -1436,10 +1436,10 @@ ERROR(did_not_call_function_value,none, ()) ERROR(did_not_call_function,none, "function %0 was used as a property; add () to call it", - (Identifier)) + (DeclBaseName)) ERROR(did_not_call_method,none, "method %0 was used as a property; add () to call it", - (Identifier)) + (DeclBaseName)) ERROR(init_not_instance_member_use_assignment,none, "'init' is a member of the type; use assignment " @@ -3781,9 +3781,6 @@ ERROR(enum_non_integer_convertible_raw_type_no_value,none, "expressible by integer or string literal", ()) ERROR(enum_raw_value_not_unique,none, "raw value for enum case is not unique", ()) -ERROR(enum_raw_value_magic_literal,none, - "use of '%0' literal as raw value for enum case is not supported", - (StringRef)) NOTE(enum_raw_value_used_here,none, "raw value previously used here", ()) NOTE(enum_raw_value_incrementing_from_here,none, diff --git a/lib/AST/ASTScope.cpp b/lib/AST/ASTScope.cpp index 4583ac892c517..c49c6c49756f5 100644 --- a/lib/AST/ASTScope.cpp +++ b/lib/AST/ASTScope.cpp @@ -356,6 +356,8 @@ SourceRange NominalTypeScope::getBraces() const { return decl->getBraces(); } NullablePtr ExtensionScope::getCorrespondingNominalTypeDecl() const { + if (!decl->hasBeenBound()) + return nullptr; return decl->getExtendedNominal(); } diff --git a/lib/AST/ProtocolConformance.cpp b/lib/AST/ProtocolConformance.cpp index da9f1adc7d0ac..56519a83bdfa6 100644 --- a/lib/AST/ProtocolConformance.cpp +++ b/lib/AST/ProtocolConformance.cpp @@ -990,9 +990,12 @@ static bool isVanishingTupleConformance( auto replacementTypes = substitutions.getReplacementTypes(); assert(replacementTypes.size() == 1); - auto packType = replacementTypes[0]->castTo(); - return (packType->getNumElements() == 1 && + // This might not be an actual pack type with an invalid tuple conformance. + auto packType = replacementTypes[0]->getAs(); + + return (packType && + packType->getNumElements() == 1 && !packType->getElementTypes()[0]->is()); } diff --git a/lib/AST/RequirementMachine/RequirementLowering.cpp b/lib/AST/RequirementMachine/RequirementLowering.cpp index cb3cfcdb25583..7fa5cec5beef3 100644 --- a/lib/AST/RequirementMachine/RequirementLowering.cpp +++ b/lib/AST/RequirementMachine/RequirementLowering.cpp @@ -451,6 +451,7 @@ static void desugarSameShapeRequirement( !req.getSecondType()->isParameterPack()) { errors.push_back(RequirementError::forInvalidShapeRequirement( req, loc)); + return; } result.emplace_back(RequirementKind::SameShape, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 478c58fd34889..bf6541726f4ce 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -6337,8 +6337,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi, DescriptiveKind = DescriptiveDeclKind::StaticProperty; break; case StaticSpellingKind::KeywordClass: - llvm_unreachable("kw_class is only parsed as a modifier if it's " - "followed by a keyword"); + DescriptiveKind = DescriptiveDeclKind::ClassProperty; + break; } diagnose(Tok.getLoc(), diag::expected_keyword_in_decl, "var", @@ -6366,8 +6366,7 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi, DescriptiveKind = DescriptiveDeclKind::StaticMethod; break; case StaticSpellingKind::KeywordClass: - llvm_unreachable("kw_class is only parsed as a modifier if it's " - "followed by a keyword"); + DescriptiveKind = DescriptiveDeclKind::ClassMethod; } } @@ -9229,6 +9228,20 @@ ParserResult Parser::parseDeclEnum(ParseDeclOptions Flags, return DCC.fixupParserResult(Status, ED); } +static bool isValidEnumRawValueLiteral(LiteralExpr *expr) { + if (expr == nullptr) + return false; + + if (!isa(expr) && + !isa(expr) && + !isa(expr) && + !isa(expr) && + !isa(expr)) + return false; + + return true; +} + /// Parse a 'case' of an enum. /// /// \verbatim @@ -9346,8 +9359,7 @@ Parser::parseDeclEnumCase(ParseDeclOptions Flags, } // The raw value must be syntactically a simple literal. LiteralRawValueExpr = dyn_cast(RawValueExpr.getPtrOrNull()); - if (!LiteralRawValueExpr - || isa(LiteralRawValueExpr)) { + if (!isValidEnumRawValueLiteral(LiteralRawValueExpr)) { diagnose(RawValueExpr.getPtrOrNull()->getLoc(), diag::nonliteral_enum_case_raw_value); LiteralRawValueExpr = nullptr; diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index 40c22af154615..6af4e4bfc995e 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -3940,14 +3940,14 @@ bool MissingCallFailure::diagnoseAsError() { if (auto *DRE = getAsExpr(anchor)) { emitDiagnostic(diag::did_not_call_function, - DRE->getDecl()->getBaseIdentifier()) + DRE->getDecl()->getBaseName()) .fixItInsertAfter(insertLoc, "()"); return true; } if (auto *UDE = getAsExpr(anchor)) { emitDiagnostic(diag::did_not_call_method, - UDE->getName().getBaseIdentifier()) + UDE->getName().getBaseName()) .fixItInsertAfter(insertLoc, "()"); return true; } @@ -3955,7 +3955,7 @@ bool MissingCallFailure::diagnoseAsError() { if (auto *DSCE = getAsExpr(anchor)) { if (auto *DRE = dyn_cast(DSCE->getFn())) { emitDiagnostic(diag::did_not_call_method, - DRE->getDecl()->getBaseIdentifier()) + DRE->getDecl()->getBaseName()) .fixItInsertAfter(insertLoc, "()"); return true; } diff --git a/lib/Sema/DerivedConformance/DerivedConformance.cpp b/lib/Sema/DerivedConformance/DerivedConformance.cpp index 8d3f5b62d0b09..7df7919af315a 100644 --- a/lib/Sema/DerivedConformance/DerivedConformance.cpp +++ b/lib/Sema/DerivedConformance/DerivedConformance.cpp @@ -272,6 +272,9 @@ void DerivedConformance::diagnoseIfSynthesisUnsupportedForDecl( shouldDiagnose = !isa(nominal); } + if (isa(nominal)) + shouldDiagnose = false; + if (shouldDiagnose) { auto &ctx = nominal->getASTContext(); ctx.Diags.diagnose(nominal->getLoc(), diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 547092d7033ec..4228f526e6a8e 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -6268,9 +6268,9 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E, note.fixItRemove(duplicated.first->getSourceRange()); if (duplicatedEltIdx < commanLocs.size()) { note.fixItRemove(commanLocs[duplicatedEltIdx]); - } else { + } else if (!commanLocs.empty()) { // For the last element remove the previous comma. - note.fixItRemove(commanLocs[duplicatedEltIdx - 1]); + note.fixItRemove(commanLocs[commanLocs.size() - 1]); } }; diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index abce1b3299457..7dd540e408c6e 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -1304,15 +1304,6 @@ EnumRawValuesRequest::evaluate(Evaluator &eval, EnumDecl *ED, SourceLoc diagLoc = uncheckedRawValueOf(elt)->isImplicit() ? elt->getLoc() : uncheckedRawValueOf(elt)->getLoc(); - if (auto magicLiteralExpr = - dyn_cast(prevValue)) { - auto kindString = - magicLiteralExpr->getKindString(magicLiteralExpr->getKind()); - Diags.diagnose(diagLoc, diag::enum_raw_value_magic_literal, kindString); - elt->setInvalid(); - continue; - } - // Check that the raw value is unique. RawValueKey key{prevValue}; RawValueSource source{elt, lastExplicitValueElt}; diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index ff61134aadd51..77b47d3d2ce67 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -217,6 +217,9 @@ bool swift::isOverrideBasedOnType(const ValueDecl *decl, Type declTy, return false; } + if (declTy->is()) + return false; + auto fnType1 = declTy->castTo(); auto fnType2 = parentDeclTy->castTo(); return AnyFunctionType::equalParams(fnType1->getParams(), diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index 86fe85b94b69f..8121b40eb8097 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -3888,10 +3888,19 @@ filterProtocolRequirements( return Filtered; } - const auto getProtocolSubstitutionMap = [&](ValueDecl *Req) { - auto *const PD = cast(Req->getDeclContext()); - auto Conformance = lookupConformance(Adoptee, PD); - return SubstitutionMap::getProtocolSubstitutions(Conformance); + const auto getProtocolSubstitutionMap = [&](ValueDecl *req) { + ASSERT(isa(req->getDeclContext())); + auto genericSig = req->getInnermostDeclContext() + ->getGenericSignatureOfContext(); + SmallVector args; + for (auto paramTy : genericSig.getGenericParams()) { + if (args.empty()) + args.push_back(Adoptee); + else + args.push_back(paramTy); + } + return SubstitutionMap::get(genericSig, args, + LookUpConformanceInModule()); }; llvm::SmallDenseMap, 4> @@ -3907,11 +3916,11 @@ filterProtocolRequirements( auto OverloadTy = Req->getOverloadSignatureType(); if (OverloadTy) { auto Subs = getProtocolSubstitutionMap(Req); - // FIXME: This is wrong if the overload has its own generic parameters - if (auto GenericFnTy = dyn_cast(OverloadTy)) + if (auto GenericFnTy = dyn_cast(OverloadTy)) { OverloadTy = GenericFnTy.substGenericArgs(Subs); - else + } else { OverloadTy = OverloadTy.subst(Subs)->getCanonicalType(); + } } if (llvm::any_of(DeclsByName[Req->getName()], [&](ValueDecl *OtherReq) { auto OtherOverloadTy = OtherReq->getOverloadSignatureType(); diff --git a/lib/Sema/TypeCheckStorage.cpp b/lib/Sema/TypeCheckStorage.cpp index afc616c560e33..b001206557629 100644 --- a/lib/Sema/TypeCheckStorage.cpp +++ b/lib/Sema/TypeCheckStorage.cpp @@ -2996,9 +2996,10 @@ LazyStoragePropertyRequest::evaluate(Evaluator &evaluator, addMemberToContextIfNeeded(PBD, VD->getDeclContext(), Storage); // Make sure the original init is marked as subsumed. - auto *originalPBD = VD->getParentPatternBinding(); - auto originalIndex = originalPBD->getPatternEntryIndexForVarDecl(VD); - originalPBD->setInitializerSubsumed(originalIndex); + if (auto *originalPBD = VD->getParentPatternBinding()) { + auto originalIndex = originalPBD->getPatternEntryIndexForVarDecl(VD); + originalPBD->setInitializerSubsumed(originalIndex); + } return Storage; } diff --git a/test/Generics/tuple-conformances-synthesize-crash.swift b/test/Generics/tuple-conformances-synthesize-crash.swift new file mode 100644 index 0000000000000..8d4fdfafdfb2f --- /dev/null +++ b/test/Generics/tuple-conformances-synthesize-crash.swift @@ -0,0 +1,5 @@ +// RUN: not %target-swift-frontend -typecheck %s + +// Just don't crash. +extension () : Comparable {} + diff --git a/test/decl/enum/invalid_raw_value.swift b/test/decl/enum/invalid_raw_value.swift new file mode 100644 index 0000000000000..31ef46e50a5c7 --- /dev/null +++ b/test/decl/enum/invalid_raw_value.swift @@ -0,0 +1,7 @@ +// RUN: %target-typecheck-verify-swift + +_ = a.init +_ = b.init + +enum a : Int { case x = #/ /# } // expected-error {{raw value for enum case must be a literal}} +enum b : String { case x = #file } // expected-error {{raw value for enum case must be a literal}} diff --git a/test/decl/protocol/conforms/fixit_stub_generic.swift b/test/decl/protocol/conforms/fixit_stub_generic.swift new file mode 100644 index 0000000000000..b47ef8c65f6fa --- /dev/null +++ b/test/decl/protocol/conforms/fixit_stub_generic.swift @@ -0,0 +1,13 @@ +// RUN: %target-typecheck-verify-swift + +protocol P1 { + associatedtype A +} + +protocol P2 { + func f(_: T, _: T) // expected-note {{protocol requires function 'f' with type ' (T, T) -> ()'}} + func f(_: T, _: T.A) // expected-note {{protocol requires function 'f' with type ' (T, T.A) -> ()'}} +} + +struct S: P2 {} // expected-error {{type 'S' does not conform to protocol 'P2'}} +// expected-note@-1 {{add stubs for conformance}} diff --git a/validation-test/compiler_crashers_2/1c4f5ed8bb743453.swift b/validation-test/compiler_crashers_2_fixed/1c4f5ed8bb743453.swift similarity index 75% rename from validation-test/compiler_crashers_2/1c4f5ed8bb743453.swift rename to validation-test/compiler_crashers_2_fixed/1c4f5ed8bb743453.swift index 67cc303dee5ac..567cb0fb4f627 100644 --- a/validation-test/compiler_crashers_2/1c4f5ed8bb743453.swift +++ b/validation-test/compiler_crashers_2_fixed/1c4f5ed8bb743453.swift @@ -1,4 +1,4 @@ // {"signature":"swift::Parser::parseNewDeclAttribute(swift::DeclAttributes&, swift::SourceLoc, swift::DeclAttrKind, bool)::$_4::operator()() const"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s class a { class override b diff --git a/validation-test/compiler_crashers_2/1f1b9ed16e283e76.swift b/validation-test/compiler_crashers_2_fixed/1f1b9ed16e283e76.swift similarity index 69% rename from validation-test/compiler_crashers_2/1f1b9ed16e283e76.swift rename to validation-test/compiler_crashers_2_fixed/1f1b9ed16e283e76.swift index 8c2da215f9391..1365c7e0535ea 100644 --- a/validation-test/compiler_crashers_2/1f1b9ed16e283e76.swift +++ b/validation-test/compiler_crashers_2_fixed/1f1b9ed16e283e76.swift @@ -1,4 +1,4 @@ // {"signature":"swift::LazyStoragePropertyRequest::evaluate(swift::Evaluator&, swift::VarDecl*) const"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s class a { lazy(b, c) { diff --git a/validation-test/compiler_crashers_2/1fb63f2dc87bc9b9.swift b/validation-test/compiler_crashers_2_fixed/1fb63f2dc87bc9b9.swift similarity index 70% rename from validation-test/compiler_crashers_2/1fb63f2dc87bc9b9.swift rename to validation-test/compiler_crashers_2_fixed/1fb63f2dc87bc9b9.swift index 6192c4bd17615..763f8bacf18b1 100644 --- a/validation-test/compiler_crashers_2/1fb63f2dc87bc9b9.swift +++ b/validation-test/compiler_crashers_2_fixed/1fb63f2dc87bc9b9.swift @@ -1,3 +1,3 @@ // {"signature":"swift::Parser::parseDecl(bool, bool, llvm::function_ref, bool)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s class a { class override ( override diff --git a/validation-test/compiler_crashers_2/259dac55924ef426.swift b/validation-test/compiler_crashers_2_fixed/259dac55924ef426.swift similarity index 65% rename from validation-test/compiler_crashers_2/259dac55924ef426.swift rename to validation-test/compiler_crashers_2_fixed/259dac55924ef426.swift index a3f4faaa87333..beaa9da85e046 100644 --- a/validation-test/compiler_crashers_2/259dac55924ef426.swift +++ b/validation-test/compiler_crashers_2_fixed/259dac55924ef426.swift @@ -1,3 +1,3 @@ // {"signature":"swift::GenericContext::getGenericParams() const"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s typealias a = () extension a : Comparable diff --git a/validation-test/compiler_crashers_2/2617a198505b47e4.swift b/validation-test/compiler_crashers_2_fixed/2617a198505b47e4.swift similarity index 82% rename from validation-test/compiler_crashers_2/2617a198505b47e4.swift rename to validation-test/compiler_crashers_2_fixed/2617a198505b47e4.swift index 4a03fe302445c..9147add3fa74f 100644 --- a/validation-test/compiler_crashers_2/2617a198505b47e4.swift +++ b/validation-test/compiler_crashers_2_fixed/2617a198505b47e4.swift @@ -1,5 +1,5 @@ // {"signature":"swift::rewriting::RequirementMachine::getReducedShape(swift::Type, llvm::ArrayRef) const"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s protocol a{ b < c > (c, _ : c} protocol d : a{ b(c, c.c) protocol e { diff --git a/validation-test/compiler_crashers_2/441e44e28042d5a3.swift b/validation-test/compiler_crashers_2_fixed/441e44e28042d5a3.swift similarity index 66% rename from validation-test/compiler_crashers_2/441e44e28042d5a3.swift rename to validation-test/compiler_crashers_2_fixed/441e44e28042d5a3.swift index 69369f6de1291..5b6e0e7abafed 100644 --- a/validation-test/compiler_crashers_2/441e44e28042d5a3.swift +++ b/validation-test/compiler_crashers_2_fixed/441e44e28042d5a3.swift @@ -1,3 +1,3 @@ // {"signature":"deriveBodyRawRepresentable_init(swift::AbstractFunctionDecl*, void*)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s a enum a : Int { case = #/ diff --git a/validation-test/compiler_crashers_2/90773c979d435f7.swift b/validation-test/compiler_crashers_2_fixed/90773c979d435f7.swift similarity index 80% rename from validation-test/compiler_crashers_2/90773c979d435f7.swift rename to validation-test/compiler_crashers_2_fixed/90773c979d435f7.swift index 6b160e9f6cde6..dccfdaecd70c6 100644 --- a/validation-test/compiler_crashers_2/90773c979d435f7.swift +++ b/validation-test/compiler_crashers_2_fixed/90773c979d435f7.swift @@ -1,5 +1,5 @@ // {"signature":"swift::isOverrideBasedOnType(swift::ValueDecl const*, swift::Type, swift::ValueDecl const*)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s struct a < b { protocol c { associatedtype d init(e : d } diff --git a/validation-test/compiler_crashers_2/93eaba9fd0e76cdf.swift b/validation-test/compiler_crashers_2_fixed/93eaba9fd0e76cdf.swift similarity index 75% rename from validation-test/compiler_crashers_2/93eaba9fd0e76cdf.swift rename to validation-test/compiler_crashers_2_fixed/93eaba9fd0e76cdf.swift index 3b4535b3be622..97cda574e4c59 100644 --- a/validation-test/compiler_crashers_2/93eaba9fd0e76cdf.swift +++ b/validation-test/compiler_crashers_2_fixed/93eaba9fd0e76cdf.swift @@ -1,3 +1,3 @@ // {"signature":"diagnoseDictionaryLiteralDuplicateKeyEntries(swift::Expr const*, swift::DeclContext const*)::DiagnoseWalker::walkToExprPre(swift::Expr*)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s [ 1.01: "" 1.01: "" diff --git a/validation-test/compiler_crashers_2/a9f541ae5c40ef35.swift b/validation-test/compiler_crashers_2_fixed/a9f541ae5c40ef35.swift similarity index 71% rename from validation-test/compiler_crashers_2/a9f541ae5c40ef35.swift rename to validation-test/compiler_crashers_2_fixed/a9f541ae5c40ef35.swift index e988fba99f1dc..e74acdceb6a01 100644 --- a/validation-test/compiler_crashers_2/a9f541ae5c40ef35.swift +++ b/validation-test/compiler_crashers_2_fixed/a9f541ae5c40ef35.swift @@ -1,3 +1,3 @@ // {"signature":"(anonymous namespace)::ABIDependencyEvaluator::computeABIDependenciesForModule(swift::ModuleDecl*)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s struct a { init? { init! diff --git a/validation-test/compiler_crashers_2/d48def542970cfa.swift b/validation-test/compiler_crashers_2_fixed/d48def542970cfa.swift similarity index 85% rename from validation-test/compiler_crashers_2/d48def542970cfa.swift rename to validation-test/compiler_crashers_2_fixed/d48def542970cfa.swift index ffbeac8876178..33d9b14c41143 100644 --- a/validation-test/compiler_crashers_2/d48def542970cfa.swift +++ b/validation-test/compiler_crashers_2_fixed/d48def542970cfa.swift @@ -1,4 +1,4 @@ // {"signature":"swift::rewriting::performConcreteContraction(llvm::ArrayRef, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, bool)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s func a < each b, each c where(repeat(each c each b)) : { typealias d = () func e where d == diff --git a/validation-test/compiler_crashers_2_fixed/issue-55443.swift b/validation-test/compiler_crashers_2_fixed/issue-55443.swift index 928c1def248d1..0a25bcf9fe080 100644 --- a/validation-test/compiler_crashers_2_fixed/issue-55443.swift +++ b/validation-test/compiler_crashers_2_fixed/issue-55443.swift @@ -2,20 +2,20 @@ // https://github.com/apple/swift/issues/55443 -enum FooString: String { // expected-error {{'FooString' declares raw type 'String', but does not conform to RawRepresentable and conformance could not be synthesized}} expected-note {{add stubs for conformance}} - case bar1 = #file // expected-error {{use of '#file' literal as raw value for enum case is not supported}} - case bar2 = #function // expected-error {{use of '#function' literal as raw value for enum case is not supported}} - case bar3 = #filePath // expected-error {{use of '#filePath' literal as raw value for enum case is not supported}} - case bar4 = #line // expected-error {{cannot convert value of type 'Int' to raw type 'String'}} - case bar5 = #column // expected-error {{cannot convert value of type 'Int' to raw type 'String'}} - case bar6 = #dsohandle // expected-error {{cannot convert value of type 'UnsafeRawPointer' to raw type 'String'}} +enum FooString: String { + case bar1 = #file // expected-error {{raw value for enum case must be a literal}} + case bar2 = #function // expected-error {{raw value for enum case must be a literal}} + case bar3 = #filePath // expected-error {{raw value for enum case must be a literal}} + case bar4 = #line // expected-error {{raw value for enum case must be a literal}} + case bar5 = #column // expected-error {{raw value for enum case must be a literal}} + case bar6 = #dsohandle // expected-error {{raw value for enum case must be a literal}} } -enum FooInt: Int { // expected-error {{'FooInt' declares raw type 'Int', but does not conform to RawRepresentable and conformance could not be synthesized}} expected-note {{add stubs for conformance}} - case bar1 = #file // expected-error {{cannot convert value of type 'String' to raw type 'Int'}} - case bar2 = #function // expected-error {{cannot convert value of type 'String' to raw type 'Int'}} - case bar3 = #filePath // expected-error {{cannot convert value of type 'String' to raw type 'Int'}} - case bar4 = #line // expected-error {{use of '#line' literal as raw value for enum case is not supported}} - case bar5 = #column // expected-error {{use of '#column' literal as raw value for enum case is not supported}} - case bar6 = #dsohandle // expected-error {{cannot convert value of type 'UnsafeRawPointer' to raw type 'Int'}} +enum FooInt: Int { + case bar1 = #file // expected-error {{raw value for enum case must be a literal}} + case bar2 = #function // expected-error {{raw value for enum case must be a literal}} + case bar3 = #filePath // expected-error {{raw value for enum case must be a literal}} + case bar4 = #line // expected-error {{raw value for enum case must be a literal}} + case bar5 = #column // expected-error {{raw value for enum case must be a literal}} + case bar6 = #dsohandle // expected-error {{raw value for enum case must be a literal}} }