aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-02 09:23:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-02 09:23:18 +0200
commit1214dffc272f6f0ffee4e8ec203804b21023930d (patch)
treedc420bbcfdee3439d933beee1549acc55e870829
parentcd2b498e552434ee97ef12ef6d9f0b7829e00846 (diff)
Improve override cache typing to handle value-typed stems
-rw-r--r--build2/scope.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index 0659797..b0bd109 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -249,23 +249,30 @@ namespace build2
// If there is a stem, set it as the initial value of the cache.
// Otherwise, start with a NULL value.
//
+
+ // Un-typify the cache. This can be necessary, for example, if we are
+ // changing from one value-typed stem to another.
+ //
+ if (!stem.defined () || cache.value.type != stem->type)
+ {
+ cache.value = nullptr;
+ cache.value.type = nullptr; // Un-typify.
+ }
+
if (stem.defined ())
{
cache.value = *stem;
cache.stem_vars = stem.vars;
}
else
- {
- cache.value = nullptr;
cache.stem_vars = nullptr; // No stem.
- }
// Typify the cache value. If the stem is the original, then the type
// would get propagated automatically. But the stem could also be the
// override, which is kept untyped. Or the stem might not be there at all
// while we still need to apply prefixes/suffixes in the type-aware way.
//
- if (cache.value.type != var.type)
+ if (cache.value.type == nullptr && var.type != nullptr)
typify (cache.value, *var.type, var);
// Now apply override prefixes and suffixes.