Skip to content
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

Add static and class subscripts #23358

Merged
merged 9 commits into from
Apr 11, 2019

Conversation

beccadax
Copy link
Contributor

This PR lets you declare static subscripts or, in classes, class subscripts, removing an unnecessary asymmetry between different kinds of members.

This is just a quick Saturday prototype right now—it's nowhere near fully tested and I'm sure there are plenty of buried bodies I haven't discovered yet.

@beccadax beccadax added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Mar 17, 2019
@beccadax

This comment has been minimized.

@beccadax

This comment has been minimized.

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@beccadax

This comment has been minimized.

@swift-ci

This comment has been minimized.

@beccadax

This comment has been minimized.

1 similar comment
@beccadax

This comment has been minimized.

@swift-ci

This comment has been minimized.

@beccadax beccadax force-pushed the a-type-is-a-set-of-its-instances branch 4 times, most recently from 099b736 to 6ca894c Compare March 28, 2019 17:21
@beccadax beccadax mentioned this pull request Mar 28, 2019
@beccadax beccadax force-pushed the a-type-is-a-set-of-its-instances branch from 6ca894c to 977ac2e Compare March 28, 2019 17:40
@beccadax
Copy link
Contributor Author

Rolled back work on metatype key paths, which are now out of scope. That work is parked in #23623.

@beccadax

This comment has been minimized.

1 similar comment
@beccadax

This comment has been minimized.

@beccadax

This comment has been minimized.

@beccadax

This comment has been minimized.

@beccadax

This comment has been minimized.

@beccadax
Copy link
Contributor Author

Summary for master full

Unexpected test results, excluded stats for CoreStore, Tagged, ProcedureKit, Wordy, Deferred

No regressions above thresholds

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 25,323,286,735,460 25,265,855,160,985 -57,431,574,475 -0.23%
LLVM.NumLLVMBytesOutput 972,775,292 972,773,660 -1,632 -0.0%
time.swift-driver.wall 2403.2s 2403.1s -133.0ms -0.01%

