FIR checker: DSL_SCOPE_VIOLATION

This commit is contained in:
Tianyu Geng
2021-09-14 22:29:35 -07:00
committed by TeamCityServer
parent 7aaac2573c
commit 826ea122a9
53 changed files with 331 additions and 550 deletions
@@ -29,7 +29,7 @@ fun main() {
baz1 {
baz2 {
bar()
foo()
<!DSL_SCOPE_VIOLATION!>foo<!>()
}
}
@@ -29,7 +29,7 @@ fun main() {
baz1 {
baz2 {
bar()
foo()
<!DSL_SCOPE_VIOLATION!>foo<!>()
}
}
@@ -1,26 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun <T> foo(x: T.() -> Unit) {}
fun <E> bar(x: E.() -> Unit) {}
fun test() {
foo<@Ann A> {
a()
bar<@Ann B> {
a()
this@foo.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -1,28 +0,0 @@
@DslMarker
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS)
annotation class XMarker
@XMarker
class Foo
class Bar
@XMarker
typealias XBar = Bar
typealias XXBar = XBar
fun Foo.foo(body: Foo.() -> Unit) = body()
fun Foo.xbar(body: XBar.() -> Unit) = Bar().body()
fun Foo.xxbar(body: XXBar.() -> Unit) = Bar().body()
fun test() {
Foo().foo {
xbar {
foo {}
}
xxbar {
foo {}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
@DslMarker
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS)
annotation class XMarker
@@ -1,30 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
interface Common
interface C : Common
interface D : C
class A : C {
fun a() = 1
}
class B : D {
fun b() = 2
}
fun foo(x: A.() -> Unit) {}
fun bar(x: B.() -> Unit) {}
fun test() {
foo {
a()
bar {
a()
this@foo.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -1,23 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
class A {
fun a() = 1
}
@Ann
class B {
fun b() = 2
}
fun bar(x: B.() -> Unit) {}
fun A.test() {
bar {
a()
this@test.a()
b()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -1,22 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun bar(x: (@Ann B).() -> Unit) {}
fun @Ann A.test() {
bar {
a()
this@test.a()
b()
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -29,12 +29,12 @@ fun test() {
foo12 {
a()
bar1 {
a()
<!DSL_SCOPE_VIOLATION!>a<!>()
b()
}
bar2 {
a()
<!DSL_SCOPE_VIOLATION!>a<!>()
b()
}
}
@@ -43,7 +43,7 @@ fun test() {
b()
foo12 {
a()
b()
<!DSL_SCOPE_VIOLATION!>b<!>()
}
}
@@ -51,7 +51,7 @@ fun test() {
b()
foo12 {
a()
b()
<!DSL_SCOPE_VIOLATION!>b<!>()
}
}
@@ -64,7 +64,7 @@ fun test() {
}
bar2 {
a()
<!DSL_SCOPE_VIOLATION!>a<!>()
b()
}
}
@@ -85,7 +85,7 @@ fun test() {
foo2 {
bar1t(this) {
a()
b()
<!DSL_SCOPE_VIOLATION!>b<!>()
}
}
}
@@ -1,40 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun foo(x: (@Ann A).() -> Unit) {}
fun bar(x: (@Ann B).() -> Unit) {}
fun test() {
foo {
a()
foo l1@{
a()
bar l2@{
a()
this@l1.a()
b()
foo l3@{
a()
b()
this@l2.b()
bar {
a()
this@l3.a()
b()
}
}
}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -34,13 +34,13 @@ fun test() {
a1++
bar {
a + 1
a += a + 1
a++
<!DSL_SCOPE_VIOLATION!>a<!> + 1
<!DSL_SCOPE_VIOLATION, VARIABLE_EXPECTED!>a<!> += <!DSL_SCOPE_VIOLATION!>a<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a<!>++
a1 + 1
a1 += a1 + 1
a1++
<!DSL_SCOPE_VIOLATION!>a1<!> + 1
<!DSL_SCOPE_VIOLATION, VARIABLE_EXPECTED!>a1<!> += <!DSL_SCOPE_VIOLATION!>a1<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a1<!>++
this@foo.a + 1
this@foo.a += this@foo.a + 1
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -1,26 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun foo(x: (@Ann A).() -> Unit) {}
fun bar(x: (@Ann B).() -> Unit) {}
fun test() {
foo {
a()
bar {
a()
this@foo.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -1,27 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
class A {
fun a() = 1
}
@Ann
class B {
fun b() = 2
}
fun <T> foo(x: T.() -> Unit) {}
fun <E> bar(x: E.() -> Unit) {}
fun test() {
foo<A> {
a()
bar<B> {
a()
this@foo.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -48,8 +48,8 @@ fun test() {
D().x()
foo1 {
x()
y()
<!DSL_SCOPE_VIOLATION!>x<!>()
<!DSL_SCOPE_VIOLATION!>y<!>()
with(A()) {
x()
@@ -57,19 +57,19 @@ fun test() {
}
with(D()) {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
}
D().x()
D().<!DSL_SCOPE_VIOLATION!>x<!>()
}
foo2 {
x()
y()
<!DSL_SCOPE_VIOLATION!>y<!>()
}
foo3 {
x()
y()
<!DSL_SCOPE_VIOLATION!>x<!>()
<!DSL_SCOPE_VIOLATION!>y<!>()
}
}
}
@@ -79,7 +79,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -90,7 +90,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -101,7 +101,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -43,8 +43,8 @@ fun test() {
}
foo1 {
x()
y()
<!DSL_SCOPE_VIOLATION!>x<!>()
<!DSL_SCOPE_VIOLATION!>y<!>()
with(A()) {
x()
@@ -52,19 +52,19 @@ fun test() {
}
with(D()) {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
}
A().x()
}
foo2 {
x()
y()
<!DSL_SCOPE_VIOLATION!>y<!>()
}
foo3 {
x()
y()
<!DSL_SCOPE_VIOLATION!>x<!>()
<!DSL_SCOPE_VIOLATION!>y<!>()
}
}
}
@@ -74,7 +74,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -85,7 +85,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -96,7 +96,7 @@ fun test() {
foo {
baz {
bar {
x()
<!DSL_SCOPE_VIOLATION!>x<!>()
y()
}
}
@@ -1,102 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann1
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann2
class A {
fun D.extA() {}
}
class B {
fun D.extB() {}
}
class D
fun foo(x: (@Ann1 A).() -> Unit) {}
fun bar(x: (@Ann2 B).() -> Unit) {}
fun baz(x: (@Ann1 D).() -> Unit) {}
fun test() {
foo {
bar {
baz {
extA()
extB()
D().extA()
D().extB()
with(D()) {
extA()
extB()
}
}
}
}
foo {
baz {
extA()
D().extA()
bar {
extA()
extB()
D().extA()
D().extB()
with(D()) {
extA()
extB()
}
}
}
}
baz {
foo {
extA()
D().extA()
bar {
extA()
extB()
D().extA()
D().extB()
with(D()) {
extA()
extB()
}
}
}
}
baz {
bar {
extB()
D().extB()
foo {
extA()
extB()
D().extA()
D().extB()
with(D()) {
extA()
extB()
}
}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -1,104 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class L1
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class L2
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun foo1(x: (@L1 A).() -> Unit) {}
fun foo2(x: (@L2 A).() -> Unit) {}
fun bar1(x: (@L1 B).() -> Unit) {}
fun bar2(x: (@L2 B).() -> Unit) {}
fun test() {
foo1 {
a()
foo2 {
a()
bar1 {
a()
b()
bar2 {
a()
b()
}
}
bar2 {
a()
b()
}
}
bar1 {
a()
b()
bar2 {
a()
b()
}
}
bar2 {
a()
b()
}
}
foo2 {
a()
bar1 {
a()
b()
bar2 {
a()
b()
}
}
bar2 {
a()
b()
}
}
bar1 {
b()
bar2 {
b()
}
}
bar2 {
b()
}
foo1 {
bar1 {
a()
b()
foo2 {
a()
b()
bar2 {
a()
b()
}
}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
@@ -0,0 +1,28 @@
// FIR_IDENTICAL
@DslMarker
annotation class MyDsl
@MyDsl
class X
fun x(block: X.() -> Unit) {}
@MyDsl
class A
fun a(block: A.() -> Unit) {}
val useX1: X.() -> Unit = TODO()
typealias FunctionType = X.() -> Unit
val useX2: FunctionType = TODO()
fun test() {
x {
a {
<!DSL_SCOPE_VIOLATION!>useX1<!>()
<!DSL_SCOPE_VIOLATION!>useX2<!>()
}
}
}
@@ -0,0 +1,29 @@
package
public val useX1: X.() -> kotlin.Unit
public val useX2: FunctionType /* = X.() -> kotlin.Unit */
public fun a(/*0*/ block: A.() -> kotlin.Unit): kotlin.Unit
public fun test(): kotlin.Unit
public fun x(/*0*/ block: X.() -> kotlin.Unit): kotlin.Unit
@MyDsl public final class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@kotlin.DslMarker public final annotation class MyDsl : kotlin.Annotation {
public constructor MyDsl()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@MyDsl public final class X {
public constructor X()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias FunctionType = X.() -> kotlin.Unit
@@ -1,3 +1,4 @@
// !LANGUAGE: -DslMarkersSupport
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -19,7 +20,7 @@ fun test() {
foo {
a()
bar {
a()
<!DSL_SCOPE_VIOLATION!>a<!>()
this@foo.a()
b()
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !LANGUAGE: -DslMarkersSupport
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@@ -1,27 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
class A
fun A.a() = 1
@Ann
class B
fun B.b() = 2
fun foo(x: A.() -> Unit) {}
fun bar(x: B.() -> Unit) {}
fun test() {
foo {
a()
bar {
a()
this@foo.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -1,24 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
class A {
fun a() = 1
}
@Ann
class B {
fun b() = 2
}
fun test(a: A, b: B) {
with(a) l1@{
a()
with(b) {
a()
this@l1.a()
b()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@@ -1,30 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)
annotation class Ann
class A {
fun a() = 1
}
class B {
fun b() = 2
}
fun foo(x: (@Ann A).() -> Unit) {}
fun bar(x: (@Ann B).() -> Unit) {}
fun test() {
foo {
with(this) l1@{
a()
bar {
with(this) {
a()
this@l1.a()
b()
}
}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
@Target(AnnotationTarget.TYPE)