Overview explanation how symbols, named types and denotations hang together: Denotations1
Comment with a few details: Denotations2
Denotation is the result of a name lookup during a given period
- Most properties of symbols are now in the denotation (name, type, owner, etc.)
- Denotations usually have a reference to the selected symbol
- Denotations may be overloaded (
MultiDenotation). In this case the symbol may be
NoSymbol(the two variants have symbols).
- Non-overloaded denotations have an
Denotations of methods have a signature (Signature1), which uniquely identifies overloaded methods.
SymDenotation is an extended denotation that has symbol-specific properties (that may change over phases) *
SymDenotation implements lazy types (similar to scalac). The type completer assigns the denotation's
There is an implicit conversion:
core.Symbols.toDenot(sym: Symbol)(implicit ctx: Context): SymDenotation
Because the class
Symbol is defined in the object
core.Symbols, the implicit conversion does not need to be imported, it is part of the implicit scope of the type
Symbol (check the Scala spec). However, it can only be applied if an implicit
Context is in scope.
Symbolinstances have a
- Most symbol properties in the Scala 2 compiler are now in the denotation (in the Scala 3 compiler).
Most of the
isFooBar properties in scalac don't exist anymore in dotc. Use flag tests instead, for example:
if (sym.isPackageClass) // Scala 2 if (sym is Flags.PackageClass) // Scala 3 (*)
(*) Symbols are implicitly converted to their denotation, see above. Each
SymDenotation has flags that can be queried using the
- Flags are instances of the value class
FlagSet, which encapsulates a
- Each flag is either valid for types, terms, or both
000..0001000..01 ^ ^^ flag | \ | valid for term valid for type
Moduleis valid for both module values and module classes,
ModuleClassfor either of the two.
flags.is(Method | Param): true if
flagshas either of the two
- Trees don't have symbols
NamdedType(see next point)
- Subclasses of
Ident, etc.) have a
NamedType, which has a
denotfield. The denotation has a symbol.
NamedType(prefix + name) for the current period is obtained from the symbol that the type refers to. This symbol is searched using
MethodType(paramSyms, resultType)from scalac =>
mt @ MethodType(paramNames, paramTypes). Result type is