mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] IDEA-198057 Fix substitutor calculation on explicit type arguments
This commit is contained in:
+16
-7
@@ -35,16 +35,25 @@ class MethodResolveResult(
|
||||
}
|
||||
|
||||
private val applicabilitySubstitutor by lazy {
|
||||
GroovyInferenceSessionBuilder(ref, methodCandidate).build().inferSubst()
|
||||
if (ref.typeArguments.isNotEmpty()) {
|
||||
methodCandidate.siteSubstitutor
|
||||
}
|
||||
else {
|
||||
GroovyInferenceSessionBuilder(ref, methodCandidate).build().inferSubst()
|
||||
}
|
||||
}
|
||||
|
||||
private val fullSubstitutor by lazy {
|
||||
GroovyInferenceSessionBuilder(ref, methodCandidate)
|
||||
.addReturnConstraint()
|
||||
.resolveMode(false)
|
||||
.startFromTop(true)
|
||||
.build()
|
||||
.inferSubst(ref)
|
||||
if (ref.typeArguments.isNotEmpty()) {
|
||||
methodCandidate.siteSubstitutor
|
||||
}
|
||||
else {
|
||||
GroovyInferenceSessionBuilder(ref, methodCandidate)
|
||||
.addReturnConstraint()
|
||||
.resolveMode(false)
|
||||
.startFromTop(true)
|
||||
.build().inferSubst(ref)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCandidate(): MethodCandidate? = methodCandidate
|
||||
|
||||
+4
-6
@@ -103,10 +103,8 @@ fun buildTopLevelArgumentTypes(place: PsiElement): Array<PsiType?> {
|
||||
}
|
||||
|
||||
fun PsiSubstitutor.putAll(parameters: Array<out PsiTypeParameter>, arguments: Array<out PsiType>): PsiSubstitutor {
|
||||
return this
|
||||
// TODO deal with it
|
||||
// if (arguments.size != parameters.size) return this
|
||||
// return parameters.zip(arguments).fold(this) { acc, (param, arg) ->
|
||||
// acc.put(param, arg)
|
||||
// }
|
||||
if (arguments.size != parameters.size) return this
|
||||
return parameters.zip(arguments).fold(this) { acc, (param, arg) ->
|
||||
acc.put(param, arg)
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -524,6 +524,39 @@ class A {
|
||||
new A(foo: {
|
||||
prop
|
||||
})
|
||||
'''
|
||||
}
|
||||
|
||||
void 'test IDEA-198057-1'() {
|
||||
testHighlighting '''
|
||||
Optional<BigDecimal> foo(Optional<String> string) {
|
||||
string.flatMap {
|
||||
try {
|
||||
return Optional.of(new BigDecimal(it))
|
||||
} catch (Exception ignored) {
|
||||
return Optional.<BigDecimal> empty()
|
||||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
void 'test IDEA-198057-2'() {
|
||||
testHighlighting '''
|
||||
Optional<BigDecimal> foo(Optional<String> string) {
|
||||
string.flatMap {
|
||||
return Optional.<BigDecimal> empty()
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
void 'test IDEA-198057-3'() {
|
||||
testHighlighting '''
|
||||
void foo() {
|
||||
def o = Optional.<BigDecimal> empty()
|
||||
Optional<BigDecimal> d = o
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user