diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt
index f40c4dd97ce..420eab9221d 100644
--- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/TypeHints.kt
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
+import org.jetbrains.kotlin.load.java.sam.SamConstructorDescriptor
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset
@@ -82,9 +83,12 @@ private fun isUnclearType(type: KotlinType, element: KtCallableDeclaration): Boo
if (initializer is KtCallExpression) {
val bindingContext = element.analyze()
val resolvedCall = initializer.getResolvedCall(bindingContext)
- val constructorDescriptor = resolvedCall?.candidateDescriptor as? ConstructorDescriptor
- if (constructorDescriptor != null &&
- (constructorDescriptor.constructedClass.declaredTypeParameters.isEmpty() || initializer.typeArgumentList != null)) {
+ val resolvedDescriptor = resolvedCall?.candidateDescriptor
+ if (resolvedDescriptor is SamConstructorDescriptor) {
+ return false
+ }
+ if (resolvedDescriptor is ConstructorDescriptor &&
+ (resolvedDescriptor.constructedClass.declaredTypeParameters.isEmpty() || initializer.typeArgumentList != null)) {
return false
}
}
diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/InlayTypeHintsTest.kt b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/InlayTypeHintsTest.kt
index 42c9ac983eb..72e0b3bd4a3 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/InlayTypeHintsTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/InlayTypeHintsTest.kt
@@ -1,17 +1,6 @@
/*
- * 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.
+ * Copyright 2000-2018 JetBrains s.r.o. 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.idea.parameterInfo
@@ -116,4 +105,9 @@ class InlayTypeHintsTest : KotlinLightCodeInsightFixtureTestCase() {
return Triple("A", "B", "C")
}""")
}
+
+ fun testSAMConstructor() {
+ HintType.PROPERTY_HINT.option.set(true)
+ check("""val x = Runnable { }""")
+ }
}