aboutsummaryrefslogtreecommitdiff
path: root/tests/repl/errmsgs.check
blob: a1b3bd6ae415836d4cd3917505793891779e4941 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
scala> class Inv[T](x: T)
defined class Inv
scala> val x: List[String] = List(1)
-- [E007] Type Mismatch Error: <console>:4:27 ----------------------------------
4 |val x: List[String] = List(1)
  |                           ^
  |                           found:    Int(1)
  |                           required: String
  |                           
scala> val y: List[List[String]] = List(List(1))
-- [E007] Type Mismatch Error: <console>:4:38 ----------------------------------
4 |val y: List[List[String]] = List(List(1))
  |                                      ^
  |                                      found:    Int(1)
  |                                      required: String
  |                                      
scala> val z: (List[String], List[Int]) = (List(1), List("a"))
-- [E007] Type Mismatch Error: <console>:4:41 ----------------------------------
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
  |                                         ^
  |                                         found:    Int(1)
  |                                         required: String
  |                                         
-- [E007] Type Mismatch Error: <console>:4:50 ----------------------------------
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
  |                                                  ^^^
  |                                                  found:    String("a")
  |                                                  required: Int
  |                                                  
scala> val a: Inv[String] = new Inv(new Inv(1))
-- [E007] Type Mismatch Error: <console>:5:33 ----------------------------------
5 |val a: Inv[String] = new Inv(new Inv(1))
  |                                 ^^^^^
  |                  found:    Inv[T]
  |                  required: String
  |                  
  |                  where:    T is a type variable with constraint >: Int(1)
scala> val b: Inv[String] = new Inv(1)
-- [E007] Type Mismatch Error: <console>:5:29 ----------------------------------
5 |val b: Inv[String] = new Inv(1)
  |                             ^
  |                             found:    Int(1)
  |                             required: String
  |                             
scala> abstract class C {
           type T
           val x: T
           val s: Unit = {
             type T = String
             var y: T = x
             locally {
               def f() = {
                 type T = Int
                 val z: T = y
               }
               f()
             }
           }
         }
-- [E007] Type Mismatch Error: <console>:9:17 ----------------------------------
9 |      var y: T = x
  |                 ^
  |found:    C.this.T(C.this.x)
  |required: T'
  |
  |where:    T  is a type in class C
  |          T' is a type in the initalizer of value s which is an alias of String
-- [E007] Type Mismatch Error: <console>:13:21 ---------------------------------
13 |          val z: T = y
   |                     ^
   |found:    T(y)
   |required: T'
   |
   |where:    T  is a type in the initalizer of value s which is an alias of String
   |          T' is a type in method f which is an alias of Int
scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
-- [E008] Member Not Found Error: <console>:4:59 -------------------------------
4 |class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
  |                                                       ^^^^^^^^
  |        value `barr` is not a member of Foo(foo) - did you mean `foo.bar`?
scala> val x: List[Int] = "foo" :: List(1)
-- [E007] Type Mismatch Error: <console>:4:19 ----------------------------------
4 |val x: List[Int] = "foo" :: List(1)
  |                   ^^^^^
  |                   found:    String($1$)
  |                   required: Int
  |                   
scala> { def f: Int = g; val x: Int = 1; def g: Int = 5; }
-- [E038] Reference Error: <console>:5:15 --------------------------------------
5 |{ def f: Int = g; val x: Int = 1; def g: Int = 5; }
  |               ^
  |           `g` is a forward reference extending over the definition of `x`

longer explanation available when compiling with `-explain`
scala> :quit