debug-batch 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) (99)
name old new delta delta_pct
AST.NumASTBytesAllocated 61,305,649,229 61,309,943,215 4,293,986 0.01%
AST.NumDecls 80,786 80,786 0 0.0%
AST.NumDependencies 160,472 160,466 -6 -0.0%
AST.NumImportedExternalDefinitions 919,976 919,976 0 0.0%
AST.NumInfixOperators 31,080 31,080 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 196,321 196,321 0 0.0%
AST.NumLocalTypeDecls 108 108 0 0.0%
AST.NumObjCMethods 9,724 9,724 0 0.0%
AST.NumPostfixOperators 18 18 0 0.0%
AST.NumPrecedenceGroups 14,514 14,514 0 0.0%
AST.NumPrefixOperators 70 70 0 0.0%
AST.NumReferencedDynamicNames 92 92 0 0.0%
AST.NumReferencedMemberNames 3,511,573 3,511,573 0 0.0%
AST.NumReferencedTopLevelNames 271,022 271,022 0 0.0%
AST.NumSourceBuffers 234,257 234,257 0 0.0%
AST.NumSourceLines 2,432,547 2,432,547 0 0.0%
AST.NumSourceLinesPerSecond 2,184,508 2,188,734 4,226 0.19%
AST.NumTotalClangImportedEntities 3,596,501 3,599,818 3,317 0.09%
AST.NumUsedConformances 226,386 226,386 0 0.0%
Driver.ChildrenMaxRSS 107,199,283,200 107,239,983,104 40,699,904 0.04%
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 16,205 16,205 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 165,523 164,049 -1,474 -0.89%
Driver.NumDriverPipeReads 177,350 176,204 -1,146 -0.65%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 587,635,049,752 587,873,188,904 238,139,152 0.04%
Frontend.NumInstructionsExecuted 25,323,286,735,460 25,265,855,160,985 -57,431,574,475 -0.23%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 105,540 105,540 0 0.0%
IRModule.NumIRBasicBlocks 3,849,136 3,849,136 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 1,804,505 1,804,505 0 0.0%
IRModule.NumIRGlobals 1,857,058 1,857,058 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 47,452,775 47,452,775 0 0.0%
IRModule.NumIRNamedMetaData 78,402 78,402 0 0.0%
IRModule.NumIRValueSymbols 3,302,011 3,302,011 0 0.0%
LLVM.NumLLVMBytesOutput 972,775,292 972,773,660 -1,632 -0.0%
Parse.NumFunctionsParsed 142,585 142,585 0 0.0%
Parse.NumIterableDeclContextParsed 709,593 709,593 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 932,961 932,961 0 0.0%
SILModule.NumSILGenGlobalVariables 37,189 37,189 0 0.0%
SILModule.NumSILGenVtables 10,694 10,694 0 0.0%
SILModule.NumSILGenWitnessTables 39,362 39,362 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,326,972 1,326,972 0 0.0%
SILModule.NumSILOptGlobalVariables 37,947 37,947 0 0.0%
SILModule.NumSILOptVtables 17,207 17,207 0 0.0%
SILModule.NumSILOptWitnessTables 86,613 86,613 0 0.0%
Sema.AccessLevelRequest 2,171,313 2,171,511 198 0.01%
Sema.DefaultAndMaxAccessLevelRequest 49,711 49,711 0 0.0%
Sema.DefaultTypeRequest 315,674 315,674 0 0.0%
Sema.EnumRawTypeRequest 15,117 15,117 0 0.0%
Sema.ExtendedNominalRequest 3,197,579 3,200,871 3,292 0.1%
Sema.InheritedDeclsReferencedRequest 3,892,938 3,902,559 9,621 0.25%
Sema.InheritedTypeRequest 564,725 565,321 596 0.11%
Sema.IsDynamicRequest 1,678,371 1,678,371 0 0.0%
Sema.IsObjCRequest 1,435,594 1,435,542 -52 -0.0%
Sema.MangleLocalTypeDeclRequest 216 216 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 17,007 17,017 10 0.06%
Sema.NamedLazyMemberLoadSuccessCount 16,443,501 16,450,429 6,928 0.04%
Sema.NominalTypeLookupDirectCount 27,459,077 27,467,332 8,255 0.03%
Sema.NumConformancesDeserialized 6,180,248 6,190,799 10,551 0.17%
Sema.NumConstraintScopes 14,816,710 14,818,660 1,950 0.01%
Sema.NumConstraintsConsideredForEdgeContraction 41,224,999 41,225,574 575 0.0%
Sema.NumDeclsDeserialized 43,889,207 43,952,520 63,313 0.14%
Sema.NumDeclsFinalized 1,499,521 1,499,521 0 0.0%
Sema.NumDeclsTypechecked 895,861 895,861 0 0.0%
Sema.NumDeclsValidated 1,814,194 1,814,194 0 0.0%
Sema.NumFunctionsTypechecked 848,567 848,567 0 0.0%
Sema.NumGenericSignatureBuilders 1,011,622 1,012,806 1,184 0.12%
Sema.NumLazyGenericEnvironments 8,672,415 8,677,630 5,215 0.06%
Sema.NumLazyGenericEnvironmentsLoaded 188,247 188,435 188 0.1%
Sema.NumLazyIterableDeclContexts 5,730,093 5,734,790 4,697 0.08%
Sema.NumLeafScopes 9,619,668 9,621,124 1,456 0.02%
Sema.NumTypesDeserialized 14,308,589 14,323,157 14,568 0.1%
Sema.NumTypesValidated 1,227,708 1,227,706 -2 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 3,608,604 3,610,542 1,938 0.05%
Sema.OverriddenDeclsRequest 7,276,296 7,286,516 10,220 0.14%
Sema.RequirementRequest 59,884 59,884 0 0.0%
Sema.SelfBoundsFromWhereClauseRequest 5,653,243 5,667,892 14,649 0.26%
Sema.SetterAccessLevelRequest 126,612 126,612 0 0.0%
Sema.SuperclassDeclRequest 59,046 59,301 255 0.43%
Sema.SuperclassTypeRequest 28,517 28,517 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 28,021 28,021 0 0.0%
Sema.USRGenerationRequest 12,449,698 12,474,064 24,366 0.2%
Sema.UnderlyingTypeDeclsReferencedRequest 134,261 134,421 160 0.12%

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 25,575,835,994,835 25,528,786,137,206 -47,049,857,629 -0.18%
LLVM.NumLLVMBytesOutput 779,847,214 779,843,818 -3,396 -0.0%
time.swift-driver.wall 4061.9s 4062.6s 665.5ms 0.02%

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) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 216,559 216,559 0 0.0%
AST.NumLoadedModules 16,492 16,492 0 0.0%
AST.NumTotalClangImportedEntities 736,667 736,667 0 0.0%
AST.NumUsedConformances 227,331 227,331 0 0.0%
IRModule.NumIRBasicBlocks 3,234,121 3,234,121 0 0.0%
IRModule.NumIRFunctions 1,486,895 1,486,895 0 0.0%
IRModule.NumIRGlobals 1,622,639 1,622,639 0 0.0%
IRModule.NumIRInsts 29,381,129 29,381,129 0 0.0%
IRModule.NumIRValueSymbols 2,896,376 2,896,376 0 0.0%
LLVM.NumLLVMBytesOutput 779,847,214 779,843,818 -3,396 -0.0%
SILModule.NumSILGenFunctions 653,152 653,152 0 0.0%
SILModule.NumSILOptFunctions 889,962 889,962 0 0.0%
Sema.NumConformancesDeserialized 2,233,184 2,233,184 0 0.0%
Sema.NumConstraintScopes 13,401,956 13,401,956 0 0.0%
Sema.NumDeclsDeserialized 6,021,369 6,021,369 0 0.0%
Sema.NumDeclsValidated 1,038,655 1,038,655 0 0.0%
Sema.NumFunctionsTypechecked 428,737 428,737 0 0.0%
Sema.NumGenericSignatureBuilders 190,265 190,265 0 0.0%
Sema.NumLazyGenericEnvironments 1,245,248 1,245,248 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 21,173 21,173 0 0.0%
Sema.NumLazyIterableDeclContexts 765,629 765,629 0 0.0%
Sema.NumTypesDeserialized 3,186,576 3,186,576 0 0.0%
Sema.NumTypesValidated 616,421 616,421 0 0.0%

