blob: f804fa75f48e5db20e32c9253706fd1b0c570eb9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
Type in expressions to have them evaluated.
Type :help for more information.
scala> class A
defined class A
scala> object A // warn
defined object A
warning: previously defined class A is not a companion to object A.
Companions must be defined together; you may wish to use :paste mode for this.
scala> trait B
defined trait B
scala> object B // warn
defined object B
warning: previously defined trait B is not a companion to object B.
Companions must be defined together; you may wish to use :paste mode for this.
scala> object C
defined object C
scala> object Bippy
defined object Bippy
scala> class C // warn
defined class C
warning: previously defined object C is not a companion to class C.
Companions must be defined together; you may wish to use :paste mode for this.
scala> class D
defined class D
scala> def D = 0 // no warn
D: Int
scala> val D = 0 // no warn
D: Int = 0
scala> object E
defined object E
scala> var E = 0 // no warn
E: Int = 0
scala> object F
defined object F
scala> type F = Int // no warn
defined type alias F
scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **
scala> object lookup {
import intp._
def apply(name: String): Symbol = types(name) orElse terms(name)
def types(name: String): Symbol = replScope lookup (name: TypeName) orElse getClassIfDefined(name)
def terms(name: String): Symbol = replScope lookup (name: TermName) orElse getModuleIfDefined(name)
def types[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol
def terms[T: global.TypeTag] : Symbol = typeOf[T].termSymbol
def apply[T: global.TypeTag] : Symbol = typeOf[T].typeSymbol
}
defined object lookup
scala> lookup("F") // this now works as a result of changing .typeSymbol to .typeSymbolDirect in IMain#Request#definedSymbols
res0: $r.intp.global.Symbol = type F
scala>
|