It looks like REPL does the following if you execute a line:
It wraps it into an anonymous object literal, imports the members of all previously generated objects and compiles that. If the line has a return value, it includes a member resX to that object and stores the return value there.
You can see that by executing stuff like this.
scala> def foo = "asd"; this
foo: String
res0: type = @ee7d9f1
scala> res0.foo
res1: String = asd
scala> def foo = this; this
foo: type
res2: type = @6d86b085
scala> res2.foo
res3: type = @6d86b085
scala> res3.foo.res2.foo.foo.res2
res4: type = @6d86b085
The interesting thing is the type of these objects, its "type", and the class of the objects has an empty name. This does not usually happen, maybe it is, what the compiler API generates, if you just give it a line of code that is not wrapped in any context, something, you normally cannot do in Scala.
If you really want to know it exactly, you probably have to look into the source of Scala. But to use REPL it should be enough to know, that your code is wrapped in a fresh anonymous object each time.