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

[ConstraintSystem] Mark generic parameter bindings as potentially inc… #21931

Merged
merged 1 commit into from Jan 17, 2019

Conversation

xedin
Copy link
Member

@xedin xedin commented Jan 16, 2019

…omplete by default

This helps to postpone attempting bindings related to generic
parameters with all else being equal.

Consider situation when function has class requirement on its
generic parameter. Without such requirement solver would infer
sub-class for T. But currently when requirement is present base
class is inferred instead, because when bindings for such generic
parameter are attempted early single available binding at that
point comes from the requirement.

class BaseClass {}
class SubClass: BaseClass {}

struct Box<T> { init(_: T.Type) {} }

func test<T: BaseClass>(box: Box<T>) -> T.Type {
  return T.self
}

test(box: .init(SubClass.self)) // `T` expected to be `SubClass`

Resolves: SR-9626
Resolves: rdar://problem/47324309

@xedin xedin requested a review from DougGregor January 16, 2019 21:43
…omplete by default

This helps to postpone attempting bindings related to generic
parameters with all else being equal.

Consider situation when function has class requirement on its
generic parameter. Without such requirement solver would infer
sub-class for `T`. But currently when requirement is present base
class is inferred instead, because when bindings for such generic
parameter are attempted early single available binding at that
point comes from the requirement.

```swift
class BaseClass {}
class SubClass: BaseClass {}

struct Box<T> { init(_: T.Type) {} }

func test<T: BaseClass>(box: Box<T>) -> T.Type {
  return T.self
}

test(box: .init(SubClass.self)) // `T` expected to be `SubClass`
```

Resolves: [SR-9626](https://bugs.swift.org/browse/SR-9626)
Resolves: rdar://problem/47324309
@xedin
Copy link
Member Author

xedin commented Jan 16, 2019

@swift-ci please smoke test compiler performance

@xedin
Copy link
Member Author

xedin commented Jan 16, 2019

@swift-ci please test source compatibility

@swift-ci
Copy link
Collaborator

Build comment file:

Summary for master smoketest

Unexpected test results, excluded stats for Kingfisher, Alamofire, ReactiveCocoa

No regressions above thresholds

Debug

debug 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 124,641,163,618 124,546,931,567 -94,232,051 -0.08%
LLVM.NumLLVMBytesOutput 6,591,628 6,591,616 -12 -0.0%
time.swift-driver.wall 16.8s 16.8s -68.6ms -0.41%

debug 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 1,110 1,110 0 0.0%
AST.NumLoadedModules 1,038 1,038 0 0.0%
AST.NumTotalClangImportedEntities 4,462 4,462 0 0.0%
AST.NumUsedConformances 886 886 0 0.0%
IRModule.NumIRBasicBlocks 18,386 18,386 0 0.0%
IRModule.NumIRFunctions 10,964 10,964 0 0.0%
IRModule.NumIRGlobals 9,261 9,261 0 0.0%
IRModule.NumIRInsts 320,414 320,414 0 0.0%
IRModule.NumIRValueSymbols 19,344 19,344 0 0.0%
LLVM.NumLLVMBytesOutput 6,591,628 6,591,616 -12 -0.0%
SILModule.NumSILGenFunctions 5,384 5,384 0 0.0%
SILModule.NumSILOptFunctions 7,062 7,062 0 0.0%
Sema.NumConformancesDeserialized 17,055 17,055 0 0.0%
Sema.NumConstraintScopes 41,636 41,978 342 0.82%
Sema.NumDeclsDeserialized 148,779 148,779 0 0.0%
Sema.NumDeclsValidated 11,580 11,580 0 0.0%
Sema.NumFunctionsTypechecked 2,540 2,540 0 0.0%
Sema.NumGenericSignatureBuilders 5,026 5,026 0 0.0%
Sema.NumLazyGenericEnvironments 33,373 33,373 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 2,036 2,036 0 0.0%
Sema.NumLazyIterableDeclContexts 27,384 27,384 0 0.0%
Sema.NumTypesDeserialized 68,141 68,141 0 0.0%
Sema.NumTypesValidated 11,180 11,180 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 144,107,464,004 144,182,947,437 75,483,433 0.05%
LLVM.NumLLVMBytesOutput 7,562,480 7,562,308 -172 -0.0%
time.swift-driver.wall 27.5s 27.6s 112.5ms 0.41%

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 402 402 0 0.0%
AST.NumLoadedModules 76 76 0 0.0%
AST.NumTotalClangImportedEntities 2,113 2,113 0 0.0%
AST.NumUsedConformances 886 886 0 0.0%
IRModule.NumIRBasicBlocks 21,408 21,408 0 0.0%
IRModule.NumIRFunctions 10,630 10,630 0 0.0%
IRModule.NumIRGlobals 9,162 9,162 0 0.0%
IRModule.NumIRInsts 221,117 221,117 0 0.0%
IRModule.NumIRValueSymbols 18,992 18,992 0 0.0%
LLVM.NumLLVMBytesOutput 7,562,480 7,562,308 -172 -0.0%
SILModule.NumSILGenFunctions 4,180 4,180 0 0.0%
SILModule.NumSILOptFunctions 5,852 5,852 0 0.0%
Sema.NumConformancesDeserialized 12,287 12,287 0 0.0%
Sema.NumConstraintScopes 40,308 40,650 342 0.85%
Sema.NumDeclsDeserialized 32,498 32,498 0 0.0%
Sema.NumDeclsValidated 7,874 7,874 0 0.0%
Sema.NumFunctionsTypechecked 2,204 2,204 0 0.0%
Sema.NumGenericSignatureBuilders 1,710 1,710 0 0.0%
Sema.NumLazyGenericEnvironments 6,825 6,825 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 130 130 0 0.0%
Sema.NumLazyIterableDeclContexts 4,174 4,174 0 0.0%
Sema.NumTypesDeserialized 18,176 18,176 0 0.0%
Sema.NumTypesValidated 5,972 5,972 0 0.0%

@xedin
Copy link
Member Author

xedin commented Jan 17, 2019

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - 3fdee3869740f0fee8675e8bc7a929bb9281fae1

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - 3fdee3869740f0fee8675e8bc7a929bb9281fae1

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.

None yet

2 participants