Skip to content

baseType caching is broken because the cached type can contain uninstantiated type variables #5333

Closed
@smarter

Description

@smarter

In ClassDenotation#baseTypeOf, we have: https://github.com/lampepfl/dotty/blob/cedef0d317e39ee114a5ec0409604613837743a2/compiler/src/dotty/tools/dotc/core/SymDenotations.scala#L1697-L1707

Notice that record(tp, baseTp) is always called, even if tp contains uninstantiated type variables which could later be instantiated in a way that changes the base type. I haven't been able to make a test case that shows how this is broken in master, but I've hit this in a branch where I'm doing unrelated changes. I was able to work around the issue by doing:

if (isFullyDefined(tp, ForceDegree.none))
  record(tp, baseTp)
else
  btrCache.remove(tp) // Remove the "NoPrefix" sentinel value

but that causes many tests to fail with a cyclic error.

@odersky WDYT ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions