diff options
Diffstat (limited to 'test/files/neg')
33 files changed, 186 insertions, 41 deletions
diff --git a/test/files/neg/macro-divergence-controlled.check b/test/files/neg/macro-divergence-controlled.check new file mode 100644 index 0000000000..4876f7cf96 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: could not find implicit value for parameter e: Complex[Foo] + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala new file mode 100644 index 0000000000..cdea3104a1 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo(val foo: Foo) + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + if (c.openImplicits.tail.exists(ic => ic._1 =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") + val recur = c.inferImplicitValue(trecur, silent = true) + if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") + } + c.literalNull + } + + implicit object ComplexString extends Complex[String] + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/macro-divergence-controlled/Test_2.scala b/test/files/neg/macro-divergence-controlled/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/neg/macro-qmarkqmarkqmark.check b/test/files/neg/macro-qmarkqmarkqmark.check new file mode 100644 index 0000000000..afd49e7d90 --- /dev/null +++ b/test/files/neg/macro-qmarkqmarkqmark.check @@ -0,0 +1,13 @@ +macro-qmarkqmarkqmark.scala:5: error: macro implementation is missing + foo1 + ^ +macro-qmarkqmarkqmark.scala:8: error: macros cannot be partially applied + foo2 + ^ +macro-qmarkqmarkqmark.scala:9: error: macro implementation is missing + foo2(1) + ^ +macro-qmarkqmarkqmark.scala:12: error: macro implementation is missing + foo3[Int] + ^ +four errors found diff --git a/test/files/neg/macro-qmarkqmarkqmark.scala b/test/files/neg/macro-qmarkqmarkqmark.scala new file mode 100644 index 0000000000..c8d8550fd8 --- /dev/null +++ b/test/files/neg/macro-qmarkqmarkqmark.scala @@ -0,0 +1,13 @@ +import language.experimental.macros + +object Macros { + def foo1 = macro ??? + foo1 + + def foo2(x: Int) = macro ??? + foo2 + foo2(1) + + def foo3[T] = macro ??? + foo3[Int] +}
\ No newline at end of file diff --git a/test/files/neg/stringinterpolation_macro-neg.check b/test/files/neg/stringinterpolation_macro-neg.check index 8986b899a3..457f497f2f 100644 --- a/test/files/neg/stringinterpolation_macro-neg.check +++ b/test/files/neg/stringinterpolation_macro-neg.check @@ -66,5 +66,5 @@ Note that implicit conversions are not applicable because they are ambiguous: ^ stringinterpolation_macro-neg.scala:30: error: illegal conversion character f"$s%i" - ^ + ^ 15 errors found diff --git a/test/files/neg/t5353.check b/test/files/neg/t5353.check deleted file mode 100644 index 75e2435600..0000000000 --- a/test/files/neg/t5353.check +++ /dev/null @@ -1,4 +0,0 @@ -t5353.scala:2: error: this type parameter must be specified - def f(x: Boolean) = if (x) Array("abc") else Array() - ^ -one error found diff --git a/test/files/neg/t5353.scala b/test/files/neg/t5353.scala deleted file mode 100644 index 1ee869aac1..0000000000 --- a/test/files/neg/t5353.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def f(x: Boolean) = if (x) Array("abc") else Array() -} diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check index 04220e79bb..322a2f5e25 100644 --- a/test/files/neg/t5510.check +++ b/test/files/neg/t5510.check @@ -1,15 +1,15 @@ t5510.scala:2: error: unclosed string literal val s1 = s"xxx - ^ + ^ t5510.scala:3: error: unclosed string literal val s2 = s"xxx $x ^ t5510.scala:4: error: unclosed string literal val s3 = s"xxx $$ - ^ + ^ t5510.scala:5: error: unclosed string literal val s4 = ""s" - ^ + ^ t5510.scala:6: error: unclosed multi-line string literal val s5 = ""s""" $s1 $s2 s" ^ diff --git a/test/files/neg/t5692a.check b/test/files/neg/t5692a.check deleted file mode 100644 index 7fbfb5dba7..0000000000 --- a/test/files/neg/t5692a.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:2: error: this type parameter must be specified - def x = Macros.foo - ^ -one error found diff --git a/test/files/neg/t5692a.flags b/test/files/neg/t5692a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/neg/t5692a.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692a/Macros_1.scala b/test/files/neg/t5692a/Macros_1.scala deleted file mode 100644 index 06b5a3de36..0000000000 --- a/test/files/neg/t5692a/Macros_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.reflect.macros.Context - -object Macros { - def impl[T](c: Context) = c.literalUnit - def foo[T] = macro impl[T] -}
\ No newline at end of file diff --git a/test/files/neg/t5692a/Test_2.scala b/test/files/neg/t5692a/Test_2.scala deleted file mode 100644 index 08d510cc6f..0000000000 --- a/test/files/neg/t5692a/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - def x = Macros.foo -}
\ No newline at end of file diff --git a/test/files/neg/t5692b.check b/test/files/neg/t5692b.check deleted file mode 100644 index 16796826b4..0000000000 --- a/test/files/neg/t5692b.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:2: error: these type parameters must be specified - def x = Macros.foo - ^ -one error found diff --git a/test/files/neg/t5692b.flags b/test/files/neg/t5692b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/neg/t5692b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/t5692b/Macros_1.scala b/test/files/neg/t5692b/Macros_1.scala deleted file mode 100644 index b28d19f903..0000000000 --- a/test/files/neg/t5692b/Macros_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.reflect.macros.Context - -object Macros { - def impl[T, U](c: Context) = c.literalUnit - def foo[T, U] = macro impl[T, U] -}
\ No newline at end of file diff --git a/test/files/neg/t5692b/Test_2.scala b/test/files/neg/t5692b/Test_2.scala deleted file mode 100644 index 08d510cc6f..0000000000 --- a/test/files/neg/t5692b/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - def x = Macros.foo -}
\ No newline at end of file diff --git a/test/files/neg/t5856.check b/test/files/neg/t5856.check index ac49d4b9ac..08a61bdc07 100644 --- a/test/files/neg/t5856.check +++ b/test/files/neg/t5856.check @@ -1,6 +1,6 @@ t5856.scala:10: error: invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected val s9 = s"$" - ^ + ^ t5856.scala:10: error: unclosed string literal val s9 = s"$" ^ diff --git a/test/files/neg/t696.check b/test/files/neg/t696a.check index ac26a864a5..490fc1a571 100644 --- a/test/files/neg/t696.check +++ b/test/files/neg/t696a.check @@ -1,4 +1,4 @@ -t696.scala:4: error: diverging implicit expansion for type TypeUtil0.Type[Any] +t696a.scala:4: error: diverging implicit expansion for type TypeUtil0.Type[Any] starting with method WithType in object TypeUtil0 as[Any](null); ^ diff --git a/test/files/neg/t696a.flags b/test/files/neg/t696a.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/neg/t696a.flags diff --git a/test/files/neg/t696.scala b/test/files/neg/t696a.scala index a06a32141a..a06a32141a 100644 --- a/test/files/neg/t696.scala +++ b/test/files/neg/t696a.scala diff --git a/test/files/neg/t696b.check b/test/files/neg/t696b.check new file mode 100644 index 0000000000..fcdb5440d8 --- /dev/null +++ b/test/files/neg/t696b.check @@ -0,0 +1,9 @@ +t696b.scala:5: error: diverging implicit expansion for type TypeUtil0.Type[Any] +starting with method WithType in object TypeUtil0 + as[Any](null) + ^ +t696b.scala:6: error: diverging implicit expansion for type TypeUtil0.Type[X] +starting with method WithType in object TypeUtil0 + def foo[X]() = as[X](null) + ^ +two errors found diff --git a/test/files/neg/t696b.flags b/test/files/neg/t696b.flags new file mode 100644 index 0000000000..d564f2b1f8 --- /dev/null +++ b/test/files/neg/t696b.flags @@ -0,0 +1 @@ +-Xdivergence211
\ No newline at end of file diff --git a/test/files/neg/t696b.scala b/test/files/neg/t696b.scala new file mode 100644 index 0000000000..ca76f7ef6c --- /dev/null +++ b/test/files/neg/t696b.scala @@ -0,0 +1,7 @@ +object TypeUtil0 { + trait Type[+T] + implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null + def as[T](x : Any)(implicit tpe : Type[T]) = null + as[Any](null) + def foo[X]() = as[X](null) +} diff --git a/test/files/neg/t7166.check b/test/files/neg/t7166.check new file mode 100644 index 0000000000..c87198cb27 --- /dev/null +++ b/test/files/neg/t7166.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: silent = true does work! + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/t7166/Impls_Macros_1.scala b/test/files/neg/t7166/Impls_Macros_1.scala new file mode 100644 index 0000000000..62a15657c3 --- /dev/null +++ b/test/files/neg/t7166/Impls_Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + def shout(msg: String) = { + val cannotShutMeUp = c.asInstanceOf[scala.reflect.macros.runtime.Context].universe.currentRun.currentUnit.error _ + cannotShutMeUp(c.enclosingPosition.asInstanceOf[scala.reflect.internal.util.Position], msg) + } + try { + val complexOfT = appliedType(typeOf[Complex[_]], List(weakTypeOf[T])) + val infiniteRecursion = c.inferImplicitValue(complexOfT, silent = true) + shout("silent = true does work!") + } catch { + case ex: Exception => shout(ex.toString) + } + c.literalNull + } + + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/t7166/Test_2.scala b/test/files/neg/t7166/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/t7166/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check new file mode 100644 index 0000000000..709ab6db3e --- /dev/null +++ b/test/files/neg/t7325.check @@ -0,0 +1,19 @@ +t7325.scala:2: error: percent signs not directly following splicees must be escaped + println(f"%") + ^ +t7325.scala:4: error: percent signs not directly following splicees must be escaped + println(f"%%%") + ^ +t7325.scala:6: error: percent signs not directly following splicees must be escaped + println(f"%%%%%") + ^ +t7325.scala:16: error: wrong conversion string + println(f"${0}%") + ^ +t7325.scala:19: error: percent signs not directly following splicees must be escaped + println(f"${0}%%%d") + ^ +t7325.scala:21: error: percent signs not directly following splicees must be escaped + println(f"${0}%%%%%d") + ^ +6 errors found diff --git a/test/files/neg/t7325.scala b/test/files/neg/t7325.scala new file mode 100644 index 0000000000..adfd8dd47a --- /dev/null +++ b/test/files/neg/t7325.scala @@ -0,0 +1,25 @@ +object Test extends App { + println(f"%") + println(f"%%") + println(f"%%%") + println(f"%%%%") + println(f"%%%%%") + println(f"%%%%%%") + + println(f"%%n") + println(f"%%%n") + println(f"%%%%n") + println(f"%%%%%n") + println(f"%%%%%%n") + println(f"%%%%%%%n") + + println(f"${0}%") + println(f"${0}%d") + println(f"${0}%%d") + println(f"${0}%%%d") + println(f"${0}%%%%d") + println(f"${0}%%%%%d") + + println(f"${0}%n") + println(f"${0}%d%n") +}
\ No newline at end of file diff --git a/test/files/neg/t7385.check b/test/files/neg/t7385.check new file mode 100644 index 0000000000..70d3c3fb61 --- /dev/null +++ b/test/files/neg/t7385.check @@ -0,0 +1,10 @@ +t7385.scala:2: error: '(' expected but identifier found. + do { println("bippy") } while i<10 + ^ +t7385.scala:6: error: '(' expected but identifier found. + while i<10 { () } + ^ +t7385.scala:7: error: illegal start of simple expression +} +^ +three errors found diff --git a/test/files/neg/t7385.scala b/test/files/neg/t7385.scala new file mode 100644 index 0000000000..a7f801098b --- /dev/null +++ b/test/files/neg/t7385.scala @@ -0,0 +1,7 @@ +object Bar { + do { println("bippy") } while i<10 +} + +object Foo { + while i<10 { () } +} diff --git a/test/files/neg/t7441.check b/test/files/neg/t7441.check new file mode 100644 index 0000000000..f259457197 --- /dev/null +++ b/test/files/neg/t7441.check @@ -0,0 +1,6 @@ +t7441.scala:4: error: type mismatch; + found : Int(1) + required: List[Any] + def test = apply(1) + ^ +one error found diff --git a/test/files/neg/t7441.scala b/test/files/neg/t7441.scala new file mode 100644 index 0000000000..dad7421e3f --- /dev/null +++ b/test/files/neg/t7441.scala @@ -0,0 +1,7 @@ +object Test { + object Bar { + def apply(xs: List[Any]): Int = 0 + def test = apply(1) + } + implicit def foo = 1 +} |