forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable some features when LV=1.1 API=1.0.
Feature list: - bound callable references - local delegated properties - coroutines. #KT-16017 Fixed
- Loading branch information
Showing
43 changed files
with
232 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...frontend/src/org/jetbrains/kotlin/diagnostics/rendering/LanguageFeatureMessageRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2010-2017 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.diagnostics.rendering | ||
|
||
import org.jetbrains.kotlin.config.LanguageFeature | ||
import org.jetbrains.kotlin.config.LanguageVersionSettings | ||
|
||
class LanguageFeatureMessageRenderer @JvmOverloads constructor( | ||
private val type: Type, | ||
private val useHtml: Boolean = false | ||
): DiagnosticParameterRenderer<Pair<LanguageFeature, LanguageVersionSettings>> { | ||
|
||
enum class Type { | ||
UNSUPPORTED, | ||
WARNING, | ||
ERROR | ||
} | ||
|
||
override fun render(obj: Pair<LanguageFeature, LanguageVersionSettings>, renderingContext: RenderingContext): String { | ||
val (feature, settings) = obj | ||
val since = feature.sinceVersion | ||
|
||
val sb = StringBuilder() | ||
sb.append("The feature \"").append(feature.presentableName).append("\" is ") | ||
|
||
when (type) { | ||
Type.UNSUPPORTED -> | ||
when { | ||
since == null -> | ||
sb.append("experimental and should be enabled explicitly") | ||
since > settings.languageVersion -> | ||
sb.append("only available since language version ").append(since.versionString) | ||
feature.sinceApiVersion > settings.apiVersion -> | ||
sb.append("only available since API version ").append(feature.sinceApiVersion.versionString) | ||
else -> | ||
sb.append("disabled") | ||
} | ||
|
||
Type.WARNING -> sb.append("experimental") | ||
Type.ERROR -> sb.append("experimental and disabled") | ||
} | ||
|
||
val hintUrl = feature.hintUrl | ||
if (hintUrl != null) { | ||
if (useHtml) { | ||
sb.append(" (").append("see more <a href=\"").append(hintUrl).append("\">here</a>)") | ||
} | ||
else { | ||
sb.append(" (see: ").append(hintUrl).append(")") | ||
} | ||
} | ||
|
||
return sb.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
compiler/testData/cli/jvm/apiVersion.kt:2:5: error: the feature "bound callable references" is only available since API version 1.1 | ||
""::class.isInstance(42) | ||
^ | ||
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: isInstance | ||
""::class.isInstance(42) | ||
^ | ||
COMPILATION_ERROR | ||
COMPILATION_ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$TESTDATA_DIR$/apiVersion1.0.kt | ||
-d | ||
$TEMP_DIR$ | ||
-language-version | ||
1.1 | ||
-api-version | ||
1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
typealias Foo = Int | ||
|
||
sealed class A | ||
data class B(val foo: Int): A() | ||
|
||
inline val f get() = "" | ||
|
||
suspend fun test() { | ||
""::class | ||
""::toString | ||
|
||
Foo::class | ||
Foo::toString | ||
|
||
val b by lazy { "" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
compiler/testData/cli/jvm/apiVersion1.0.kt:8:1: error: the feature "coroutines" is only available since API version 1.1 (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines) | ||
suspend fun test() { | ||
^ | ||
compiler/testData/cli/jvm/apiVersion1.0.kt:9:5: error: the feature "bound callable references" is only available since API version 1.1 | ||
""::class | ||
^ | ||
compiler/testData/cli/jvm/apiVersion1.0.kt:10:5: error: the feature "bound callable references" is only available since API version 1.1 | ||
""::toString | ||
^ | ||
compiler/testData/cli/jvm/apiVersion1.0.kt:15:11: error: the feature "local delegated properties" is only available since API version 1.1 | ||
val b by lazy { "" } | ||
^ | ||
COMPILATION_ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
compiler/testData/cli/jvm/apiVersion.kt:2:5: error: the feature "bound callable references" is only available since API version 1.1 | ||
""::class.isInstance(42) | ||
^ | ||
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: isInstance | ||
""::class.isInstance(42) | ||
^ | ||
COMPILATION_ERROR | ||
COMPILATION_ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
suspend fun simple() = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$TESTDATA_DIR$/coroutines.kt | ||
-d | ||
$TEMP_DIR$ | ||
-Xcoroutines=enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$TESTDATA_DIR$/coroutines.kt | ||
-d | ||
$TEMP_DIR$ | ||
-Xcoroutines=error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
compiler/testData/cli/jvm/coroutines.kt:1:1: error: the feature "coroutines" is experimental and disabled (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines) | ||
suspend fun simple() = 5 | ||
^ | ||
COMPILATION_ERROR |
Oops, something went wrong.