@beccadax

This comment has been minimized.

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@beccadax

This comment has been minimized.

1 similar comment
@DougGregor

This comment has been minimized.

@DougGregor

This comment has been minimized.

1 similar comment
@DougGregor

This comment has been minimized.

@beccadax
Copy link
Contributor Author

beccadax commented Apr 3, 2019

@swift-ci please test source compatibility

@beccadax
Copy link
Contributor Author

beccadax commented Apr 4, 2019

@swift-ci please test compiler performance

1 similar comment
@beccadax
Copy link
Contributor Author

beccadax commented Apr 5, 2019

@swift-ci please test compiler performance

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Only small comments from me.

lib/Parse/ParseDecl.cpp Show resolved Hide resolved
test/attr/attr_override.swift Outdated Show resolved Hide resolved
test/decl/subscript/static.swift Outdated Show resolved Hide resolved
lib/Sema/TypeCheckDeclObjC.cpp Outdated Show resolved Hide resolved
test/Interpreter/generic_subscript_static.swift Outdated Show resolved Hide resolved
@beccadax beccadax force-pushed the a-type-is-a-set-of-its-instances branch from dd635bb to 7588d38 Compare April 6, 2019 01:56
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@beccadax beccadax marked this pull request as ready for review April 11, 2019 06:06
beccadax and others added 9 commits April 10, 2019 23:09
In this commit, MyStruct.self[0] parses and typechecks but the solution doesn’t apply correctly. MyStruct[0] gets diagnosed as an error.
Obj-C subscripts don’t work on class objects, but you can declare class methods with the appropriate names. We don’t want to half-support this. Emit an error if you try to write “@objc class subscript” and test that we don’t import the methods as subscripts.
This commit modifies various subscript-related test files to add static subscript equivalents of existing tests.
@beccadax beccadax force-pushed the a-type-is-a-set-of-its-instances branch from 8a463e5 to 7ae331d Compare April 11, 2019 06:19
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax beccadax added swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process and removed swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review labels Apr 11, 2019
@beccadax beccadax merged commit def1af6 into swiftlang:master Apr 11, 2019
beccadax added a commit to beccadax/swift that referenced this pull request Apr 11, 2019
…ts-instances

Add static and class subscripts
@johnfairh
Copy link
Contributor

@brentdax are you going to make a SourceKit change to go with this, to make static and instance subscripts look different?

@beccadax
Copy link
Contributor Author

@johnfairh Not me personally, but the SourceKit team is scheduled to work on it.

@johnfairh
Copy link
Contributor

Great, thanks.

@beccadax beccadax deleted the a-type-is-a-set-of-its-instances branch April 16, 2019 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants