Intoduce and support DslMarker annotation
#KT-11551 In Progress
This commit is contained in:
@@ -644,6 +644,8 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, String> INAPPLICABLE_MODIFIER = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> DSL_SCOPE_VIOLATION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Labels
|
||||
|
||||
DiagnosticFactory0<KtSimpleNameExpression> LABEL_NAME_CLASH = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
+3
@@ -396,6 +396,9 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(INAPPLICABLE_MODIFIER, "''{0}'' modifier is inapplicable. The reason is that {1}", TO_STRING, STRING);
|
||||
|
||||
MAP.put(DSL_SCOPE_VIOLATION, "''{0}'' can't be called in this context by implicit receiver. " +
|
||||
"Use the explicit one if necessary", COMPACT);
|
||||
|
||||
MAP.put(RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY,
|
||||
"Returns are not allowed for functions with expression body. Use block body in '{...}'");
|
||||
MAP.put(NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, "A 'return' expression required in a function with a block body ('{...}')");
|
||||
|
||||
@@ -72,7 +72,7 @@ private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker(), SafeCallChecker(),
|
||||
DeprecatedCallChecker, CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(),
|
||||
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker,
|
||||
CoroutineSuspendCallChecker, BuilderFunctionsCallChecker
|
||||
CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker
|
||||
)
|
||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(DeprecatedClassifierUsageChecker(), ApiVersionClassifierUsageChecker)
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceivers
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf
|
||||
|
||||
object DslScopeViolationCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val callImplicitReceivers = resolvedCall.getImplicitReceivers()
|
||||
|
||||
for (callImplicitReceiver in callImplicitReceivers) {
|
||||
checkCallImplicitReceiver(callImplicitReceiver, resolvedCall, reportOn, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkCallImplicitReceiver(
|
||||
callImplicitReceiver: ReceiverValue,
|
||||
resolvedCall: ResolvedCall<*>,
|
||||
reportOn: PsiElement,
|
||||
context: CallCheckerContext
|
||||
) {
|
||||
val receiversUntilOneFromTheCall =
|
||||
context.scope.parentsWithSelf
|
||||
.mapNotNull { (it as? LexicalScope)?.implicitReceiver?.value }
|
||||
.takeWhile { it != callImplicitReceiver }.toList()
|
||||
|
||||
if (receiversUntilOneFromTheCall.isEmpty()) return
|
||||
|
||||
val callDslMarkers = callImplicitReceiver.extractDslMarkerFqNames()
|
||||
if (callDslMarkers.isEmpty()) return
|
||||
|
||||
val closestAnotherReceiverWithSameDslMarker =
|
||||
receiversUntilOneFromTheCall.firstOrNull { receiver -> receiver.extractDslMarkerFqNames().any(callDslMarkers::contains) }
|
||||
|
||||
if (closestAnotherReceiverWithSameDslMarker != null) {
|
||||
// TODO: report receivers configuration (what's one is used and what's one is the closest)
|
||||
context.trace.report(Errors.DSL_SCOPE_VIOLATION.on(reportOn, resolvedCall.resultingDescriptor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ReceiverValue.extractDslMarkerFqNames(): Set<FqName> {
|
||||
val result = mutableSetOf<FqName>()
|
||||
|
||||
result.addAll(type.annotations.extractDslMarkerFqNames())
|
||||
|
||||
type.constructor.declarationDescriptor?.getAllSuperClassifiers()?.asIterable()
|
||||
?.flatMapTo(result) { it.annotations.extractDslMarkerFqNames() }
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun Annotations.extractDslMarkerFqNames() =
|
||||
filter(AnnotationDescriptor::isDslMarker).map { it.type.constructor.declarationDescriptor!!.fqNameSafe }
|
||||
|
||||
private fun AnnotationDescriptor.isDslMarker(): Boolean {
|
||||
val classDescriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
|
||||
return classDescriptor.annotations.hasAnnotation(DSL_MARKER_FQ_NAME)
|
||||
}
|
||||
|
||||
private val DSL_MARKER_FQ_NAME = FqName("kotlin.DslMarker")
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
@@ -82,6 +83,21 @@ fun ResolvedCall<*>.getImplicitReceiverValue(): ImplicitReceiver? {
|
||||
} as? ImplicitReceiver
|
||||
}
|
||||
|
||||
fun ResolvedCall<*>.getImplicitReceivers(): Collection<ReceiverValue> {
|
||||
if (this is VariableAsFunctionResolvedCall) {
|
||||
val receivers = variableCall.getImplicitReceivers() + functionCall.getImplicitReceivers()
|
||||
assert(receivers.size <= 3) { "There are ${receivers.size} for $this call" }
|
||||
return receivers
|
||||
}
|
||||
|
||||
return when (explicitReceiverKind) {
|
||||
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> listOfNotNull(dispatchReceiver, extensionReceiver)
|
||||
ExplicitReceiverKind.DISPATCH_RECEIVER -> listOfNotNull(extensionReceiver)
|
||||
ExplicitReceiverKind.EXTENSION_RECEIVER -> listOfNotNull(dispatchReceiver)
|
||||
ExplicitReceiverKind.BOTH_RECEIVERS -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun ResolvedCall<*>.hasSafeNullableReceiver(context: CallResolutionContext<*>): Boolean {
|
||||
if (!call.isSafeCall()) return false
|
||||
val receiverValue = getExplicitReceiverValue()?.let { DataFlowValueFactory.createDataFlowValue(it, context) }
|
||||
|
||||
@@ -286,6 +286,10 @@ public final class DoubleArray {
|
||||
public final operator fun set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Double): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class DslMarker : kotlin.Annotation {
|
||||
/*primary*/ public constructor DslMarker()
|
||||
}
|
||||
|
||||
public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E> {
|
||||
/*primary*/ public constructor Enum</*0*/ E : kotlin.Enum<E>>(/*0*/ name: kotlin.String, /*1*/ ordinal: kotlin.Int)
|
||||
public final val name: kotlin.String
|
||||
|
||||
@@ -297,6 +297,10 @@ public final class DoubleArray : kotlin.Any, kotlin.Cloneable, java.io.Serializa
|
||||
public final operator fun set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Double): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class DslMarker : kotlin.Annotation {
|
||||
/*primary*/ public constructor DslMarker()
|
||||
}
|
||||
|
||||
public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E>, java.io.Serializable {
|
||||
/*primary*/ public constructor Enum</*0*/ E : kotlin.Enum<E>>(/*0*/ name: kotlin.String, /*1*/ ordinal: kotlin.Int)
|
||||
public final val name: kotlin.String
|
||||
|
||||
@@ -299,6 +299,10 @@ public final class DoubleArray : kotlin.Any, kotlin.Cloneable, java.io.Serializa
|
||||
public final operator fun set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Double): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class DslMarker : kotlin.Annotation {
|
||||
/*primary*/ public constructor DslMarker()
|
||||
}
|
||||
|
||||
public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E>, java.io.Serializable {
|
||||
/*primary*/ public constructor Enum</*0*/ E : kotlin.Enum<E>>(/*0*/ name: kotlin.String, /*1*/ ordinal: kotlin.Int)
|
||||
public final val name: kotlin.String
|
||||
|
||||
@@ -297,6 +297,10 @@ public final class DoubleArray : kotlin.Any, kotlin.Cloneable, java.io.Serializa
|
||||
public final operator fun set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Double): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.MustBeDocumented public final annotation class DslMarker : kotlin.Annotation {
|
||||
/*primary*/ public constructor DslMarker()
|
||||
}
|
||||
|
||||
public abstract class Enum</*0*/ E : kotlin.Enum<E>> : kotlin.Comparable<E>, java.io.Serializable {
|
||||
/*primary*/ public constructor Enum</*0*/ E : kotlin.Enum<E>>(/*0*/ name: kotlin.String, /*1*/ ordinal: kotlin.Int)
|
||||
public final val name: kotlin.String
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// !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> {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ E> bar(/*0*/ x: E.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T> foo(/*0*/ x: T.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A : C {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B : D {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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 interface C : Common {
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public interface Common {
|
||||
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 interface D : C {
|
||||
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
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@test.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun A.test(): kotlin.Unit
|
||||
|
||||
@Ann public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@test.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun @Ann A.test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// !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 foo12(x: @L1 @L2 A.() -> Unit) {}
|
||||
|
||||
fun bar1(x: @L1 B.() -> Unit) {}
|
||||
fun bar2(x: @L2 B.() -> Unit) {}
|
||||
|
||||
fun <T> bar1t(q: T, x: @L1 T.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo12 {
|
||||
a()
|
||||
bar1 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar1 {
|
||||
b()
|
||||
foo12 {
|
||||
a()
|
||||
<!DSL_SCOPE_VIOLATION!>b<!>()
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
b()
|
||||
foo12 {
|
||||
a()
|
||||
<!DSL_SCOPE_VIOLATION!>b<!>()
|
||||
}
|
||||
}
|
||||
|
||||
foo2 {
|
||||
bar1t(this) {
|
||||
a()
|
||||
bar1 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bar1 {
|
||||
b()
|
||||
foo2 {
|
||||
bar1t(this) {
|
||||
a()
|
||||
<!DSL_SCOPE_VIOLATION!>b<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
b()
|
||||
foo2 {
|
||||
bar1t(this) {
|
||||
a()
|
||||
<!DSL_SCOPE_VIOLATION!>b<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package
|
||||
|
||||
public fun bar1(/*0*/ x: @L1 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T> bar1t(/*0*/ q: T, /*1*/ x: @L1 T.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun bar2(/*0*/ x: @L2 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo1(/*0*/ x: @L1 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo12(/*0*/ x: @L1 @L2 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo2(/*0*/ x: @L2 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class L1 : kotlin.Annotation {
|
||||
public constructor L1()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class L2 : kotlin.Annotation {
|
||||
public constructor L2()
|
||||
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
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// !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@{
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@l1.a()
|
||||
b()
|
||||
|
||||
foo l3@{
|
||||
a()
|
||||
<!DSL_SCOPE_VIOLATION!>b<!>()
|
||||
this@l2.b()
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@l3.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
annotation class Ann
|
||||
|
||||
@Ann
|
||||
class A {
|
||||
var a = 1
|
||||
}
|
||||
|
||||
var A.a1: Int
|
||||
get() = 1
|
||||
set(value) {}
|
||||
|
||||
@Ann
|
||||
class B {
|
||||
var b = 2
|
||||
}
|
||||
|
||||
var B.b1: Int
|
||||
get() = 1
|
||||
set(value) {}
|
||||
|
||||
fun foo(x: A.() -> Unit) {}
|
||||
fun bar(x: B.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
a + 1
|
||||
a += a + 1
|
||||
a++
|
||||
|
||||
a1 + 1
|
||||
a1 += a1 + 1
|
||||
a1++
|
||||
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!> + 1
|
||||
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a<!> += <!DSL_SCOPE_VIOLATION!>a<!> + 1
|
||||
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a<!>++
|
||||
|
||||
<!DSL_SCOPE_VIOLATION!>a1<!> + 1
|
||||
<!DSL_SCOPE_VIOLATION!>a1<!> += <!DSL_SCOPE_VIOLATION!>a1<!> + 1
|
||||
<!DSL_SCOPE_VIOLATION!>a1<!>++
|
||||
|
||||
this@foo.a + 1
|
||||
this@foo.a += this@foo.a + 1
|
||||
this@foo.a++
|
||||
|
||||
this@foo.a1 + 1
|
||||
this@foo.a1 += this@foo.a1 + 1
|
||||
this@foo.a1++
|
||||
|
||||
b + 1
|
||||
b += b + 1
|
||||
b++
|
||||
|
||||
b1 + 1
|
||||
b1 += b1 + 1
|
||||
b1++
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public var A.a1: kotlin.Int
|
||||
public var B.b1: kotlin.Int
|
||||
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@Ann public final class A {
|
||||
public constructor A()
|
||||
public final var a: kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
public final var b: kotlin.Int
|
||||
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
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
annotation class Ann
|
||||
|
||||
@Ann
|
||||
class A {
|
||||
fun a() = 1
|
||||
}
|
||||
|
||||
@Ann
|
||||
class B {
|
||||
fun b() = 2
|
||||
}
|
||||
|
||||
fun foo(x: A.() -> Unit) {}
|
||||
fun bar(x: B.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
a()
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@Ann public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// !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> {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ E> bar(/*0*/ x: E.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T> foo(/*0*/ x: T.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@Ann public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann
|
||||
|
||||
class A {
|
||||
fun a() = 1
|
||||
}
|
||||
|
||||
class B {
|
||||
fun b() = 2
|
||||
}
|
||||
|
||||
fun <T> foo(x: @Ann T.() -> Unit) {}
|
||||
fun <E> bar(x: @Ann E.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo<A> {
|
||||
a()
|
||||
bar<B> {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ E> bar(/*0*/ x: @Ann E.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun </*0*/ T> foo(/*0*/ x: @Ann T.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann1
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann2
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann3
|
||||
|
||||
class A {
|
||||
operator fun B.invoke() {}
|
||||
|
||||
val B.y: D get() = D()
|
||||
}
|
||||
|
||||
class B
|
||||
|
||||
class C {
|
||||
operator fun D.invoke() {}
|
||||
|
||||
val D.x: B get() = B()
|
||||
}
|
||||
|
||||
class D
|
||||
|
||||
fun foo(x: @Ann1 A.() -> Unit) {}
|
||||
fun bar(x: @Ann2 B.() -> Unit) {}
|
||||
fun baz(x: @Ann3 C.() -> Unit) {}
|
||||
fun foo1(x: @Ann1 D.() -> Unit) {}
|
||||
fun foo2(x: @Ann2 D.() -> Unit) {}
|
||||
fun foo3(x: @Ann3 D.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
bar {
|
||||
baz {
|
||||
y()
|
||||
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, FUNCTION_EXPECTED!>x<!>()
|
||||
|
||||
with(D()) {
|
||||
x()
|
||||
}
|
||||
D().x()
|
||||
|
||||
foo1 {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
|
||||
with(A()) {
|
||||
x()
|
||||
y()
|
||||
}
|
||||
|
||||
with(D()) {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
}
|
||||
D().<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
}
|
||||
|
||||
foo2 {
|
||||
x()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
}
|
||||
|
||||
foo3 {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo1 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo2 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo3 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann2 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun baz(/*0*/ x: @Ann3 C.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann1 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo1(/*0*/ x: @Ann1 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo2(/*0*/ x: @Ann2 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo3(/*0*/ x: @Ann3 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val B.y: D
|
||||
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 final operator fun B.invoke(): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.DslMarker @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann1 : kotlin.Annotation {
|
||||
public constructor Ann1()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann2 : kotlin.Annotation {
|
||||
public constructor Ann2()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann3 : kotlin.Annotation {
|
||||
public constructor Ann3()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
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 final class C {
|
||||
public constructor C()
|
||||
public final val D.x: B
|
||||
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 final operator fun D.invoke(): kotlin.Unit
|
||||
}
|
||||
|
||||
public final class D {
|
||||
public constructor D()
|
||||
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
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann1
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann2
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann3
|
||||
|
||||
class A {
|
||||
val B.y: (C.() -> Unit) get() = null!!
|
||||
}
|
||||
|
||||
class B
|
||||
|
||||
class C {
|
||||
val D.x: (A.() -> Unit) get() = null!!
|
||||
}
|
||||
|
||||
class D
|
||||
|
||||
fun foo(x: @Ann1 A.() -> Unit) {}
|
||||
fun bar(x: @Ann2 B.() -> Unit) {}
|
||||
fun baz(x: @Ann3 C.() -> Unit) {}
|
||||
fun foo1(x: @Ann1 D.() -> Unit) {}
|
||||
fun foo2(x: @Ann2 D.() -> Unit) {}
|
||||
fun foo3(x: @Ann3 D.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
bar {
|
||||
baz {
|
||||
y()
|
||||
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, FUNCTION_EXPECTED!>x<!>()
|
||||
|
||||
with(D()) {
|
||||
x()
|
||||
}
|
||||
|
||||
foo1 {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
|
||||
with(A()) {
|
||||
x()
|
||||
y()
|
||||
}
|
||||
|
||||
with(D()) {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
}
|
||||
A().x()
|
||||
}
|
||||
|
||||
foo2 {
|
||||
x()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
}
|
||||
|
||||
foo3 {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>y<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo1 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo2 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo3 {
|
||||
foo {
|
||||
baz {
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>x<!>()
|
||||
y()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann2 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun baz(/*0*/ x: @Ann3 C.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann1 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo1(/*0*/ x: @Ann1 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo2(/*0*/ x: @Ann2 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo3(/*0*/ x: @Ann3 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val B.y: C.() -> kotlin.Unit
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann1 : kotlin.Annotation {
|
||||
public constructor Ann1()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann2 : kotlin.Annotation {
|
||||
public constructor Ann2()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann3 : kotlin.Annotation {
|
||||
public constructor Ann3()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
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 final class C {
|
||||
public constructor C()
|
||||
public final val D.x: A.() -> kotlin.Unit
|
||||
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 final class D {
|
||||
public constructor D()
|
||||
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
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
extB()
|
||||
|
||||
D().<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
D().extB()
|
||||
|
||||
with(D()) {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
extB()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo {
|
||||
baz {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
D().<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
extB()
|
||||
|
||||
D().<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
D().extB()
|
||||
|
||||
with(D()) {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
extB()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baz {
|
||||
foo {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
D().extA()
|
||||
|
||||
bar {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>extB<!>()
|
||||
|
||||
D().extA()
|
||||
D().extB()
|
||||
|
||||
with(D()) {
|
||||
extA()
|
||||
extB()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baz {
|
||||
bar {
|
||||
extB()
|
||||
|
||||
D().extB()
|
||||
|
||||
foo {
|
||||
<!DSL_SCOPE_VIOLATION!>extA<!>()
|
||||
<!DSL_SCOPE_VIOLATION!>extB<!>()
|
||||
|
||||
D().extA()
|
||||
D().extB()
|
||||
|
||||
with(D()) {
|
||||
extA()
|
||||
extB()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann2 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun baz(/*0*/ x: @Ann1 D.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann1 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
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
|
||||
public final fun D.extA(): kotlin.Unit
|
||||
}
|
||||
|
||||
@kotlin.DslMarker @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann1 : kotlin.Annotation {
|
||||
public constructor Ann1()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann2 : kotlin.Annotation {
|
||||
public constructor Ann2()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
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 final fun D.extB(): kotlin.Unit
|
||||
}
|
||||
|
||||
public final class D {
|
||||
public constructor D()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar1 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
foo2 {
|
||||
a()
|
||||
|
||||
bar1 {
|
||||
a()
|
||||
b()
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar1 {
|
||||
b()
|
||||
bar2 {
|
||||
b()
|
||||
}
|
||||
}
|
||||
|
||||
bar2 {
|
||||
b()
|
||||
}
|
||||
|
||||
foo1 {
|
||||
bar1 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
foo2 {
|
||||
a()
|
||||
b()
|
||||
|
||||
bar2 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package
|
||||
|
||||
public fun bar1(/*0*/ x: @L1 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun bar2(/*0*/ x: @L2 B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo1(/*0*/ x: @L1 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo2(/*0*/ x: @L2 A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class L1 : kotlin.Annotation {
|
||||
public constructor L1()
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class L2 : kotlin.Annotation {
|
||||
public constructor L2()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// !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 {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
public fun A.a(): kotlin.Int
|
||||
public fun B.b(): kotlin.Int
|
||||
|
||||
@Ann 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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// !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) {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@l1.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ a: A, /*1*/ b: B): kotlin.Unit
|
||||
|
||||
@Ann public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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
|
||||
}
|
||||
|
||||
@Ann public final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// !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) {
|
||||
<!DSL_SCOPE_VIOLATION!>a<!>()
|
||||
this@l1.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: @Ann B.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: @Ann A.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun a(): kotlin.Int
|
||||
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 @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
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 final class B {
|
||||
public constructor B()
|
||||
public final fun b(): kotlin.Int
|
||||
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
|
||||
}
|
||||
@@ -15843,6 +15843,123 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class DslMarker extends AbstractDiagnosticsTest {
|
||||
public void testAllFilesPresentInDslMarker() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/dslMarker"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedTypeArgument.kt")
|
||||
public void testAnnotatedTypeArgument() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/annotatedTypeArgument.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritedMarker.kt")
|
||||
public void testInheritedMarker() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/inheritedMarker.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideTopLevelExtension.kt")
|
||||
public void testInsideTopLevelExtension() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/insideTopLevelExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideTopLevelExtensionAnnotatedType.kt")
|
||||
public void testInsideTopLevelExtensionAnnotatedType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/insideTopLevelExtensionAnnotatedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("markersIntersection.kt")
|
||||
public void testMarkersIntersection() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/markersIntersection.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedWithSameReceiver.kt")
|
||||
public void testNestedWithSameReceiver() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/nestedWithSameReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("properties.kt")
|
||||
public void testProperties() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/properties.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleAnnotatedClasses.kt")
|
||||
public void testSimpleAnnotatedClasses() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/simpleAnnotatedClasses.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleAnnotatedTypes.kt")
|
||||
public void testSimpleAnnotatedTypes() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/simpleAnnotatedTypes.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("substitutedReceiverAnnotatedClasses.kt")
|
||||
public void testSubstitutedReceiverAnnotatedClasses() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/substitutedReceiverAnnotatedClasses.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("substitutedReceiverAnnotatedType.kt")
|
||||
public void testSubstitutedReceiverAnnotatedType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/substitutedReceiverAnnotatedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("threeImplicitReceivers.kt")
|
||||
public void testThreeImplicitReceivers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/threeImplicitReceivers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("threeImplicitReceivers2.kt")
|
||||
public void testThreeImplicitReceivers2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/threeImplicitReceivers2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("twoImplicitReceivers.kt")
|
||||
public void testTwoImplicitReceivers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/twoImplicitReceivers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("twoLanguages.kt")
|
||||
public void testTwoLanguages() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/twoLanguages.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("useOfExtensions.kt")
|
||||
public void testUseOfExtensions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/useOfExtensions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("usingWith.kt")
|
||||
public void testUsingWith() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/usingWith.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("usingWithThis.kt")
|
||||
public void testUsingWithThis() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/dslMarker/usingWithThis.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/resolve/invoke")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -107,3 +107,22 @@ public annotation class UnsafeVariance
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@MustBeDocumented
|
||||
public annotation class SinceKotlin(val version: String)
|
||||
|
||||
/**
|
||||
* When applied to annotation class X specifies that X defines a DSL language
|
||||
*
|
||||
* The general rule:
|
||||
* - an implicit receiver may *belong to a DSL @X* if marked with a corresponding DSL marker annotation
|
||||
* - two implicit receivers of the same DSL are not accessible in the same scope
|
||||
* - the closest one wins
|
||||
* - other available receivers are resolved as usual, but if the resulting resolved call binds to such a receiver, it's a compilation error
|
||||
*
|
||||
* Marking rules: an implicit receiver is considered marked with @Ann if
|
||||
* - its type is marked, or
|
||||
* - its type's classifier is marked
|
||||
* - or any of its superclasses/superinterfaces
|
||||
*/
|
||||
@Target(ANNOTATION_CLASS)
|
||||
@Retention(BINARY)
|
||||
@MustBeDocumented
|
||||
public annotation class DslMarker
|
||||
|
||||
@@ -26,4 +26,8 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
|
||||
@NotNull
|
||||
SimpleType getDefaultType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
ClassifierDescriptor getOriginal();
|
||||
}
|
||||
|
||||
@@ -336,3 +336,18 @@ val DeclarationDescriptor.isExtensionProperty: Boolean
|
||||
|
||||
fun ClassDescriptor.getAllSuperclassesWithoutAny() =
|
||||
generateSequence(getSuperClassNotAny(), ClassDescriptor::getSuperClassNotAny).toCollection(SmartList<ClassDescriptor>())
|
||||
|
||||
fun ClassifierDescriptor.getAllSuperClassifiers(): Sequence<ClassifierDescriptor> {
|
||||
val set = hashSetOf<ClassifierDescriptor>()
|
||||
|
||||
fun ClassifierDescriptor.doGetAllSuperClassesAndInterfaces(): Sequence<ClassifierDescriptor> =
|
||||
if (original in set) {
|
||||
emptySequence()
|
||||
}
|
||||
else {
|
||||
set += original
|
||||
sequenceOf(original) + typeConstructor.supertypes.asSequence().flatMap { it.constructor.declarationDescriptor?.doGetAllSuperClassesAndInterfaces() ?: sequenceOf() }
|
||||
}
|
||||
|
||||
return doGetAllSuperClassesAndInterfaces()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user