Files
kotlin-fork/idea/testData/quickfix/createFromUsage/createFunction/call/kt10983.kt
T
Alexander Udalov 5a6237b357 Refactor resolution of double colon expression LHS
Try resolving the LHS only when it looks (PSI-wise) like it could represent a
type element. This, for example, allows "illegal selector" error to be reported
on weird expressions like '""?.""::class'.

Also remove expression text from the "illegal selector" diagnostic, it's not
needed and can screw up the error message if the text is too big
2016-07-22 11:05:19 +03:00

14 lines
886 B
Kotlin
Vendored

// "Create function" "false"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ERROR: The expression cannot be a selector (occur after a dot)
// ERROR: Type inference failed: inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T?<br>cannot be applied to<br>receiver: Collection<List<String>> arguments: ((List<String>) -> () -> Boolean)<br>
// ERROR: Type mismatch: inferred type is (List<String>) -> () -> Boolean but (List<String>) -> Boolean was expected
// ERROR: Unresolved reference: maximumSizeOfGroup
fun doSomethingStrangeWithCollection(collection: Collection<String>): Collection<String>? {
val groupsByLength = collection.groupBy { s -> { s.length } }
val maximumSizeOfGroup = groupsByLength.values.maxBy { it.size }.
return groupsByLength.values.firstOrNull { group -> {group.size == maximumSizeOfGroup} }
}