@@ -79,14 +79,30 @@ void AbstractSourceFileDepGraphFactory::addAUsedDecl(
79
79
const DependencyKey &defKey, const DependencyKey &useKey) {
80
80
auto *defNode =
81
81
g.findExistingNodeOrCreateIfNew (defKey, None, false /* = !isProvides */ );
82
+
82
83
// If the depended-upon node is defined in this file, then don't
83
84
// create an arc to the user, when the user is the whole file.
84
85
// Otherwise, if the defNode's type-body fingerprint changes,
85
86
// the whole file will be marked as dirty, losing the benefit of the
86
87
// 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
+
90
106
auto nullableUse = g.findExistingNode (useKey);
91
107
assert (nullableUse.isNonNull () && " Use must be an already-added provides" );
92
108
auto *useNode = nullableUse.get ();
0 commit comments