Skip to content

Commit 67e2362

Browse files
committed
Something in the SIL printer is printing function types without parens, breaking
round tripping. Until we can fix this, don't error on them, to unbreak botz.
1 parent b7313d2 commit 67e2362

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,10 +1949,19 @@ Type TypeResolver::resolveASTFunctionType(FunctionTypeRepr *repr,
19491949
if (!isa<TupleTypeRepr>(repr->getArgsTypeRepr()) &&
19501950
!repr->isWarnedAbout()) {
19511951
auto args = repr->getArgsTypeRepr();
1952-
TC.diagnose(args->getStartLoc(), diag::function_type_no_parens)
1953-
.highlight(args->getSourceRange())
1954-
.fixItInsert(args->getStartLoc(), "(")
1955-
.fixItInsertAfter(args->getEndLoc(), ")");
1952+
1953+
bool isInSILMode = false;
1954+
if (auto sourceFile = DC->getParentSourceFile())
1955+
isInSILMode = sourceFile->Kind == SourceFileKind::SIL;
1956+
1957+
// The SIL printer is still printing function types with no parens in some
1958+
// cases. Don't warn for now.
1959+
if (!isInSILMode) {
1960+
TC.diagnose(args->getStartLoc(), diag::function_type_no_parens)
1961+
.highlight(args->getSourceRange())
1962+
.fixItInsert(args->getStartLoc(), "(")
1963+
.fixItInsertAfter(args->getEndLoc(), ")");
1964+
}
19561965
// Don't emit this warning three times when in generics.
19571966
repr->setWarned();
19581967
}

0 commit comments

Comments
 (0)