[SAM with receiver] Prepare module structure to K2 implementation
This commit is contained in:
committed by
teamcity
parent
e54c6eeafc
commit
ffc680f4a6
@@ -0,0 +1,22 @@
|
||||
description = "Kotlin SamWithReceiver Compiler Plugin (K1)"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":compiler:frontend.java"))
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
runtimeJar()
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.samWithReceiver
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.extensions.AnnotationBasedExtension
|
||||
import org.jetbrains.kotlin.resolve.sam.SamWithReceiverResolver
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
|
||||
class SamWithReceiverResolverExtension(
|
||||
private val annotations: List<String>
|
||||
) : SamWithReceiverResolver, AnnotationBasedExtension {
|
||||
override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?) = annotations
|
||||
|
||||
override fun shouldConvertFirstSamParameterToReceiver(function: FunctionDescriptor): Boolean {
|
||||
return (function.containingDeclaration as? ClassDescriptor)?.hasSpecialAnnotation(null) ?: false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user