File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -2871,7 +2871,8 @@ class ConstraintSystem {
2871
2871
// / A set of all constraints which contribute to pontential bindings.
2872
2872
llvm::SmallPtrSet<Constraint *, 8 > Sources;
2873
2873
2874
- PotentialBindings (TypeVariableType *typeVar) : TypeVar(typeVar) {}
2874
+ PotentialBindings (TypeVariableType *typeVar)
2875
+ : TypeVar(typeVar), PotentiallyIncomplete(isGenericParameter()) {}
2875
2876
2876
2877
// / Determine whether the set of bindings is non-empty.
2877
2878
explicit operator bool () const { return !Bindings.empty (); }
@@ -2937,6 +2938,16 @@ class ConstraintSystem {
2937
2938
// / Check if this binding is viable for inclusion in the set.
2938
2939
bool isViable (PotentialBinding &binding) const ;
2939
2940
2941
+ bool isGenericParameter () const {
2942
+ if (auto *locator = TypeVar->getImpl ().getLocator ()) {
2943
+ auto path = locator->getPath ();
2944
+ return path.empty () ? false
2945
+ : path.back ().getKind () ==
2946
+ ConstraintLocator::GenericParameter;
2947
+ }
2948
+ return false ;
2949
+ }
2950
+
2940
2951
void dump (llvm::raw_ostream &out,
2941
2952
unsigned indent = 0 ) const LLVM_ATTRIBUTE_USED {
2942
2953
out.indent (indent);
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
2
+
3
+ class BaseClass { }
4
+ class SubClass : BaseClass { }
5
+ struct Box < T> { init ( _: T . Type ) { } }
6
+
7
+
8
+ func test1< T> ( box: Box < T > ) -> T . Type {
9
+ return T . self
10
+ }
11
+
12
+ func test2< T: BaseClass > ( box: Box < T > ) -> T . Type {
13
+ return T . self
14
+ }
15
+
16
+ // CHECK: [[F1:%.*]] = function_ref @$s6sr96263BoxVyACyxGxmcfC
17
+ // CHECK-NEXT: apply [[F1]]<SubClass>({{.*}}, {{.*}})
18
+ _ = test1 ( box: . init( SubClass . self) )
19
+
20
+ // CHECK: [[F2:%.*]] = function_ref @$s6sr96265test23boxxmAA3BoxVyxG_tAA9BaseClassCRbzlF
21
+ // CHECK-NEXT: apply [[F2]]<SubClass>({{.*}})
22
+ _ = test2 ( box: . init( SubClass . self) )
You can’t perform that action at this time.
0 commit comments