mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Simplest fix to a dependency bug.
Better commenting-out
This commit is contained in:
@@ -79,14 +79,30 @@ void AbstractSourceFileDepGraphFactory::addAUsedDecl(
|
||||
const DependencyKey &defKey, const DependencyKey &useKey) {
|
||||
auto *defNode =
|
||||
g.findExistingNodeOrCreateIfNew(defKey, None, false /* = !isProvides */);
|
||||
|
||||
// If the depended-upon node is defined in this file, then don't
|
||||
// create an arc to the user, when the user is the whole file.
|
||||
// Otherwise, if the defNode's type-body fingerprint changes,
|
||||
// the whole file will be marked as dirty, losing the benefit of the
|
||||
// fingerprint.
|
||||
if (defNode->getIsProvides() &&
|
||||
useKey.getKind() == NodeKind::sourceFileProvide)
|
||||
return;
|
||||
|
||||
// if (defNode->getIsProvides() &&
|
||||
// useKey.getKind() == NodeKind::sourceFileProvide)
|
||||
// return;
|
||||
|
||||
// Turns out the above three lines cause miscompiles, so comment them out
|
||||
// for now. We might want them back if we can change the inputs to this
|
||||
// function to be more precise.
|
||||
|
||||
// Example of a miscompile:
|
||||
// In main.swift
|
||||
// func foo(_: Any) { print("Hello Any") }
|
||||
// foo(123)
|
||||
// Then add the following line to another file:
|
||||
// func foo(_: Int) { print("Hello Int") }
|
||||
// Although main.swift needs to get recompiled, the commented-out code below
|
||||
// prevents that.
|
||||
|
||||
auto nullableUse = g.findExistingNode(useKey);
|
||||
assert(nullableUse.isNonNull() && "Use must be an already-added provides");
|
||||
auto *useNode = nullableUse.get();
|
||||
|
||||
Reference in New Issue
Block a user