JS: refactor generation of property callable references

This commit is contained in:
Alexey Andreev
2017-01-16 15:15:57 +03:00
parent 66de78e82a
commit 1b0648a926
11 changed files with 138 additions and 221 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.js.naming
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.js.descriptorUtils.getJetTypeFqName
@@ -171,10 +172,9 @@ class NameSuggestion {
do {
parts += getSuggestedName(current)
var last = current
val last = current
current = current.containingDeclaration!!
if (last is ConstructorDescriptor && !last.isPrimary) {
last = current
parts[parts.lastIndex] = getSuggestedName(current) + "_init"
current = current.containingDeclaration!!
}
@@ -232,6 +232,19 @@ class NameSuggestion {
"kotlin.CharSequence.get" -> return NameAndStability("charAt", true)
"kotlin.Any.equals" -> return NameAndStability("equals", true)
}
val container = overriddenDescriptor.containingDeclaration
if (container is ClassDescriptor && ReflectionTypes.isNumberedKPropertyOrKMutablePropertyType(container.defaultType)) {
val name = overriddenDescriptor.name.asString()
when (name) {
"get",
"set" -> return NameAndStability(name, true)
}
}
}
else if (overriddenDescriptor is PropertyDescriptor) {
when (overriddenDescriptor.fqNameUnsafe.asString()) {
"kotlin.reflect.KCallable.name" -> return NameAndStability("callableName", true)
}
}
return mangleRegularNameIfNecessary(baseName, overriddenDescriptor)