An Ident
represents a reference to a named entity. We give it meaning by typechecking it, according the the rules of binding. It may bind to A) a name defined in an enclosing scope, or B) a member of an enclosing self type, or C) to an entity brought into a scope via an import.
In case B and C, the typechecker will sometimes expand the Ident
into a Select
.
Here’s an example of this in action
Typechecking will also assign a Symbol
to the resulting Ident
or Select
to link it do the entity it references (the definition already has the same Symbol
assigned), and compute its type. The type is computed based on the prefix of the selection, so Some(Int).get
gets the type Int
, rather than A
Select means the dot "operator."
I guess A is get's declared return type, which in the call site context can be resolved to Int.
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In that example, why the "this" in the expansion of "identity" when
there isn't one in the expansion of "Predef"?
Good question! I dug into it, and it turns out that the root import of scala.Predef._
is actually being generated as scala.this.Predef._
(where scala.this
is a ThisType
referring to the scala package class.)
I’ve tracked this and proposed a fix over at SI-9473