Skip to content

Fix precedencegroup and operator decl lookup #31506

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 5 commits into from
May 23, 2020

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented May 2, 2020

Re-implement operator and precedencegroup decl lookup to use namelookup::getAllImports and existing decl shadowing logic. This allows us to find operator decls through @_exported imports, prefer operator decls defined in the same module over imported decls, and fixes a couple of other subtle issues.

Because this new implementation is technically source breaking, as we can find multiple results where we used to only find one result, it's placed behind a Frontend staging flag -enable-new-operator-lookup (with the aim of enabling it by default when we get a new language mode).

However the new logic will always be used if the result is unambiguous. This means that e.g @_exported operators will be instantly available as long as there's only one candidate. If multiple candidates are found, we fall back to the old logic.

Resolves SR-12132.
Resolves rdar://48731166 & rdar://59198796.

@swift-ci

This comment has been minimized.

@hamishknight hamishknight marked this pull request as draft May 4, 2020 03:17
@hamishknight
Copy link
Contributor Author

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented May 4, 2020

Summary for master full

Unexpected test results, excluded stats for RxCocoa, SwifterSwift, Base64CoderSwiftUI

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 57,718,394,646,307 57,807,357,868,232 88,963,221,925 0.15%
LLVM.NumLLVMBytesOutput 1,878,350,916 1,878,355,210 4,294 0.0%
time.swift-driver.wall 3950.4s 3956.9s 6.5s 0.17%

debug-batch detailed

