mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-109296 Resulting type of Date subtraction is incorrectly inferred as Integer
This commit is contained in:
@@ -284,8 +284,8 @@ public class ResolveUtil {
|
||||
if (!psiClass.processDeclarations(processor, state, null, place)) return false;
|
||||
}
|
||||
}
|
||||
if (!processNonCodeMembers(type, nonCodeProcessor, place, state)) return false;
|
||||
if (!processCategoryMembers(place, nonCodeProcessor, state)) return false;
|
||||
if (!processNonCodeMembers(type, nonCodeProcessor, place, state)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+43
@@ -1593,4 +1593,47 @@ def foo() {
|
||||
}
|
||||
''', PsiMethod)
|
||||
}
|
||||
|
||||
void testPreferCategoryMethods() {
|
||||
def resolved = resolveByText('''
|
||||
class TimeCategory {
|
||||
public static TimeDuration minus(final Date lhs, final Date rhs) {
|
||||
return new TimeDuration()
|
||||
}
|
||||
}
|
||||
|
||||
class TimeDuration {}
|
||||
|
||||
void bug() {
|
||||
use (TimeCategory) {
|
||||
def duration = new Date() - new Date()
|
||||
print durat<caret>ion
|
||||
}
|
||||
}
|
||||
''', GrVariable)
|
||||
|
||||
assertEquals("TimeDuration", resolved.typeGroovy.canonicalText)
|
||||
}
|
||||
|
||||
void testPreferCategoryMethods2() {
|
||||
def resolved = resolveByText('''
|
||||
class TimeCategory {
|
||||
public static TimeDuration minus(final Date lhs, final Date rhs) {
|
||||
return new TimeDuration((int) days, hours, minutes, seconds, (int) milliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
class TimeDuration {}
|
||||
|
||||
void bug() {
|
||||
use (TimeCategory) {
|
||||
def duration = new Date().minus(new Date())
|
||||
print durat<caret>ion
|
||||
}
|
||||
}
|
||||
''', GrVariable)
|
||||
|
||||
assertEquals("TimeDuration", resolved.typeGroovy.canonicalText)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user