Skip to content

Commit de7033c

Browse files
author
David Ungar
committed
Simplest fix to a dependency bug.
Better commenting-out
1 parent aef3464 commit de7033c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/AST/AbstractSourceFileDepGraphFactory.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,30 @@ void AbstractSourceFileDepGraphFactory::addAUsedDecl(
7979
const DependencyKey &defKey, const DependencyKey &useKey) {
8080
auto *defNode =
8181
g.findExistingNodeOrCreateIfNew(defKey, None, false /* = !isProvides */);
82+
8283
// If the depended-upon node is defined in this file, then don't
8384
// create an arc to the user, when the user is the whole file.
8485
// Otherwise, if the defNode's type-body fingerprint changes,
8586
// the whole file will be marked as dirty, losing the benefit of the
8687
// fingerprint.
87-
if (defNode->getIsProvides() &&
88-
useKey.getKind() == NodeKind::sourceFileProvide)
89-
return;
88+
89+
// if (defNode->getIsProvides() &&
90+
// useKey.getKind() == NodeKind::sourceFileProvide)
91+
// return;
92+
93+
// Turns out the above three lines cause miscompiles, so comment them out
94+
// for now. We might want them back if we can change the inputs to this
95+
// function to be more precise.
96+
97+
// Example of a miscompile:
98+
// In main.swift
99+
// func foo(_: Any) { print("Hello Any") }
100+
// foo(123)
101+
// Then add the following line to another file:
102+
// func foo(_: Int) { print("Hello Int") }
103+
// Although main.swift needs to get recompiled, the commented-out code below
104+
// prevents that.
105+
90106
auto nullableUse = g.findExistingNode(useKey);
91107
assert(nullableUse.isNonNull() && "Use must be an already-added provides");
92108
auto *useNode = nullableUse.get();

0 commit comments

Comments
 (0)