Regressed (3)
name old new delta delta_pct
AST.ImportSetCacheHit 1,832,143 1,939,778 107,635 5.87% ⛔
Sema.DirectOperatorLookupRequest 500,186 1,782,934 1,282,748 256.45% ⛔
Sema.DirectPrecedenceGroupLookupRequest 146,221 614,520 468,299 320.27% ⛔
Improved (2)
name old new delta delta_pct
Sema.LookupInfixOperatorRequest 83,205 79,781 -3,424 -4.12% ✅
Sema.LookupPrecedenceGroupRequest 32,389 27,692 -4,697 -14.5% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (234)
name old new delta delta_pct
AST.ImportSetCacheMiss 391,143 391,927 784 0.2%
AST.ImportSetFoldHit 123,158 123,904 746 0.61%
AST.ImportSetFoldMiss 267,985 268,023 38 0.01%
AST.ModuleShadowCacheHit 3,659 3,659 0 0.0%
AST.ModuleShadowCacheMiss 1,888 1,888 0 0.0%
AST.ModuleVisibilityCacheHit 36,931 36,931 0 0.0%
AST.ModuleVisibilityCacheMiss 8,425 8,425 0 0.0%
AST.NumASTBytesAllocated 56,300,679,001 56,542,490,783 241,811,782 0.43%
AST.NumASTScopeLookups 3,642,965 3,642,936 -29 -0.0%
AST.NumBraceStmtASTScopeExpansions 642,442 642,442 0 0.0%
AST.NumBraceStmtASTScopes 642,442 642,442 0 0.0%
AST.NumDecls 145,941 145,941 0 0.0%
AST.NumDependencies 304,855 304,847 -8 -0.0%
AST.NumIterableTypeBodyASTScopeExpansions 240,814 240,814 0 0.0%
AST.NumIterableTypeBodyASTScopes 289,717 289,718 1 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 246,334 246,334 0 0.0%
AST.NumLocalTypeDecls 255 255 0 0.0%
AST.NumModuleLookupClassMember 6,993 6,993 0 0.0%
AST.NumModuleLookupValue 48,909,041 48,918,313 9,272 0.02%
AST.NumObjCMethods 25,367 25,367 0 0.0%
AST.NumOperators 589 589 0 0.0%
AST.NumPrecedenceGroups 93 93 0 0.0%
AST.NumReferencedDynamicNames 191 191 0 0.0%
AST.NumReferencedMemberNames 7,665,957 7,665,957 0 0.0%
AST.NumReferencedTopLevelNames 614,692 614,692 0 0.0%
AST.NumSourceBuffers 326,075 326,075 0 0.0%
AST.NumSourceLines 4,856,217 4,856,217 0 0.0%
AST.NumSourceLinesPerSecond 3,419,845 3,429,782 9,937 0.29%
AST.NumTotalClangImportedEntities 1,909,670 1,915,914 6,244 0.33%
Driver.ChildrenMaxRSS 262,241,128,448 261,928,966,144 -312,162,304 -0.12%
Driver.DriverDepCascadingDynamic 0 0 0 0.0%
Driver.DriverDepCascadingExternal 0 0 0 0.0%
Driver.DriverDepCascadingMember 0 0 0 0.0%
Driver.DriverDepCascadingNominal 0 0 0 0.0%
Driver.DriverDepCascadingTopLevel 0 0 0 0.0%
Driver.DriverDepDynamic 0 0 0 0.0%
Driver.DriverDepExternal 0 0 0 0.0%
Driver.DriverDepMember 0 0 0 0.0%
Driver.DriverDepNominal 0 0 0 0.0%
Driver.DriverDepTopLevel 0 0 0 0.0%
Driver.NumDriverJobsRun 29,014 29,014 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 102,421 102,790 369 0.36%
Driver.NumDriverPipeReads 93,013 93,424 411 0.44%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,154,322,630,000 1,156,094,882,136 1,772,252,136 0.15%
Frontend.NumInstructionsExecuted 57,718,394,646,307 57,807,357,868,232 88,963,221,925 0.15%
Frontend.NumProcessFailures 0 0 0 0.0%
IRGen.IRGenSourceFileRequest 27,700 27,700 0 0.0%
IRGen.IRGenWholeModuleRequest 20 20 0 0.0%
IRModule.NumGOTEntries 249,175 249,175 0 0.0%
IRModule.NumIRAliases 203,580 203,580 0 0.0%
IRModule.NumIRBasicBlocks 7,061,228 7,061,228 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,549,313 3,549,313 0 0.0%
IRModule.NumIRGlobals 3,849,797 3,849,797 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 90,701,621 90,701,621 0 0.0%
IRModule.NumIRNamedMetaData 140,100 140,100 0 0.0%
IRModule.NumIRValueSymbols 6,720,860 6,720,860 0 0.0%
LLVM.NumLLVMBytesOutput 1,878,350,916 1,878,355,210 4,294 0.0%
Parse.CodeCompletionSecondPassRequest 0 0 0 0.0%
Parse.NumFunctionsParsed 279,630 279,630 0 0.0%
Parse.NumIterableDeclContextParsed 622,535 622,530 -5 -0.0%
Parse.ParseAbstractFunctionBodyRequest 256,745 256,745 0 0.0%
Parse.ParseMembersRequest 490,279 490,274 -5 -0.0%
Parse.ParseSourceFileRequest 316,924 316,924 0 0.0%
SILGen.SILGenSourceFileRequest 27,700 27,700 0 0.0%
SILGen.SILGenWholeModuleRequest 1,302 1,302 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,771,285 1,771,285 0 0.0%
SILModule.NumSILGenGlobalVariables 55,184 55,184 0 0.0%
SILModule.NumSILGenVtables 19,137 19,137 0 0.0%
SILModule.NumSILGenWitnessTables 75,827 75,827 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,609,881 2,609,881 0 0.0%
SILModule.NumSILOptGlobalVariables 56,900 56,900 0 0.0%
SILModule.NumSILOptVtables 32,429 32,429 0 0.0%
SILModule.NumSILOptWitnessTables 175,580 175,580 0 0.0%
SILOptimizer.ExecuteSILPipelineRequest 112,162 112,162 0 0.0%
Sema.AbstractGenericSignatureRequest 34,661 34,661 0 0.0%
Sema.AccessLevelRequest 13,180,945 13,280,642 99,697 0.76%
Sema.AnyObjectLookupRequest 283 283 0 0.0%
Sema.AreAllStoredPropertiesDefaultInitableRequest 22,054 22,054 0 0.0%
Sema.AttachedFunctionBuilderRequest 145 145 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 583,616 583,616 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,595,616 2,595,614 -2 -0.0%
Sema.CallerSideDefaultArgExprRequest 79,455 79,455 0 0.0%
Sema.CheckRedeclarationRequest 1,013,726 1,013,726 0 0.0%
Sema.ClassAncestryFlagsRequest 102,270 102,270 0 0.0%
Sema.ClosureHasExplicitResultRequest 93,431 93,431 0 0.0%
Sema.CollectOverriddenDeclsRequest 8,326,287 8,404,532 78,245 0.94%
Sema.CompareDeclSpecializationRequest 491,529 492,143 614 0.12%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 432 432 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 55,533 55,534 1 0.0%
Sema.DefaultArgumentExprRequest 39,875 39,875 0 0.0%
Sema.DefaultArgumentInitContextRequest 492 492 0 0.0%
Sema.DefaultDefinitionTypeRequest 8,190 8,190 0 0.0%
Sema.DefaultTypeRequest 498,438 498,438 0 0.0%
Sema.DerivativeAttrOriginalDeclRequest 0 0 0 0.0%
Sema.DifferentiableAttributeTypeCheckRequest 0 0 0 0.0%
Sema.DirectLookupRequest 34,585,416 34,620,994 35,578 0.1%
Sema.DynamicallyReplacedDeclRequest 1,044,548 1,044,548 0 0.0%
Sema.EmittedMembersRequest 26,720 26,720 0 0.0%
Sema.EnumRawTypeRequest 22,917 22,917 0 0.0%
Sema.EnumRawValuesRequest 10,886 10,886 0 0.0%
Sema.ExistentialConformsToSelfRequest 11,929 11,963 34 0.29%
Sema.ExistentialTypeSupportedRequest 16,497 16,497 0 0.0%
Sema.ExpandASTScopeRequest 6,720,196 6,720,191 -5 -0.0%
Sema.ExtendedNominalRequest 498,359 498,359 0 0.0%
Sema.ExtendedTypeRequest 78,347 78,348 1 0.0%
Sema.FragileFunctionKindRequest 1,770,103 1,770,104 1 0.0%
Sema.FunctionBuilderTypeRequest 145 145 0 0.0%
Sema.FunctionOperatorRequest 51,393 51,393 0 0.0%
Sema.GenericParamListRequest 9,596,732 9,654,671 57,939 0.6%
Sema.GenericSignatureRequest 2,402,538 2,404,735 2,197 0.09%
Sema.GetDestructorRequest 27,368 27,368 0 0.0%
Sema.HasCircularInheritanceRequest 23,090 23,090 0 0.0%
Sema.HasCircularInheritedProtocolsRequest 10,422 10,422 0 0.0%
Sema.HasCircularRawValueRequest 9,288 9,288 0 0.0%
Sema.HasDefaultInitRequest 53,642 53,642 0 0.0%
Sema.HasDynamicCallableAttributeRequest 0 0 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 585,714 586,017 303 0.05%
Sema.HasImplementationOnlyImportsRequest 316,924 316,924 0 0.0%
Sema.HasMemberwiseInitRequest 20,353 20,353 0 0.0%
Sema.HasMissingDesignatedInitializersRequest 25,414 25,414 0 0.0%
Sema.HasUserDefinedDesignatedInitRequest 53,652 53,652 0 0.0%
Sema.InferredGenericSignatureRequest 164,596 164,597 1 0.0%
Sema.InheritedDeclsReferencedRequest 5,389,891 5,406,404 16,513 0.31%
Sema.InheritedProtocolsRequest 526,071 526,715 644 0.12%
Sema.InheritedTypeRequest 287,456 287,499 43 0.01%
Sema.InheritsSuperclassInitializersRequest 26,387 26,387 0 0.0%
Sema.InitKindRequest 94,648 94,648 0 0.0%
Sema.InterfaceTypeRequest 14,180,768 14,248,095 67,327 0.47%
Sema.IsABICompatibleOverrideRequest 140,067 140,067 0 0.0%
Sema.IsAccessorTransparentRequest 318,448 318,448 0 0.0%
Sema.IsCallableNominalTypeRequest 2,170 2,170 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,743,077 1,743,077 0 0.0%
Sema.IsFinalRequest 2,738,519 2,748,273 9,754 0.36%
Sema.IsGetterMutatingRequest 431,951 431,951 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,411,056 2,412,087 1,031 0.04%
Sema.IsObjCRequest 1,560,856 1,561,774 918 0.06%
Sema.IsSetterMutatingRequest 374,778 374,778 0 0.0%
Sema.IsStaticRequest 895,782 895,857 75 0.01%
Sema.LazyStoragePropertyRequest 2,497 2,497 0 0.0%
Sema.LookupAllConformancesInContextRequest 85,320 85,320 0 0.0%
Sema.LookupConformanceInModuleRequest 37,350,749 37,380,938 30,189 0.08%
Sema.LookupInModuleRequest 6,410,838 6,419,172 8,334 0.13%
Sema.LookupPostfixOperatorRequest 184 184 0 0.0%
Sema.LookupPrefixOperatorRequest 563 563 0 0.0%
Sema.MangleLocalTypeDeclRequest 510 510 0 0.0%
Sema.ModuleImplicitImportsRequest 10,015 10,015 0 0.0%
Sema.ModuleQualifiedLookupRequest 3,023,210 3,031,574 8,364 0.28%
Sema.NamedLazyMemberLoadSuccessCount 20,409,472 20,414,101 4,629 0.02%
Sema.NamingPatternRequest 212,616 212,614 -2 -0.0%
Sema.NeedsNewVTableEntryRequest 684,823 684,823 0 0.0%
Sema.NumAccessorBodiesSynthesized 195,538 195,538 0 0.0%
Sema.NumAccessorsSynthesized 288,396 288,396 0 0.0%
Sema.NumConformancesDeserialized 9,390,683 9,433,979 43,296 0.46%
Sema.NumConstraintScopes 31,494,688 31,498,578 3,890 0.01%
Sema.NumConstraintsConsideredForEdgeContraction 103,464,167 103,465,012 845 0.0%
Sema.NumCrossImportsChecked 0 0 0 0.0%
Sema.NumCrossImportsFound 0 0 0 0.0%
Sema.NumCyclicOneWayComponentsCollapsed 269 269 0 0.0%
Sema.NumDeclsDeserialized 72,532,052 72,843,239 311,187 0.43%
Sema.NumDeclsTypechecked 1,461,835 1,461,835 0 0.0%
Sema.NumGenericSignatureBuilders 1,304,947 1,309,234 4,287 0.33%
Sema.NumLazyIterableDeclContexts 8,283,044 8,299,782 16,738 0.2%
Sema.NumLazyRequirementSignatures 787,513 788,237 724 0.09%
Sema.NumLazyRequirementSignaturesLoaded 585,808 586,482 674 0.12%
Sema.NumLeafScopes 20,063,354 20,066,651 3,297 0.02%
Sema.NumTypesDeserialized 22,568,984 22,641,815 72,831 0.32%
Sema.NumTypesValidated 647,349 647,347 -2 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 5,068,947 5,067,110 -1,837 -0.04%
Sema.OpaqueReadOwnershipRequest 272,847 272,847 0 0.0%
Sema.OpaqueResultTypeRequest 178 178 0 0.0%
Sema.OperatorPrecedenceGroupRequest 749 749 0 0.0%
Sema.OverriddenDeclsRequest 2,585,309 2,596,818 11,509 0.45%
Sema.ParamSpecifierRequest 1,222,998 1,222,999 1 0.0%
Sema.PatternBindingEntryRequest 470,647 470,645 -2 -0.0%
Sema.PatternTypeRequest 545,621 545,619 -2 -0.0%
Sema.PreCheckFunctionBuilderRequest 296 296 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 577,664 577,664 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 583,616 583,616 0 0.0%
Sema.PropertyWrapperLValuenessRequest 203 203 0 0.0%
Sema.PropertyWrapperMutabilityRequest 616,601 616,601 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 78 78 0 0.0%
Sema.ProtocolRequiresClassRequest 36,850 36,873 23 0.06%
Sema.ProvideDefaultImplForRequest 8,326,287 8,404,532 78,245 0.94%
Sema.QualifiedLookupRequest 5,595,121 5,601,724 6,603 0.12%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 113,363 113,364 1 0.0%
Sema.RequirementSignatureRequest 639,364 640,083 719 0.11%
Sema.RequiresOpaqueAccessorsRequest 1,339,497 1,339,497 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 262,185 262,185 0 0.0%
Sema.ResolveEffectiveMemberwiseInitRequest 0 0 0 0.0%
Sema.ResolveImplicitMemberRequest 388,312 388,842 530 0.14%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.ResolveTypeEraserTypeRequest 0 0 0 0.0%
Sema.ResolveTypeRequest 3,372,223 3,372,225 2 0.0%
Sema.ResultTypeRequest 651,383 651,383 0 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SPIGroupsRequest 14,838,540 14,930,901 92,361 0.62%
Sema.ScopedImportLookupRequest 1,076 1,076 0 0.0%
Sema.SelfAccessKindRequest 614,567 614,639 72 0.01%
Sema.SelfBoundsFromWhereClauseRequest 1,627,173 1,628,621 1,448 0.09%
Sema.SetterAccessLevelRequest 148,205 148,205 0 0.0%
Sema.SimpleDidSetRequest 2,652,306 2,667,734 15,428 0.58%
Sema.StorageImplInfoRequest 1,479,342 1,479,342 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 32,056 32,056 0 0.0%
Sema.StoredPropertiesRequest 325,254 325,254 0 0.0%
Sema.StructuralTypeRequest 2,037 2,037 0 0.0%
Sema.SuperclassDeclRequest 414,849 415,382 533 0.13%
Sema.SuperclassTypeRequest 54,401 54,401 0 0.0%
Sema.SynthesizeAccessorRequest 288,396 288,396 0 0.0%
Sema.SynthesizeDefaultInitRequest 5,016 5,016 0 0.0%
Sema.SynthesizeMemberwiseInitRequest 3,561 3,561 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 547,778 547,778 0 0.0%
Sema.TypeCheckSourceFileRequest 28,020 28,020 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 29,784 29,785 1 0.0%
Sema.TypeEraserHasViableInitRequest 0 0 0 0.0%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.TypeWitnessRequest 9,119 9,119 0 0.0%
Sema.USRGenerationRequest 9,737,035 9,818,608 81,573 0.84%
Sema.UnderlyingTypeDeclsReferencedRequest 269,806 270,600 794 0.29%
Sema.UnderlyingTypeRequest 34,690 34,690 0 0.0%
Sema.UnqualifiedLookupRequest 3,792,953 3,792,924 -29 -0.0%
Sema.ValidatePrecedenceGroupRequest 183,611 183,611 0 0.0%
Sema.ValueWitnessRequest 65,681 65,681 0 0.0%
TBDGen.GenerateTBDRequest 27,720 27,720 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 54,714,012,811,000 54,735,192,990,797 21,180,179,797 0.04%
LLVM.NumLLVMBytesOutput 1,882,012,084 1,882,006,352 -5,732 -0.0%
time.swift-driver.wall 6339.8s 6322.8s -17.0s -0.27%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (17)
name old new delta delta_pct
AST.NumLoadedModules 27,540 27,540 0 0.0%
AST.NumTotalClangImportedEntities 474,334 474,334 0 0.0%
IRModule.NumIRBasicBlocks 4,971,146 4,971,146 0 0.0%
IRModule.NumIRFunctions 2,876,857 2,876,857 0 0.0%
IRModule.NumIRGlobals 3,385,143 3,385,143 0 0.0%
IRModule.NumIRInsts 50,164,217 50,164,217 0 0.0%
IRModule.NumIRValueSymbols 5,892,400 5,892,400 0 0.0%
LLVM.NumLLVMBytesOutput 1,882,012,084 1,882,006,352 -5,732 -0.0%
SILModule.NumSILGenFunctions 1,237,823 1,237,823 0 0.0%
SILModule.NumSILOptFunctions 1,038,404 1,038,404 0 0.0%
Sema.NumConformancesDeserialized 3,575,764 3,575,764 0 0.0%
Sema.NumConstraintScopes 31,193,148 31,193,155 7 0.0%
Sema.NumDeclsDeserialized 11,237,441 11,237,465 24 0.0%
Sema.NumGenericSignatureBuilders 279,204 279,204 0 0.0%
Sema.NumLazyIterableDeclContexts 1,402,777 1,402,777 0 0.0%
Sema.NumTypesDeserialized 5,437,518 5,437,518 0 0.0%
Sema.NumTypesValidated 494,084 494,084 0 0.0%

