inlined 'getType' method without 'DataFlowInfo' parameter
This commit is contained in:
@@ -220,7 +220,7 @@ public class BodyResolver {
|
|||||||
JetScope scope = scopeForConstructor == null
|
JetScope scope = scopeForConstructor == null
|
||||||
? descriptor.getScopeForMemberResolution()
|
? descriptor.getScopeForMemberResolution()
|
||||||
: scopeForConstructor;
|
: scopeForConstructor;
|
||||||
JetType type = typeInferrer.getType(scope, delegateExpression, NO_EXPECTED_TYPE, trace);
|
JetType type = typeInferrer.getType(scope, delegateExpression, NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, trace);
|
||||||
if (type != null && supertype != null && !JetTypeChecker.INSTANCE.isSubtypeOf(type, supertype)) {
|
if (type != null && supertype != null && !JetTypeChecker.INSTANCE.isSubtypeOf(type, supertype)) {
|
||||||
trace.report(TYPE_MISMATCH.on(delegateExpression, supertype, type));
|
trace.report(TYPE_MISMATCH.on(delegateExpression, supertype, type));
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ public class BodyResolver {
|
|||||||
assert primaryConstructor != null;
|
assert primaryConstructor != null;
|
||||||
final JetScope scopeForInitializers = classDescriptor.getScopeForInitializers();
|
final JetScope scopeForInitializers = classDescriptor.getScopeForInitializers();
|
||||||
for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
|
for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
|
||||||
expressionTypingServices.getType(scopeForInitializers, anonymousInitializer.getBody(), NO_EXPECTED_TYPE, trace);
|
expressionTypingServices.getType(scopeForInitializers, anonymousInitializer.getBody(), NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -572,7 +572,7 @@ public class BodyResolver {
|
|||||||
//JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(property, initializer); // TODO : flow JET-15
|
//JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(property, initializer); // TODO : flow JET-15
|
||||||
JetType expectedTypeForInitializer = property.getPropertyTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
JetType expectedTypeForInitializer = property.getPropertyTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||||
JetScope propertyDeclarationInnerScope = descriptorResolver.getPropertyDeclarationInnerScope(scope, propertyDescriptor.getTypeParameters(), ReceiverDescriptor.NO_RECEIVER, trace);
|
JetScope propertyDeclarationInnerScope = descriptorResolver.getPropertyDeclarationInnerScope(scope, propertyDescriptor.getTypeParameters(), ReceiverDescriptor.NO_RECEIVER, trace);
|
||||||
JetType type = expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, trace);
|
JetType type = expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, DataFlowInfo.EMPTY, trace);
|
||||||
//
|
//
|
||||||
// JetType expectedType = propertyDescriptor.getInType();
|
// JetType expectedType = propertyDescriptor.getInType();
|
||||||
// if (expectedType == null) {
|
// if (expectedType == null) {
|
||||||
@@ -628,7 +628,7 @@ public class BodyResolver {
|
|||||||
JetParameter jetParameter = valueParameters.get(i);
|
JetParameter jetParameter = valueParameters.get(i);
|
||||||
JetExpression defaultValue = jetParameter.getDefaultValue();
|
JetExpression defaultValue = jetParameter.getDefaultValue();
|
||||||
if (defaultValue != null) {
|
if (defaultValue != null) {
|
||||||
expressionTypingServices.getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), trace);
|
expressionTypingServices.getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), DataFlowInfo.EMPTY, trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -670,7 +670,7 @@ public class CallResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (JetExpression expression : context.call.getFunctionLiteralArguments()) {
|
for (JetExpression expression : context.call.getFunctionLiteralArguments()) {
|
||||||
expressionTypingServices.getType(context.scope, expression, NO_EXPECTED_TYPE, context.trace);
|
expressionTypingServices.getType(context.scope, expression, NO_EXPECTED_TYPE, context.dataFlowInfo, context.trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JetTypeProjection typeProjection : context.call.getTypeArguments()) {
|
for (JetTypeProjection typeProjection : context.call.getTypeArguments()) {
|
||||||
|
|||||||
+1
-6
@@ -106,7 +106,7 @@ public class ExpressionTypingServices {
|
|||||||
this.typeResolver = typeResolver;
|
this.typeResolver = typeResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetType safeGetType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, BindingTrace trace) {
|
public JetType safeGetType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
|
||||||
JetType type = getType(scope, expression, expectedType, dataFlowInfo, trace);
|
JetType type = getType(scope, expression, expectedType, dataFlowInfo, trace);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
return type;
|
return type;
|
||||||
@@ -114,11 +114,6 @@ public class ExpressionTypingServices {
|
|||||||
return ErrorUtils.createErrorType("Type for " + expression.getText());
|
return ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull BindingTrace trace) {
|
|
||||||
return getType(scope, expression, expectedType, DataFlowInfo.EMPTY, trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
|
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val i : Int? = 42
|
||||||
|
if (i != null) {
|
||||||
|
<!UNRESOLVED_REFERENCE!>doSmth<!> {
|
||||||
|
val <!UNUSED_VARIABLE!>x<!> = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -554,7 +554,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
private void assertType(String expression, JetType expectedType) {
|
private void assertType(String expression, JetType expectedType) {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
JetExpression jetExpression = JetPsiFactory.createExpression(project, expression);
|
JetExpression jetExpression = JetPsiFactory.createExpression(project, expression);
|
||||||
JetType type = expressionTypingServices.getType(scopeWithImports, jetExpression, TypeUtils.NO_EXPECTED_TYPE, JetTestUtils.DUMMY_TRACE);
|
JetType type = expressionTypingServices.getType(scopeWithImports, jetExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE);
|
||||||
assertTrue(type + " != " + expectedType, type.equals(expectedType));
|
assertTrue(type + " != " + expectedType, type.equals(expectedType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +584,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
private void assertType(JetScope scope, String expression, String expectedTypeStr) {
|
private void assertType(JetScope scope, String expression, String expectedTypeStr) {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
JetExpression jetExpression = JetPsiFactory.createExpression(project, expression);
|
JetExpression jetExpression = JetPsiFactory.createExpression(project, expression);
|
||||||
JetType type = expressionTypingServices.getType(addImports(scope), jetExpression, TypeUtils.NO_EXPECTED_TYPE, JetTestUtils.DUMMY_TRACE);
|
JetType type = expressionTypingServices.getType(addImports(scope), jetExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE);
|
||||||
JetType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
|
JetType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
|
||||||
assertEquals(expectedType, type);
|
assertEquals(expectedType, type);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user