Skip to content

[CSStep] Add a nullptr check to IsDeclRefinementOfRequest::evaluate #70956

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 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Sema/CSStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ bool IsDeclRefinementOfRequest::evaluate(Evaluator &evaluator,
auto interfaceTy =
origType->getInterfaceType()->getCanonicalType()->getAs<SubstitutableType>();

if (!interfaceTy)
return CanType();

// Make sure any duplicate bindings are equal to the one already recorded.
// Otherwise, the substitution has conflicting generic arguments.
auto bound = substMap.find(interfaceTy);
Expand Down
26 changes: 26 additions & 0 deletions test/Sema/diag_ambiguous_overloads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,29 @@ do {

f2(f1) // expected-error {{no 'f1' candidates produce the expected type '(String) -> Void' for parameter #0}}
}

// https://forums.swift.org/t/1-x-type-inference/69417/15
protocol N { associatedtype D }

infix operator ++ : AdditionPrecedence
infix operator -- : AdditionPrecedence

func ++ <T: N> (lhs: T, rhs: T) -> T.D { fatalError() } // expected-note {{found this candidate}}
func ++ <T: N> (lhs: T, rhs: T) -> T { fatalError() } // expected-note {{found this candidate}}

func -- <T: N> (lhs: T, rhs: T) -> T { fatalError() } // expected-note {{found this candidate}}
func -- <T: N> (lhs: T, rhs: T) -> T.D { fatalError() } // expected-note {{found this candidate}}

do {
struct MyInt16: N { typealias D = MyInt32 }
struct MyInt32: N { typealias D = MyInt64 }
struct MyInt64 {}

var i16 = MyInt16()

let _ = i16 ++ i16
// expected-error@-1 {{ambiguous use of operator '++'}}

let _ = i16 -- i16
// expected-error@-1 {{ambiguous use of operator '--'}}
}