Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Won't Fix
-
Affects Version/s: 1.5.4
-
Fix Version/s: 1.5.5
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
String x = "123".length()
works while it should throw a ClassCastException. I don't see why there should be default behavior in Groovy that converts objects to make an assignment work. If the object type is wrong the assignment shall - by default - always fail with ClassCastException.
It also does silent narrowing coercions (double to int for example). I don't think a strongly typed language should do this either.
int i = 2.5d should fail either at compile time or at run time
char c = 'd'
int i = c should work OK of course