Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328188

Summary: assignment validation should allow assignment of literal null
Product: z_Archived Reporter: Henrik Lindberg <henrik.lindberg>
Component: b3Assignee: Project Inbox <b3.engine-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Henrik Lindberg CLA 2010-10-19 19:32:57 EDT
Integer a = null;
Currently results in a type mismatch error "can not convert Object to Integer".
The evaluator already copes with null assignment, so this is only a validation issue.

Unfotunately, it is not enough to only check for direct assignment of null - null values can also be part of type inference in other situations:

var a = if wtf() then null else 2;

where the common type of null and 2 (Integer) is computed.

By introducing a NullType and modifying TypeUtils.isAssignableFrom(Type, Type), and other methods dealing with type compatibility to synthetically allow assignment of null the issue should be solved.
Comment 1 Henrik Lindberg CLA 2010-10-19 21:25:00 EDT
A NullType was introduced. Tests added that checks that ["a", null, "b"] results in List<String> being inferred (and a few other tests).