summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2013-01-29 13:46:56 +0100
committerLukas Rytz <lukas.rytz@epfl.ch>2013-02-03 21:08:34 +0100
commitb74c33eb860622e3630949ee0eeac9c15e8df166 (patch)
treec5f80cbe5d5a552bd1bb8efeb6f3b8b1499b0e2e /test/files
parenta06d31f6a2df021acc18b10ad9cad0f80d7498f2 (diff)
downloadscala-b74c33eb860622e3630949ee0eeac9c15e8df166.tar.gz
scala-b74c33eb860622e3630949ee0eeac9c15e8df166.tar.bz2
scala-b74c33eb860622e3630949ee0eeac9c15e8df166.zip
SI-1803, plus documentation and cleanups in Namers, mainly in typeSig
- when typing (and naming) a ValDef, tpt and rhs are now type checked in the same context (the inner / ValDef context). this does not change any behavior, but is more uniform (same as for DefDef). martin told me (offline) that this change is desirable if it doesn't break anything. (it doesn't). - typeSig is now more uniform with a separate method for each case (methodSig, valDefSig, etc). methodSig was cleaned up (no more variables) and documented. the type returned by methodSig no longer contains / refers to type skolems, but to the actual type parameters (so we don't need to replace the skolems lateron). - documentation on constructor contexts, type skolems - more tests for SI-5543
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t5543.check10
-rw-r--r--test/files/neg/t5543.scala19
-rw-r--r--test/files/neg/t6829.check6
-rw-r--r--test/files/pos/t1014.scala4
-rw-r--r--test/files/pos/t1803.flags1
-rw-r--r--test/files/pos/t1803.scala2
-rw-r--r--test/files/run/t5543.check6
-rw-r--r--test/files/run/t5543.scala19
8 files changed, 63 insertions, 4 deletions
diff --git a/test/files/neg/t5543.check b/test/files/neg/t5543.check
new file mode 100644
index 0000000000..b61de0f78b
--- /dev/null
+++ b/test/files/neg/t5543.check
@@ -0,0 +1,10 @@
+t5543.scala:3: error: not found: type T
+ def this(x: T) { this() }
+ ^
+t5543.scala:11: error: not found: value x
+ def this(a: Int, b: Int = x) {
+ ^
+t5543.scala:18: error: not found: value x
+ def this(a: Int = x) { this() }
+ ^
+three errors found
diff --git a/test/files/neg/t5543.scala b/test/files/neg/t5543.scala
new file mode 100644
index 0000000000..4e03e6e114
--- /dev/null
+++ b/test/files/neg/t5543.scala
@@ -0,0 +1,19 @@
+class C1 {
+ type T
+ def this(x: T) { this() }
+}
+
+class C1a[T] {
+ def this(x: T) { this() } // works, no error here
+}
+
+class C2(x: Int) {
+ def this(a: Int, b: Int = x) {
+ this(b)
+ }
+}
+
+class C3 {
+ val x = 0
+ def this(a: Int = x) { this() }
+}
diff --git a/test/files/neg/t6829.check b/test/files/neg/t6829.check
index 8ee6d182eb..7c3c66e0f2 100644
--- a/test/files/neg/t6829.check
+++ b/test/files/neg/t6829.check
@@ -1,6 +1,6 @@
t6829.scala:35: error: type mismatch;
found : AgentSimulation.this.state.type (with underlying type G#State)
- required: _10.State
+ required: _9.State
lazy val actions: Map[G#Agent,G#Action] = agents.map(a => a -> a.chooseAction(state)).toMap
^
t6829.scala:45: error: trait AgentSimulation takes type parameters
@@ -17,12 +17,12 @@ t6829.scala:49: error: not found: value nextState
^
t6829.scala:50: error: type mismatch;
found : s.type (with underlying type Any)
- required: _54.State where val _54: G
+ required: _53.State where val _53: G
val r = rewards(agent).r(s,a,s2)
^
t6829.scala:51: error: type mismatch;
found : s.type (with underlying type Any)
- required: _51.State
+ required: _50.State
agent.learn(s,a,s2,r): G#Agent
^
t6829.scala:53: error: not found: value nextState
diff --git a/test/files/pos/t1014.scala b/test/files/pos/t1014.scala
index 1ac87b225b..3fc10d10dc 100644
--- a/test/files/pos/t1014.scala
+++ b/test/files/pos/t1014.scala
@@ -1,6 +1,8 @@
import scala.xml.{NodeSeq, Elem}
-class EO extends App with Moo{
+class EO extends App with Moo {
+ // return type is Flog, inherited from overridden method.
+ // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`.
def cat = <cat>dog</cat>
implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in)
diff --git a/test/files/pos/t1803.flags b/test/files/pos/t1803.flags
new file mode 100644
index 0000000000..d1a8244169
--- /dev/null
+++ b/test/files/pos/t1803.flags
@@ -0,0 +1 @@
+-Yinfer-argument-types \ No newline at end of file
diff --git a/test/files/pos/t1803.scala b/test/files/pos/t1803.scala
new file mode 100644
index 0000000000..42f4e784a3
--- /dev/null
+++ b/test/files/pos/t1803.scala
@@ -0,0 +1,2 @@
+class A { def foo[A](a: A) = a }
+class B extends A { override def foo[A](b) = b }
diff --git a/test/files/run/t5543.check b/test/files/run/t5543.check
index 517038f4c7..2ef2d51ff4 100644
--- a/test/files/run/t5543.check
+++ b/test/files/run/t5543.check
@@ -1,3 +1,9 @@
Test, 7, 119
m, 3, 19
Test, 5, 85
+T
+C
+T
+T
+D
+T
diff --git a/test/files/run/t5543.scala b/test/files/run/t5543.scala
index 651bc7f2b2..3684bf9690 100644
--- a/test/files/run/t5543.scala
+++ b/test/files/run/t5543.scala
@@ -22,5 +22,24 @@ object Test extends Function0[Int] {
println(sut.toString)
println(sut.m())
println(A.init()())
+
+ println((new T.C()).x)
+ println((new T.D(0,0)).x)
+ }
+}
+
+object T {
+ override def toString = "T"
+
+ // `this` refers to T
+ class C(val x: Any = {println(this); this}) { // prints T
+ println(this) // prints C
+ override def toString() = "C"
+ }
+
+ class D(val x: Any) {
+ override def toString() = "D"
+ // `this` refers again to T
+ def this(a: Int, b: Int, c: Any = {println(this); this}) { this(c); println(this) } // prints T, then prints D
}
}