Always emit detailed type check diagnostics, update unit tests to reflect this.

Swift SVN r17334
This commit is contained in:
Joe Pamer
2014-05-03 23:03:47 +00:00
parent a155fc642a
commit 006158ff56
5 changed files with 45 additions and 58 deletions

View File

@@ -101,9 +101,6 @@ namespace swift {
getTargetConfigOptions() const {
return TargetConfigOptions;
}
/// Enables detailed type-check error reporting.
bool detailedTypeCheckDiagnostics = false;
private:
llvm::SmallVector<std::pair<std::string, std::string>, 2>

View File

@@ -137,10 +137,6 @@ def serialize_diagnostics : Flag<["-"], "serialize-diagnostics">,
Flags<[DriverOption, FrontendOption]>,
HelpText<"Serialize diagnostics in a binary format">;
def detailed_diagnostics : Flag<["-"], "detailed-diagnostics">,
Flags<[DriverOption, FrontendOption]>,
HelpText<"Produce more detailed diagnostics for type-check errors">;
def module_cache_path : Separate<["-"], "module-cache-path">,
Flags<[DriverOption, FrontendOption]>,
HelpText<"Specifies the Clang module cache path">;

View File

@@ -265,8 +265,6 @@ Job *Swift::constructJob(const JobAction &JA, std::unique_ptr<JobList> Inputs,
Args.AddLastArg(Arguments, options::OPT_split_objc_selectors);
Args.AddLastArg(Arguments, options::OPT_implicit_objc_with);
Args.AddLastArg(Arguments, options::OPT_strict_keyword_arguments);
Args.AddLastArg(Arguments, options::OPT_detailed_diagnostics);
// Pass the optimization level down to the frontend.
Args.AddLastArg(Arguments, options::OPT_O_Group);

View File

@@ -551,7 +551,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableAppExtensionRestrictions = Args.hasArg(OPT_enable_app_extension);
Opts.SplitPrepositions = Args.hasArg(OPT_split_objc_selectors);
Opts.ImplicitObjCWith = Args.hasArg(OPT_implicit_objc_with);
Opts.detailedTypeCheckDiagnostics = Args.hasArg(OPT_detailed_diagnostics);
Opts.StrictKeywordArguments = Args.hasArg(OPT_strict_keyword_arguments);
if (Opts.SplitPrepositions) {

View File

@@ -781,59 +781,56 @@ void ConstraintSystem::diagnoseFailureFromConstraints(Expr *expr) {
Constraint *activeConformanceConstraint = nullptr;
Constraint *valueMemberConstraint = nullptr;
Constraint *argumentConstraint = nullptr;
if(!ActiveConstraints.empty()) {
// If any active conformance constraints are in the system, we know that
// any inactive constraints are in its service. Capture the constraint and
// present this information to the user.
auto *constraint = &ActiveConstraints.front();
activeConformanceConstraint = getComponentConstraint(constraint);
}
if (TC.Context.LangOpts.detailedTypeCheckDiagnostics) {
while (!InactiveConstraints.empty()) {
auto *constraint = &InactiveConstraints.front();
if(!ActiveConstraints.empty()) {
// If any active conformance constraints are in the system, we know that
// any inactive constraints are in its service. Capture the constraint and
// present this information to the user.
auto *constraint = &ActiveConstraints.front();
activeConformanceConstraint = getComponentConstraint(constraint);
// Capture the first non-disjunction constraint we find. We'll use this
// if we can't find a clearer reason for the failure.
if (!fallbackConstraint &&
(constraint->getKind() != ConstraintKind::Disjunction)) {
fallbackConstraint = constraint;
}
while (!InactiveConstraints.empty()) {
auto *constraint = &InactiveConstraints.front();
// Capture the first non-disjunction constraint we find. We'll use this
// if we can't find a clearer reason for the failure.
if (!fallbackConstraint &&
(constraint->getKind() != ConstraintKind::Disjunction)) {
fallbackConstraint = constraint;
}
// Failed binding constraints point to a missing member.
if (!valueMemberConstraint &&
(constraint->getKind() == ConstraintKind::ValueMember)) {
valueMemberConstraint = constraint;
}
// A missed argument conversion can result in better error messages when
// a user passes the wrong arguments to a function application.
if (!argumentConstraint) {
argumentConstraint = getDisjunctionChoice(constraint,
ConstraintKind::
ArgumentTupleConversion);
}
// Overload resolution failures are often nicely descriptive, so store
// off the first one we find.
if (!overloadConstraint) {
overloadConstraint = getDisjunctionChoice(constraint,
ConstraintKind::BindOverload);
}
// Conversion constraints are also nicely descriptive, so we'll grab the
// first one of those as well.
if (!conversionConstraint &&
(constraint->getKind() == ConstraintKind::Conversion ||
constraint->getKind() == ConstraintKind::ArgumentTupleConversion)) {
conversionConstraint = constraint;
}
InactiveConstraints.pop_front();
// Failed binding constraints point to a missing member.
if (!valueMemberConstraint &&
(constraint->getKind() == ConstraintKind::ValueMember)) {
valueMemberConstraint = constraint;
}
// A missed argument conversion can result in better error messages when
// a user passes the wrong arguments to a function application.
if (!argumentConstraint) {
argumentConstraint = getDisjunctionChoice(constraint,
ConstraintKind::
ArgumentTupleConversion);
}
// Overload resolution failures are often nicely descriptive, so store
// off the first one we find.
if (!overloadConstraint) {
overloadConstraint = getDisjunctionChoice(constraint,
ConstraintKind::BindOverload);
}
// Conversion constraints are also nicely descriptive, so we'll grab the
// first one of those as well.
if (!conversionConstraint &&
(constraint->getKind() == ConstraintKind::Conversion ||
constraint->getKind() == ConstraintKind::ArgumentTupleConversion)) {
conversionConstraint = constraint;
}
InactiveConstraints.pop_front();
}
// If no more descriptive constraint was found, use the fallback constraint.