From 520e90acf1aa3f28d7542bfac9dac1dc01cfa59e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 30 Oct 2015 18:21:07 +0300 Subject: [PATCH] Minor: Use kotlin.lazy instead of kotlin.Delegates.lazy in KtPsiFactory.CallableBuilder --- .../frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt | 2 +- .../extractLazyMultipleExpressions.kt.after | 4 +--- .../introduceProperty/extractLazyToClass.kt.after | 4 +--- .../introduceProperty/extractLazyToFile.kt.after | 6 ++---- .../introduceProperty/extractLazyWithBlock.kt.after | 4 +--- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index 55b5df4fa3d..9cb319b0433 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -533,7 +533,7 @@ public class KtPsiFactory(private val project: Project) { public fun lazyBody(body: String): CallableBuilder { assert(target == Target.READ_ONLY_PROPERTY && (state == State.BODY || state == State.TYPE_CONSTRAINTS)) - sb.append(" by kotlin.properties.Delegates.lazy {\n").append(body).append("\n}") + sb.append(" by kotlin.lazy {\n").append(body).append("\n}") state = State.DONE return this diff --git a/idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt.after b/idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt.after index f63c4dd3099..663ad92ea9a 100644 --- a/idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt.after +++ b/idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt.after @@ -1,9 +1,7 @@ -import kotlin.properties.Delegates - // WITH_RUNTIME // EXTRACTION_TARGET: lazy property class A { - private val i: Int by Delegates.lazy { + private val i: Int by lazy { val a = 1 + 2 val b = a * 2 b diff --git a/idea/testData/refactoring/introduceProperty/extractLazyToClass.kt.after b/idea/testData/refactoring/introduceProperty/extractLazyToClass.kt.after index 5fc62363706..086f19a4b46 100644 --- a/idea/testData/refactoring/introduceProperty/extractLazyToClass.kt.after +++ b/idea/testData/refactoring/introduceProperty/extractLazyToClass.kt.after @@ -1,12 +1,10 @@ -import kotlin.properties.Delegates - // WITH_RUNTIME // EXTRACTION_TARGET: lazy property class A(val n: Int = 1) { val m: Int = 2 - private val i: Int by Delegates.lazy { + private val i: Int by lazy { m + n + 1 } diff --git a/idea/testData/refactoring/introduceProperty/extractLazyToFile.kt.after b/idea/testData/refactoring/introduceProperty/extractLazyToFile.kt.after index eee2047edc5..871502b2223 100644 --- a/idea/testData/refactoring/introduceProperty/extractLazyToFile.kt.after +++ b/idea/testData/refactoring/introduceProperty/extractLazyToFile.kt.after @@ -1,14 +1,12 @@ -import kotlin.properties.Delegates - // WITH_RUNTIME // EXTRACTION_TARGET: lazy property val n: Int = 1 -private val i: Int by Delegates.lazy { +private val i: Int by lazy { n + 1 } fun foo(): Int { return i -} +} \ No newline at end of file diff --git a/idea/testData/refactoring/introduceProperty/extractLazyWithBlock.kt.after b/idea/testData/refactoring/introduceProperty/extractLazyWithBlock.kt.after index 3b8fdc22f0c..391c95ec085 100644 --- a/idea/testData/refactoring/introduceProperty/extractLazyWithBlock.kt.after +++ b/idea/testData/refactoring/introduceProperty/extractLazyWithBlock.kt.after @@ -1,12 +1,10 @@ -import kotlin.properties.Delegates - // WITH_RUNTIME // EXTRACTION_TARGET: lazy property class A(val n: Int = 1) { val m: Int = 2 - private val i: Int by Delegates.lazy { + private val i: Int by lazy { println(n) m + n + 1 }