@hamishknight hamishknight marked this pull request as ready for review May 5, 2020 00:06
@hamishknight hamishknight requested review from CodaFi and slavapestov May 5, 2020 00:06
@swiftlang swiftlang deleted a comment from swift-ci May 5, 2020
@hamishknight
Copy link
Contributor Author

Ping @CodaFi @slavapestov

Add overloads of `removeShadowedDecls` that deal
with operator and precedencegroup decls, and
template the existing shadowing logic such that it
can process them.
For now disabled by default, but once we get a new
language mode, we should flip it on by default.
We don't need to look at re-exports when resolving
cross references. Luckily the old lookup logic
didn't, but the new logic will. Therefore switch
it over to calling the appropriate request for a
direct operator lookup. In addition, return a
deserialization error instead of silently
returning nullptr if the lookup fails.
Re-implement operator and precedencegroup decl
lookup to use `namelookup::getAllImports` and
existing decl shadowing logic. This allows us to
find operator decls through `@_exported` imports,
prefer operator decls defined in the same module
over imported decls, and fixes a couple of other
subtle issues.

Because this new implementation is technically
source breaking, as we can find multiple results
where we used to only find one result, it's placed
behind the new Frontend flag
`-enable-new-operator-lookup` (with the aim of
enabling it by default when we get a new language
mode).

However the new logic will always be used if the
result is unambiguous. This means that e.g
`@_exported` operators will be instantly available
as long as there's only one candidate. If multiple
candidates are found, we fall back to the old
logic.

Resolves SR-12132.
Resolves rdar://59198796.
Previously we permitted operator redeclarations
across files as the user could shadow imported
operator decls on a per-file basis, and we would
prefer an imported operator decl over one in
another file.

However with the new operator lookup
implementation, operators in the current module
always shadow imported decls. As such, we should
start diagnosing cross-file redeclarations when
the new lookup logic is enabled.

Resolves rdar://48731166
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2020
@swiftlang swiftlang deleted a comment from swift-ci May 18, 2020
@hamishknight
Copy link
Contributor Author

swiftlang/llvm-project#892

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight merged commit 9e2cdf4 into swiftlang:master May 23, 2020
@hamishknight hamishknight deleted the hello-operator branch May 23, 2020 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants