Skip to content

Commit 7300868

Browse files
committed
SingleDenotation#signature: Use Scala 3 signature for non-SymDenotations
For SymDenotations, it's important that we use a signature that matches how the type is erased to maintain the invariant that two overloads in the same owner have different signatures, but for non-SymDenotations we don't make this guarantee so we can choose whatever we want as long as it's consistent. I originally chose to treat them like SymDenotation for consistency, but we're about to add some complex (and therefore somewhat expensive) logic for dealing with Scala 2 intersection erasure, by using the Scala 3 signature for all non-SymDenotation we avoid calling this logic more than we need to.
1 parent 2c901c8 commit 7300868

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ object Denotations {
582582
*/
583583
def prefix: Type = NoPrefix
584584

585-
/** The symbol-specific signature of the info.
585+
/** For SymDenotations, the language-specific signature of the info, depending on
586+
* where the symbol is defined. For non-SymDenotations, the Scala 3
587+
* signature.
586588
*
587589
* Invariants:
588590
* - Before erasure, the signature of a denotation is always equal to the
@@ -594,7 +596,7 @@ object Denotations {
594596
* SingleDenotations will have distinct signatures (cf #9050).
595597
*/
596598
final def signature(using Context): Signature =
597-
signature(sourceLanguage = if isType then SourceLanguage.Scala3 else SourceLanguage(symbol))
599+
signature(sourceLanguage = if isType || !this.isInstanceOf[SymDenotation] then SourceLanguage.Scala3 else SourceLanguage(symbol))
598600

599601
/** Overload of `signature` which lets the caller pick the language used
600602
* to compute the signature of the info. Useful to match denotations defined in

0 commit comments

Comments
 (0)