Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6322,6 +6322,13 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
// not a match in this case.
auto impact =
locator->findLast<LocatorPathElt::UnresolvedMember>() ? 2 : 1;

// Impact is higher if the the base type is any function type
// because function types can't have any members other than self
if (baseObjTy->getDesugaredType()->is<AnyFunctionType>()) {
impact += 1;
Comment thread
xedin marked this conversation as resolved.
Outdated
}

if (recordFix(fix, impact))
return SolutionKind::Error;

Expand Down
20 changes: 20 additions & 0 deletions test/Constraints/diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1385,3 +1385,23 @@ class ClassWithPropContainingSetter {
set { return 1 } // expected-error {{unexpected non-void return value in void function}}
}
}

// https://bugs.swift.org/browse/SR-11964
struct Rect {
let width: Int
let height: Int
}

struct Frame {
func rect(width: Int, height: Int) -> Rect {
Rect(width: width, height: height)
}

let rect: Rect
}

func foo(frame: Frame) {
frame.rect.width + 10.0 // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'Double'}}
// expected-note@-1 {{overloads for '+' exist with these partially matching parameter lists: (Double, Double), (Int, Int)}}

}