diff options
Diffstat (limited to 'test/files')
48 files changed, 593 insertions, 59 deletions
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 72d8d39fd0..6b712b93c7 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -278,13 +278,13 @@ scala> // both of the following should abort immediately: scala> def x => y => z <console>:1: error: '=' expected but '=>' found. -def x => y => z - ^ + def x => y => z + ^ scala> [1,2,3] <console>:1: error: illegal start of definition -[1,2,3] -^ + [1,2,3] + ^ scala> diff --git a/test/files/neg/badtok-1.check b/test/files/neg/badtok-1.check index b05bc60161..5d5a8e1f35 100644 --- a/test/files/neg/badtok-1.check +++ b/test/files/neg/badtok-1.check @@ -4,4 +4,10 @@ badtok-1.scala:2: error: unclosed character literal badtok-1.scala:2: error: unclosed character literal '42' ^ -two errors found +badtok-1.scala:6: error: empty character literal (use '\'' for single quote) +''' +^ +badtok-1.scala:9: error: unclosed character literal (or use " for string literal "abc") +'abc' + ^ +four errors found diff --git a/test/files/neg/badtok-1.scala b/test/files/neg/badtok-1.scala index 706e794946..cc7dc6cecc 100644 --- a/test/files/neg/badtok-1.scala +++ b/test/files/neg/badtok-1.scala @@ -1,2 +1,9 @@ // bug 989 '42' + + +// SI-10133 +''' + +// SI-10120 +'abc' diff --git a/test/files/neg/literals.check b/test/files/neg/literals.check index 148a9346c5..79b6d47782 100644 --- a/test/files/neg/literals.check +++ b/test/files/neg/literals.check @@ -19,6 +19,18 @@ literals.scala:23: error: missing integer number literals.scala:27: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.) def tooManyZeros: Int = 00 // line 26: no leading zero ^ +literals.scala:40: error: floating point number too small + def tooTiny: Float = { 0.7e-45f } // floating point number too small + ^ +literals.scala:42: error: double precision floating point number too small + def twoTiny: Double = { 2.0e-324 } // double precision floating point number too small + ^ +literals.scala:44: error: floating point number too large + def tooHuge: Float = { 3.4028236E38f } // floating point number too large + ^ +literals.scala:46: error: double precision floating point number too large + def twoHuge: Double = { 1.7976931348623159e308 } // double precision floating point number too large + ^ literals.scala:14: error: identifier expected but '}' found. def orphanDot: Int = { 9. } // line 12: ident expected ^ @@ -37,4 +49,4 @@ literals.scala:29: error: ';' expected but 'def' found. literals.scala:33: error: identifier expected but 'def' found. def zeroOfNineDot: Int = 09. // line 32: malformed integer, ident expected ^ -13 errors found +17 errors found diff --git a/test/files/neg/literals.scala b/test/files/neg/literals.scala index 3df7f0b408..22d5d9acd1 100644 --- a/test/files/neg/literals.scala +++ b/test/files/neg/literals.scala @@ -1,6 +1,6 @@ /* This took me literally all day. -*/ + */ trait RejectedLiterals { def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero @@ -34,3 +34,14 @@ trait Braceless { def noHexFloat: Double = 0x1.2 // line 34: ';' expected but double literal found. } + +trait MoreSadness { + + def tooTiny: Float = { 0.7e-45f } // floating point number too small + + def twoTiny: Double = { 2.0e-324 } // double precision floating point number too small + + def tooHuge: Float = { 3.4028236E38f } // floating point number too large + + def twoHuge: Double = { 1.7976931348623159e308 } // double precision floating point number too large +} diff --git a/test/files/neg/t10066.check b/test/files/neg/t10066.check new file mode 100644 index 0000000000..3555205d83 --- /dev/null +++ b/test/files/neg/t10066.check @@ -0,0 +1,7 @@ +t10066.scala:33: error: could not find implicit value for parameter extractor: dynamicrash.Extractor[String] + println(storage.foo[String]) + ^ +t10066.scala:37: error: could not find implicit value for parameter extractor: dynamicrash.Extractor[A] + println(storage.foo) + ^ +two errors found diff --git a/test/files/neg/t10066.scala b/test/files/neg/t10066.scala new file mode 100644 index 0000000000..ef52f333dd --- /dev/null +++ b/test/files/neg/t10066.scala @@ -0,0 +1,38 @@ +package dynamicrash + +import scala.language.dynamics + +class Config + +trait Extractor[A] { + def extract(config: Config, name: String): A +} + +object Extractor { + // note missing "implicit" + val stringExtractor = new Extractor[String] { + override def extract(config: Config, name: String): String = ??? + } +} + +class Workspace extends Dynamic { + val config: Config = new Config + + def selectDynamic[A](name: String)(implicit extractor: Extractor[A]): A = + extractor.extract(config, name) +} + +object Main { + val storage = new Workspace + + // this line works fine + // val a = storage.foo + + // this line crashes the compiler ("head of empty list") + // in ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBoundsErrorMessage + println(storage.foo[String]) + + // this line crashes the compiler in different way ("unknown type") + // in the backend, warning: an unexpected type representation reached the compiler backend while compiling Test.scala: <error> + println(storage.foo) +} diff --git a/test/files/neg/t5856.check b/test/files/neg/t5856.check index 08a61bdc07..306cc04177 100644 --- a/test/files/neg/t5856.check +++ b/test/files/neg/t5856.check @@ -1,4 +1,4 @@ -t5856.scala:10: error: invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected +t5856.scala:10: error: invalid string interpolation $", expected: $$, $identifier or ${expression} val s9 = s"$" ^ t5856.scala:10: error: unclosed string literal diff --git a/test/files/neg/t9636.check b/test/files/neg/t9636.check new file mode 100644 index 0000000000..f36d1d32b2 --- /dev/null +++ b/test/files/neg/t9636.check @@ -0,0 +1,6 @@ +t9636.scala:11: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. + if (signature.sameElements(Array(0x1F, 0x8B))) { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t9636.flags b/test/files/neg/t9636.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/neg/t9636.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/neg/t9636.scala b/test/files/neg/t9636.scala new file mode 100644 index 0000000000..7ad5fb3e9e --- /dev/null +++ b/test/files/neg/t9636.scala @@ -0,0 +1,17 @@ + +import java.io._ +import java.util.zip._ + +class C { + def isWrapper(is: FileInputStream): InputStream = { + val pb = new PushbackInputStream(is, 2) + val signature = new Array[Byte](2) + pb.read(signature) + pb.unread(signature) + if (signature.sameElements(Array(0x1F, 0x8B))) { + new GZIPInputStream(new BufferedInputStream(pb)) + } else { + pb + } + } +} diff --git a/test/files/neg/t9675.check b/test/files/neg/t9675.check new file mode 100644 index 0000000000..255477499c --- /dev/null +++ b/test/files/neg/t9675.check @@ -0,0 +1,27 @@ +t9675.scala:4: warning: comparing values of types Test.A and String using `!=' will always yield true + val func1 = (x: A) => { x != "x" } + ^ +t9675.scala:6: warning: comparing values of types Test.A and String using `!=' will always yield true + val func2 = (x: A) => { x != "x" }: Boolean + ^ +t9675.scala:8: warning: comparing values of types Test.A and String using `!=' will always yield true + val func3: Function1[A, Boolean] = (x) => { x != "x" } + ^ +t9675.scala:11: warning: comparing values of types Test.A and String using `!=' will always yield true + def apply(x: A): Boolean = { x != "x" } + ^ +t9675.scala:14: warning: comparing values of types Test.A and String using `!=' will always yield true + def method(x: A): Boolean = { x != "x" } + ^ +t9675.scala:18: warning: comparing values of types Test.A and String using `!=' will always yield true + A("x") != "x" + ^ +t9675.scala:20: warning: comparing values of types Test.A and String using `!=' will always yield true + val func5: Function1[A, Boolean] = (x) => { x != "x" } + ^ +t9675.scala:22: warning: comparing values of types Test.A and String using `!=' will always yield true + List(A("x")).foreach((item: A) => item != "x") + ^ +error: No warnings can be incurred under -Xfatal-warnings. +8 warnings found +one error found diff --git a/test/files/neg/t9675.flags b/test/files/neg/t9675.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t9675.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t9675.scala b/test/files/neg/t9675.scala new file mode 100644 index 0000000000..f76b74b6ac --- /dev/null +++ b/test/files/neg/t9675.scala @@ -0,0 +1,24 @@ +object Test { + case class A(x: String) + + val func1 = (x: A) => { x != "x" } + + val func2 = (x: A) => { x != "x" }: Boolean + + val func3: Function1[A, Boolean] = (x) => { x != "x" } + + val func4 = new Function1[A, Boolean] { + def apply(x: A): Boolean = { x != "x" } + } + + def method(x: A): Boolean = { x != "x" } + case class PersonInfo(rankPayEtc: Unit) + + def main(args: Array[String]) { + A("x") != "x" + + val func5: Function1[A, Boolean] = (x) => { x != "x" } + + List(A("x")).foreach((item: A) => item != "x") + } +} diff --git a/test/files/neg/warn-inferred-any.check b/test/files/neg/warn-inferred-any.check index 8ad81d1529..2b321a83c9 100644 --- a/test/files/neg/warn-inferred-any.check +++ b/test/files/neg/warn-inferred-any.check @@ -9,7 +9,7 @@ warn-inferred-any.scala:17: warning: a type was inferred to be `AnyVal`; this ma ^ warn-inferred-any.scala:25: warning: a type was inferred to be `Any`; this may indicate a programming error. def za = f(1, "one") - ^ + ^ error: No warnings can be incurred under -Xfatal-warnings. four warnings found one error found diff --git a/test/files/pos/sam_erasure_boundedwild.scala b/test/files/pos/sam_erasure_boundedwild.scala new file mode 100644 index 0000000000..1ec27e0ea4 --- /dev/null +++ b/test/files/pos/sam_erasure_boundedwild.scala @@ -0,0 +1,11 @@ +class Test { + trait Q[T] { + def toArray[T](x: Array[T]): Array[T] + def toArray(): Array[T] + } + + def crashTyper: Array[_] = { + val x : Q[_] = ??? + x.toArray // crashes while doing overload resolution + } +}
\ No newline at end of file diff --git a/test/files/pos/t10066.scala b/test/files/pos/t10066.scala new file mode 100644 index 0000000000..bef85cb08c --- /dev/null +++ b/test/files/pos/t10066.scala @@ -0,0 +1,38 @@ +package dynamicrash + +import scala.language.dynamics + +class Config + +trait Extractor[A] { + def extract(config: Config, name: String): A +} + +object Extractor { + // this has "implicit", unlike the corresponding neg test + implicit val stringExtractor = new Extractor[String] { + override def extract(config: Config, name: String): String = ??? + } +} + +class Workspace extends Dynamic { + val config: Config = new Config + + def selectDynamic[A](name: String)(implicit extractor: Extractor[A]): A = + extractor.extract(config, name) +} + +object Main { + val storage = new Workspace + + // this line works fine + // val a = storage.foo + + // this line crashes the compiler ("head of empty list") + // in ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBoundsErrorMessage + println(storage.foo[String]) + + // this line crashes the compiler in different way ("unknown type") + // in the backend, warning: an unexpected type representation reached the compiler backend while compiling Test.scala: <error> + println(storage.foo) +} diff --git a/test/files/pos/t9331.scala b/test/files/pos/t9331.scala new file mode 100644 index 0000000000..00a667886f --- /dev/null +++ b/test/files/pos/t9331.scala @@ -0,0 +1,6 @@ +import scala.language.higherKinds + +trait Proxy[+T] +case class Stuff[+P[PP] <: Proxy[PP]]() { + // canEqual was incorrectly synthetized and started reporting a kind error. +} diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index b0d852865d..8800df0823 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -2,28 +2,28 @@ abstract trait Bippy[A <: AnyRef, B] extends AnyRef extest.Bippy[_ <: AnyRef, _] abstract trait BippyBud[A <: AnyRef, B, C <: List[A]] extends AnyRef - extest.BippyBud[A,B,C] forSome { A <: AnyRef; B; C <: List[A] } + extest.BippyBud[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1; type ?2 <: List[?0] } abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B]] extends AnyRef - extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] } + extest.BippyLike[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1 <: List[?0]; type ?2 <: extest.BippyLike[?0,?1,?2] with extest.Bippy[?0,?1] } abstract trait Contra[-A >: AnyRef, -B] extends AnyRef - extest.Contra[AnyRef, _] + extest.Contra[_ >: AnyRef, _] abstract trait ContraLike[-A >: AnyRef, -B >: List[A]] extends AnyRef - extest.ContraLike[A,B] forSome { -A >: AnyRef; -B >: List[A] } + extest.ContraLike[?0,?1] forSome { type ?0 >: AnyRef; type ?1 >: List[?0] } abstract trait Cov01[+A <: AnyRef, +B] extends AnyRef - extest.Cov01[AnyRef,Any] + extest.Cov01[_ <: AnyRef, _] abstract trait Cov02[+A <: AnyRef, B] extends AnyRef - extest.Cov02[AnyRef, _] + extest.Cov02[_ <: AnyRef, _] abstract trait Cov03[+A <: AnyRef, -B] extends AnyRef - extest.Cov03[AnyRef, _] + extest.Cov03[_ <: AnyRef, _] abstract trait Cov04[A <: AnyRef, +B] extends AnyRef - extest.Cov04[_ <: AnyRef, Any] + extest.Cov04[_ <: AnyRef, _] abstract trait Cov05[A <: AnyRef, B] extends AnyRef extest.Cov05[_ <: AnyRef, _] @@ -32,7 +32,7 @@ abstract trait Cov06[A <: AnyRef, -B] extends AnyRef extest.Cov06[_ <: AnyRef, _] abstract trait Cov07[-A <: AnyRef, +B] extends AnyRef - extest.Cov07[_ <: AnyRef, Any] + extest.Cov07[_ <: AnyRef, _] abstract trait Cov08[-A <: AnyRef, B] extends AnyRef extest.Cov08[_ <: AnyRef, _] @@ -41,16 +41,16 @@ abstract trait Cov09[-A <: AnyRef, -B] extends AnyRef extest.Cov09[_ <: AnyRef, _] abstract trait Cov11[+A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov11[AnyRef,List[_]] + extest.Cov11[_ <: AnyRef, _ <: List[_]] abstract trait Cov12[+A <: AnyRef, B <: List[_]] extends AnyRef - extest.Cov12[AnyRef, _ <: List[_]] + extest.Cov12[_ <: AnyRef, _ <: List[_]] abstract trait Cov13[+A <: AnyRef, -B <: List[_]] extends AnyRef - extest.Cov13[AnyRef, _ <: List[_]] + extest.Cov13[_ <: AnyRef, _ <: List[_]] abstract trait Cov14[A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov14[_ <: AnyRef, List[_]] + extest.Cov14[_ <: AnyRef, _ <: List[_]] abstract trait Cov15[A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov15[_ <: AnyRef, _ <: List[_]] @@ -59,7 +59,7 @@ abstract trait Cov16[A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov16[_ <: AnyRef, _ <: List[_]] abstract trait Cov17[-A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov17[_ <: AnyRef, List[_]] + extest.Cov17[_ <: AnyRef, _ <: List[_]] abstract trait Cov18[-A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov18[_ <: AnyRef, _ <: List[_]] @@ -68,16 +68,16 @@ abstract trait Cov19[-A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov19[_ <: AnyRef, _ <: List[_]] abstract trait Cov21[+A, +B] extends AnyRef - extest.Cov21[Any,Any] + extest.Cov21[_, _] abstract trait Cov22[+A, B] extends AnyRef - extest.Cov22[Any, _] + extest.Cov22[_, _] abstract trait Cov23[+A, -B] extends AnyRef - extest.Cov23[Any, _] + extest.Cov23[_, _] abstract trait Cov24[A, +B] extends AnyRef - extest.Cov24[_, Any] + extest.Cov24[_, _] abstract trait Cov25[A, B] extends AnyRef extest.Cov25[_, _] @@ -86,7 +86,7 @@ abstract trait Cov26[A, -B] extends AnyRef extest.Cov26[_, _] abstract trait Cov27[-A, +B] extends AnyRef - extest.Cov27[_, Any] + extest.Cov27[_, _] abstract trait Cov28[-A, B] extends AnyRef extest.Cov28[_, _] @@ -95,43 +95,43 @@ abstract trait Cov29[-A, -B] extends AnyRef extest.Cov29[_, _] abstract trait Cov31[+A, +B, C <: (A, B)] extends AnyRef - extest.Cov31[A,B,C] forSome { +A; +B; C <: (A, B) } + extest.Cov31[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov32[+A, B, C <: (A, B)] extends AnyRef - extest.Cov32[A,B,C] forSome { +A; B; C <: (A, B) } + extest.Cov32[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov33[+A, -B, C <: Tuple2[A, _]] extends AnyRef - extest.Cov33[A,B,C] forSome { +A; -B; C <: Tuple2[A, _] } + extest.Cov33[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[?0, _] } abstract trait Cov34[A, +B, C <: (A, B)] extends AnyRef - extest.Cov34[A,B,C] forSome { A; +B; C <: (A, B) } + extest.Cov34[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov35[A, B, C <: (A, B)] extends AnyRef - extest.Cov35[A,B,C] forSome { A; B; C <: (A, B) } + extest.Cov35[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov36[A, -B, C <: Tuple2[A, _]] extends AnyRef - extest.Cov36[A,B,C] forSome { A; -B; C <: Tuple2[A, _] } + extest.Cov36[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[?0, _] } abstract trait Cov37[-A, +B, C <: Tuple2[_, B]] extends AnyRef - extest.Cov37[A,B,C] forSome { -A; +B; C <: Tuple2[_, B] } + extest.Cov37[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[_, ?1] } abstract trait Cov38[-A, B, C <: Tuple2[_, B]] extends AnyRef - extest.Cov38[A,B,C] forSome { -A; B; C <: Tuple2[_, B] } + extest.Cov38[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[_, ?1] } abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends AnyRef extest.Cov39[_, _, _ <: Tuple2[_, _]] abstract trait Cov41[+A >: Null, +B] extends AnyRef - extest.Cov41[Any,Any] + extest.Cov41[_ >: Null, _] abstract trait Cov42[+A >: Null, B] extends AnyRef - extest.Cov42[Any, _] + extest.Cov42[_ >: Null, _] abstract trait Cov43[+A >: Null, -B] extends AnyRef - extest.Cov43[Any, _] + extest.Cov43[_ >: Null, _] abstract trait Cov44[A >: Null, +B] extends AnyRef - extest.Cov44[_ >: Null, Any] + extest.Cov44[_ >: Null, _] abstract trait Cov45[A >: Null, B] extends AnyRef extest.Cov45[_ >: Null, _] @@ -140,7 +140,7 @@ abstract trait Cov46[A >: Null, -B] extends AnyRef extest.Cov46[_ >: Null, _] abstract trait Cov47[-A >: Null, +B] extends AnyRef - extest.Cov47[_ >: Null, Any] + extest.Cov47[_ >: Null, _] abstract trait Cov48[-A >: Null, B] extends AnyRef extest.Cov48[_ >: Null, _] @@ -149,8 +149,8 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef extest.Cov49[_ >: Null, _] abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef - extest.Covariant[AnyRef,Any] + extest.Covariant[_ <: AnyRef, _] abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef - extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] } + extest.CovariantLike[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1 <: List[?0]; type ?2 <: extest.CovariantLike[?0,?1,?2] with extest.Covariant[?0,?1] } diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index e516eddf95..e35b7231c2 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -79,7 +79,7 @@ package extest { exitingTyper { clazz.info println(clazz.defString) - println(" " + classExistentialType(clazz) + "\n") + println(" " + classExistentialType(clazz.owner.typeOfThis, clazz) + "\n") } } } diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 13fda05876..a7962e5cd9 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -6,7 +6,7 @@ object Test { - /* I add a couple of Unicode identifier tests here temporarily */ + /* I add a couple of Unicode identifier tests here "temporarily" */ def \u03b1\u03c1\u03b5\u03c4\u03b7 = "alpha rho epsilon tau eta" @@ -80,10 +80,17 @@ object Test { check_success("1e1f == 10.0f", 1e1f, 10.0f) check_success(".3f == 0.3f", .3f, 0.3f) check_success("0f == 0.0f", 0f, 0.0f) + check_success("0f == -0.000000000000000000e+00f", 0f, -0.000000000000000000e+00f) + check_success("0f == -0.000000000000000000e+00F", 0f, -0.000000000000000000e+00F) + check_success("0f == -0.0000000000000000e14f", 0f, -0.0000000000000000e14f) check_success("01.23f == 1.23f", 01.23f, 1.23f) check_success("3.14f == 3.14f", 3.14f, 3.14f) check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f) check_success("09f == 9.0f", 09f, 9.0f) + check_success("1.00000017881393421514957253748434595763683319091796875001f == 1.0000001f", + 1.00000017881393421514957253748434595763683319091796875001f, + 1.0000001f) + check_success("3.4028235E38f == Float.MaxValue", 3.4028235E38f, Float.MaxValue) check_success("1.asInstanceOf[Float] == 1.0", 1.asInstanceOf[Float], 1.0f) check_success("1l.asInstanceOf[Float] == 1.0", 1l.asInstanceOf[Float], 1.0f) @@ -92,11 +99,17 @@ object Test { check_success(".3 == 0.3", .3, 0.3) check_success("0.0 == 0.0", 0.0, 0.0) check_success("0d == 0.0", 0d, 0.0) + check_success("0d == 0.000000000000000000e+00d", 0d, 0.000000000000000000e+00d) + check_success("0d == -0.000000000000000000e+00d", 0d, -0.000000000000000000e+00d) + check_success("0d == -0.000000000000000000e+00D", 0d, -0.000000000000000000e+00D) + check_success("0.0 == 0.000000000000000000e+00", 0.0, 0.000000000000000000e+00) + check_success("0.0 == -0.000000000000000000e+00", 0.0, -0.000000000000000000e+00) check_success("01.23 == 1.23", 01.23, 1.23) check_success("01.23d == 1.23d", 01.23d, 1.23d) check_success("3.14 == 3.14", 3.14, 3.14) check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9) check_success("1e137 == 1.0e137", 1e137, 1.0e137) + check_success("1.7976931348623157e308d == Double.MaxValue", 1.7976931348623157e308d, Double.MaxValue) check_success("1.asInstanceOf[Double] == 1.0", 1.asInstanceOf[Double], 1.0) check_success("1l.asInstanceOf[Double] == 1.0", 1l.asInstanceOf[Double], 1.0) diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check index 985f646579..b2f4d5624e 100644 --- a/test/files/run/reify_newimpl_22.check +++ b/test/files/run/reify_newimpl_22.check @@ -15,7 +15,7 @@ scala> { } println(code.eval) } -<console>:19: free term: Ident(TermName("x")) defined by res0 in <console>:18:14 +<console>:19: free term: Ident(TermName("x")) defined by res0 in <console>:18:7 val code = reify { ^ 2 diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check index f60113c69f..abf314b26a 100644 --- a/test/files/run/reify_newimpl_23.check +++ b/test/files/run/reify_newimpl_23.check @@ -14,7 +14,7 @@ scala> def foo[T]{ } println(code.eval) } -<console>:17: free type: Ident(TypeName("T")) defined by foo in <console>:16:16 +<console>:17: free type: Ident(TypeName("T")) defined by foo in <console>:16:9 val code = reify { ^ foo: [T]=> Unit diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check index 9104d8df0b..d446caa91a 100644 --- a/test/files/run/reify_newimpl_25.check +++ b/test/files/run/reify_newimpl_25.check @@ -5,7 +5,7 @@ scala> { val tt = implicitly[TypeTag[x.type]] println(tt) } -<console>:15: free term: Ident(TermName("x")) defined by res0 in <console>:14:14 +<console>:15: free term: Ident(TermName("x")) defined by res0 in <console>:14:7 val tt = implicitly[TypeTag[x.type]] ^ TypeTag[x.type] diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index cbb21854ba..099231bf62 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -4,7 +4,7 @@ scala> def foo[T]{ val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } -<console>:13: free type: Ident(TypeName("T")) defined by foo in <console>:11:16 +<console>:13: free type: Ident(TypeName("T")) defined by foo in <console>:11:9 val tt = implicitly[WeakTypeTag[List[T]]] ^ foo: [T]=> Unit diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 1217e8d8c2..3fdd318df6 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -1,8 +1,8 @@ scala> :type List[1, 2, 3] <console>:1: error: identifier expected but integer literal found. -List[1, 2, 3] - ^ + List[1, 2, 3] + ^ scala> :type List(1, 2, 3) List[Int] @@ -38,8 +38,8 @@ scala> :type protected lazy val f = 5 Access to protected lazy value f not permitted because enclosing object $eval in package $line13 is not a subclass of object $iw where target is defined - lazy val $result = f - ^ + lazy val $result = f + ^ scala> :type def f = 5 => Int @@ -75,7 +75,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List( @@ -142,7 +142,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List( @@ -175,7 +175,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -198,7 +198,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) diff --git a/test/files/run/t10026.check b/test/files/run/t10026.check new file mode 100644 index 0000000000..15a62794a9 --- /dev/null +++ b/test/files/run/t10026.check @@ -0,0 +1 @@ +List(1, 2, 3) diff --git a/test/files/run/t10026.scala b/test/files/run/t10026.scala new file mode 100644 index 0000000000..a56840c8c2 --- /dev/null +++ b/test/files/run/t10026.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe +import scala.tools.reflect.ToolBox + +object Test { + def main(args: Array[String]): Unit = { + val classloader = getClass.getClassLoader + val toolbox = universe.runtimeMirror(classloader).mkToolBox() + println(toolbox.compile(toolbox.parse("Array(1, 2, 3).toList")).apply()) + } +} + diff --git a/test/files/run/t10072.scala b/test/files/run/t10072.scala new file mode 100644 index 0000000000..0f1dca1838 --- /dev/null +++ b/test/files/run/t10072.scala @@ -0,0 +1,18 @@ +trait T[A] { + def a: A + def foldLeft[B](zero: B, op: (B, A) => B): B = op(zero, a) + def sum[B >: A](zero: B): B +} + +class C[@specialized(Int) A](val a: A) extends T[A] { + override def sum[@specialized(Int) B >: A](zero: B): B = foldLeft(zero, (x: B, y: B) => x) +} + +object Test extends App { + def factory[T](a: T): C[T] = new C[T](a) + + assert(new C[Int](1).sum(2) == 2) + assert(new C[String]("ho").sum("hu") == "hu") + assert(factory[Int](1).sum(2) == 2) + assert(factory[String]("ho").sum("hu") == "hu") +} diff --git a/test/files/run/t1459.check b/test/files/run/t1459.check new file mode 100644 index 0000000000..93b4c5a810 --- /dev/null +++ b/test/files/run/t1459.check @@ -0,0 +1,3 @@ +JavaPrinter: one two three +InheritingPrinter extends JavaPrinter: one two three +ScalaPrinter: onetwothree diff --git a/test/files/run/t1459/InheritingPrinter.scala b/test/files/run/t1459/InheritingPrinter.scala new file mode 100644 index 0000000000..70301307f5 --- /dev/null +++ b/test/files/run/t1459/InheritingPrinter.scala @@ -0,0 +1,6 @@ +class InheritingPrinter extends JavaPrinter { + override def doit(s: String*) { + print("InheritingPrinter extends ") + super.doit(s: _*); + } +}
\ No newline at end of file diff --git a/test/files/run/t1459/JavaPrinter.java b/test/files/run/t1459/JavaPrinter.java new file mode 100644 index 0000000000..3912ea613a --- /dev/null +++ b/test/files/run/t1459/JavaPrinter.java @@ -0,0 +1,7 @@ +public class JavaPrinter implements VarArg { + public void doit(String... s) { + System.out.print("JavaPrinter: "); + for(String str : s) + System.out.print(str + " "); + } +} diff --git a/test/files/run/t1459/ScalaPrinter.scala b/test/files/run/t1459/ScalaPrinter.scala new file mode 100644 index 0000000000..46305804c2 --- /dev/null +++ b/test/files/run/t1459/ScalaPrinter.scala @@ -0,0 +1,6 @@ +class ScalaPrinter extends VarArg { + override def doit(s: String*) = { + print("ScalaPrinter: ") + s.foreach(print _) + } +}
\ No newline at end of file diff --git a/test/files/run/t1459/Test.java b/test/files/run/t1459/Test.java new file mode 100644 index 0000000000..3cf91e2e8b --- /dev/null +++ b/test/files/run/t1459/Test.java @@ -0,0 +1,15 @@ +public class Test { + public static void main(String[] args) { + VarArg jp = new JavaPrinter(); + VarArg ip = new InheritingPrinter(); + VarArg sp = new ScalaPrinter(); + doYourThing(jp); + doYourThing(ip); + doYourThing(sp); + } + + public static void doYourThing(VarArg va) { + va.doit("one", "two", "three"); + System.out.println(); + } +} diff --git a/test/files/run/t1459/VarArg.java b/test/files/run/t1459/VarArg.java new file mode 100644 index 0000000000..7039f99e7b --- /dev/null +++ b/test/files/run/t1459/VarArg.java @@ -0,0 +1,3 @@ +public interface VarArg { + void doit(String... s); +} diff --git a/test/files/run/t1459generic.check b/test/files/run/t1459generic.check new file mode 100644 index 0000000000..346fadbc0d --- /dev/null +++ b/test/files/run/t1459generic.check @@ -0,0 +1,4 @@ +Note: t1459generic/Test.java uses unchecked or unsafe operations. +Note: Recompile with -Xlint:unchecked for details. +ab +ab diff --git a/test/files/run/t1459generic/Impl.scala b/test/files/run/t1459generic/Impl.scala new file mode 100644 index 0000000000..9234e70456 --- /dev/null +++ b/test/files/run/t1459generic/Impl.scala @@ -0,0 +1,4 @@ +class Impl extends VarargGeneric[String] { + def genericOne(x: String, arg: String): String = x + arg + def genericVar(x: String, args: String*): String = x + args.head +} diff --git a/test/files/run/t1459generic/Test.java b/test/files/run/t1459generic/Test.java new file mode 100644 index 0000000000..a97158796b --- /dev/null +++ b/test/files/run/t1459generic/Test.java @@ -0,0 +1,10 @@ +public class Test { + public static void main(String[] args) throws Exception { + VarargGeneric vg = new Impl(); + System.out.println(vg.genericOne("a", "b")); + System.out.println(vg.genericVar("a", "b")); + // should not result in java.lang.AbstractMethodError: Impl.genericVar(Ljava/lang/Object;[Ljava/lang/String;)Ljava/lang/String; + // --> genericVar needs a varargs bridge (scala -> java varargs) and a standard generics bridge + // (for comparison, including genericOne, which needs only a generics bridge) + } +} diff --git a/test/files/run/t1459generic/VarargGeneric.java b/test/files/run/t1459generic/VarargGeneric.java new file mode 100644 index 0000000000..9b37a0fe3f --- /dev/null +++ b/test/files/run/t1459generic/VarargGeneric.java @@ -0,0 +1,7 @@ +public interface VarargGeneric<T> { + String genericOne(T x, String args); + // we cannot annotate this with @SafeVarargs, because + // it's in an interface. so that's why a warning from + // javac appears in the checkfile. + String genericVar(T x, String... args); +} diff --git a/test/files/run/t4700.check b/test/files/run/t4700.check new file mode 100644 index 0000000000..ae854b959d --- /dev/null +++ b/test/files/run/t4700.check @@ -0,0 +1,44 @@ + +scala> import scala.annotation.showAsInfix +import scala.annotation.showAsInfix + +scala> class &&[T,U] +defined class $amp$amp + +scala> def foo: Int && Boolean = ??? +foo: Int && Boolean + +scala> def foo: Int && Boolean && String = ??? +foo: Int && Boolean && String + +scala> def foo: Int && (Boolean && String) = ??? +foo: Int && (Boolean && String) + +scala> @showAsInfix type Mappy[T, U] = Map[T, U] +defined type alias Mappy + +scala> def foo: Int Mappy (Boolean && String) = ??? +foo: Int Mappy (Boolean && String) + +scala> @showAsInfix(false) class ||[T,U] +defined class $bar$bar + +scala> def foo: Int || Boolean = ??? +foo: ||[Int,Boolean] + +scala> class &:[L, R] +defined class $amp$colon + +scala> def foo: Int &: String = ??? +foo: Int &: String + +scala> def foo: Int &: Boolean &: String = ??? +foo: Int &: Boolean &: String + +scala> def foo: (Int && String) &: Boolean = ??? +foo: (Int && String) &: Boolean + +scala> def foo: Int && (Boolean &: String) = ??? +foo: Int && (Boolean &: String) + +scala> :quit diff --git a/test/files/run/t4700.scala b/test/files/run/t4700.scala new file mode 100644 index 0000000000..7c02676e89 --- /dev/null +++ b/test/files/run/t4700.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc.interpreter._ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import scala.annotation.showAsInfix + |class &&[T,U] + |def foo: Int && Boolean = ??? + |def foo: Int && Boolean && String = ??? + |def foo: Int && (Boolean && String) = ??? + |@showAsInfix type Mappy[T, U] = Map[T, U] + |def foo: Int Mappy (Boolean && String) = ??? + |@showAsInfix(false) class ||[T,U] + |def foo: Int || Boolean = ??? + |class &:[L, R] + |def foo: Int &: String = ??? + |def foo: Int &: Boolean &: String = ??? + |def foo: (Int && String) &: Boolean = ??? + |def foo: Int && (Boolean &: String) = ??? + |""".stripMargin +} + diff --git a/test/files/run/t8918-unary-ids.check b/test/files/run/t8918-unary-ids.check index 92f02371c7..b1f16ed56a 100644 --- a/test/files/run/t8918-unary-ids.check +++ b/test/files/run/t8918-unary-ids.check @@ -5,3 +5,17 @@ Expected 41 lines, got 39 -Type in expressions to have them evaluated. -Type :help for more information. +@@ -14,4 +12,4 @@ + <console>:1: error: illegal start of simple expression +-- if (true) 1 else 2 +- ^ ++ - if (true) 1 else 2 ++ ^ + +@@ -19,4 +17,4 @@ + <console>:1: error: ';' expected but integer literal found. +-- - 1 +- ^ ++ - - 1 ++ ^ + diff --git a/test/files/run/t9013/Test.java b/test/files/run/t9013/Test.java new file mode 100644 index 0000000000..14152b16ac --- /dev/null +++ b/test/files/run/t9013/Test.java @@ -0,0 +1,20 @@ +import java.util.Comparator; + +public class Test { + public static void main(String[] args) { + ClassImplementsClass c = new ClassImplementsClass(); + + c.x("a", "b", "c"); + c.y("a", "b", "c"); + c.z("a", "b", "c"); + + VarargAbstractClass i = new ClassImplementsClass(); + + i.x("a", "b", "c"); + i.y("a", "b", "c"); + // System.out.println(i.z("a", "b", "c")); // still incurs a LinkageError. + // Perhaps due to Uncurry: + // > for every repeated Java parameter `x: T...' --> x: Array[T], except: + // > if T is an unbounded abstract type, replace --> x: Array[Object] + } +} diff --git a/test/files/run/t9013/test.scala b/test/files/run/t9013/test.scala new file mode 100644 index 0000000000..073f8d086f --- /dev/null +++ b/test/files/run/t9013/test.scala @@ -0,0 +1,18 @@ +import scala.annotation.varargs + +abstract class VarargAbstractClass[T] { + @varargs + def x(els: String*): Int + + @varargs + def y(els: String*): Int + + @varargs + def z(els: T*): Int +} +class ClassImplementsClass extends VarargAbstractClass[String] { + + override def x(els: String*): Int = els.length + override def y(els: String*): Int = els.length + override def z(els: String*): Int = els.length +} diff --git a/test/files/run/t9114.scala b/test/files/run/t9114.scala new file mode 100644 index 0000000000..656a5c7d8d --- /dev/null +++ b/test/files/run/t9114.scala @@ -0,0 +1,31 @@ +import annotation.unchecked + +class Test { + trait Two[A, B] + type One[A] = Two[A,A] + class View extends One[Any] + + def checkAny(x: Some[One[Any]]) = x match { // okay + case Some(_: View) => true + case _ => false + } + def checkAbstract[A](x: Some[One[A]]) = x match { // okay + case Some(_: View) => true + case _ => false + } + + def checkExistential(x: Some[One[_]]) = x match { + case Some(_: View) => true // compiler crash + case _ => false + } +} + +object Test { + def main(args: Array[String]): Unit = { + val t1 = new Test + val t2 = new Test + assert(t1.checkAny(Some(new t1.View))) + assert(t1.checkAbstract(Some(new t1.View))) + assert(t1.checkExistential(Some(new t1.View))) + } +} diff --git a/test/files/run/t9170.scala b/test/files/run/t9170.scala index 87471fb129..cb7971235f 100644 --- a/test/files/run/t9170.scala +++ b/test/files/run/t9170.scala @@ -48,8 +48,8 @@ object Y { def f[A](a: => A): Int at line 12 and def f[A](a: => Either[Exception,A]): Int at line 13 have same type after erasure: (a: Function0)Int - def f[A](a: => Either[Exception, A]) = 2 - ^ + def f[A](a: => Either[Exception, A]) = 2 + ^ scala> :quit""" } diff --git a/test/files/run/t9880-9881.check b/test/files/run/t9880-9881.check new file mode 100644 index 0000000000..36513e249a --- /dev/null +++ b/test/files/run/t9880-9881.check @@ -0,0 +1,36 @@ + +scala> // import in various ways + +scala> import java.util.Date +import java.util.Date + +scala> import scala.util._ +import scala.util._ + +scala> import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{universe=>ru} + +scala> import ru.TypeTag +import ru.TypeTag + +scala> + +scala> // show the imports + +scala> :imports + 1) import java.lang._ (...) + 2) import scala._ (...) + 3) import scala.Predef._ (...) + 4) import java.util.Date (...) + 5) import scala.util._ (...) + 6) import scala.reflect.runtime.{universe=>ru} (...) + 7) import ru.TypeTag (...) + +scala> + +scala> // should be able to define this class with the imports above + +scala> class C[T](date: Date, rand: Random, typeTag: TypeTag[T]) +defined class C + +scala> :quit diff --git a/test/files/run/t9880-9881.scala b/test/files/run/t9880-9881.scala new file mode 100644 index 0000000000..0268c8c32c --- /dev/null +++ b/test/files/run/t9880-9881.scala @@ -0,0 +1,29 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + + override def transformSettings(s: Settings): Settings = { + s.Yreplclassbased.value = true + s + } + + lazy val normalizeRegex = """(import\s.*)\(.*\)""".r + + override def normalize(s: String): String = normalizeRegex.replaceFirstIn(s, "$1(...)") + + def code = + """ + |// import in various ways + |import java.util.Date + |import scala.util._ + |import scala.reflect.runtime.{universe => ru} + |import ru.TypeTag + | + |// show the imports + |:imports + | + |// should be able to define this class with the imports above + |class C[T](date: Date, rand: Random, typeTag: TypeTag[T]) + """.stripMargin +} |