diff --git a/tests/neg/cycles.scala b/tests/neg/cycles.scala index b24a367c8377..aebe80535e24 100644 --- a/tests/neg/cycles.scala +++ b/tests/neg/cycles.scala @@ -29,6 +29,11 @@ class E { lazy val x: F#T = ??? } +object CyclicAnnotation { + class local(num: Int) extends annotation.StaticAnnotation + def f(x: Int @local(x ++ x)) = ??? // error: Cyclic reference involving val x +} + class T1 { type X = (U, U) // error: cycle type U = X & Int diff --git a/tests/neg/singletons.scala b/tests/neg/singletons.scala index 48d0b7390123..0c4c9013390a 100644 --- a/tests/neg/singletons.scala +++ b/tests/neg/singletons.scala @@ -8,4 +8,6 @@ object Test { val sym: 'sym = 'sym // error: an identifier expected, but quoted identifier found val foo: s"abc" = "abc" // error: not a legal singleton type + + def path(x: String, z: x.length.type) = ??? // error: Int is not a valid singleton type, since it is not an immutable path } diff --git a/tests/pos/i17242.scala b/tests/pos/i17242.scala new file mode 100644 index 000000000000..4b418bba2b3a --- /dev/null +++ b/tests/pos/i17242.scala @@ -0,0 +1,11 @@ + +class local(num: Int) extends annotation.StaticAnnotation +class local2(predicate: Boolean) extends annotation.StaticAnnotation + +def working1(x: Int)(z: Int @local(x + x)) = ??? +def working2(x: Int, z: Int @local(x)) = ??? +def working3(x: Int, z: Int & x.type ) = ??? + + +def failing1(x: Int, z: Int @local(x + x)) = ??? //error: undefined: x.+ # -1: TermRef(TermParamRef(x),+) at typer +def failing2(x: Int, z: Int @local2(x == x)) = ??? //error: undefined: x.== # -1: TermRef(TermParamRef(x),==) at typer