Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But then you are representing two distinct types as the same underlying type, String.

  MyType extends String;
  void foo(String s);
  foo(new MyType()); // is valid
Leading to the original problem. I don't want to represent MyType as a String because it's not.


It has to work that way or else you can't use the standard library. What you want to block is not:

    StringUtils.trim(String foo);
but

    myApp.doSomething(AnotherMyType amt);
The latter is saying "I need not any string but a specific kind of string".


No I want to block both. I don't want to give devs the option of creating a function doSomething(String) that happens to accept MyType. If I need to call trim then I'll do

  StringUtils.trim(MyType.toString());




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: