mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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) {
|
const DependencyKey &defKey, const DependencyKey &useKey) {
|
||||||
auto *defNode =
|
auto *defNode =
|
||||||
g.findExistingNodeOrCreateIfNew(defKey, None, false /* = !isProvides */);
|
g.findExistingNodeOrCreateIfNew(defKey, None, false /* = !isProvides */);
|
||||||
|
|
||||||
// If the depended-upon node is defined in this file, then don't
|
// 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.
|
// create an arc to the user, when the user is the whole file.
|
||||||
// Otherwise, if the defNode's type-body fingerprint changes,
|
// Otherwise, if the defNode's type-body fingerprint changes,
|
||||||
// the whole file will be marked as dirty, losing the benefit of the
|
// the whole file will be marked as dirty, losing the benefit of the
|
||||||
// fingerprint.
|
// fingerprint.
|
||||||
if (defNode->getIsProvides() &&
|
|
||||||
useKey.getKind() == NodeKind::sourceFileProvide)
|
// if (defNode->getIsProvides() &&
|
||||||
return;
|
// 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);
|
auto nullableUse = g.findExistingNode(useKey);
|
||||||
assert(nullableUse.isNonNull() && "Use must be an already-added provides");
|
assert(nullableUse.isNonNull() && "Use must be an already-added provides");
|
||||||
auto *useNode = nullableUse.get();
|
auto *useNode = nullableUse.get();
|
||||||
|
|||||||
Reference in New Issue
Block a user