Add KParameter.type, KType, KType.isMarkedNullable

This commit is contained in:
Alexander Udalov
2015-07-13 20:46:10 +03:00
parent b0db9c5b03
commit 6ab1c6bfb3
6 changed files with 100 additions and 0 deletions
@@ -34,4 +34,9 @@ public interface KParameter {
* compiled without the debug information, and others.
*/
public val name: String?
/**
* Type of this parameter.
*/
public val type: KType
}
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2015 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 kotlin.reflect
/**
* Represents a type. Type is usually either a class with optional type arguments,
* or a type parameter of some declaration, plus nullability.
*/
public interface KType {
/**
* `true` if this type was marked nullable in the source code.
*
* For Kotlin types, it means that `null` value is allowed to be represented by this type.
* In practice it means that the type was declared with a question mark at the end.
* For non-Kotlin types, it means the type or the symbol which was declared with this type
* is annotated with a runtime-retained nullability annotation such as [javax.annotation.Nullable].
*
* Note that even if [isMarkedNullable] is false, values of the type can still be `null`.
* This may happen if it is a type of the type parameter with a nullable upper bound:
*
* ```
* fun foo<T>(t: T) {
* // isMarkedNullable == false for t's type, but t can be null here
* }
* ```
*/
public val isMarkedNullable: Boolean
}