Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.2
-
None
Description
class CustomServletOutputStream extends OutputStream { OutputStream out void write(int i) { out.write(i) } void write(byte[] bytes) { out.write(bytes) } void write(byte[] bytes, int offset, int length) { out.write(bytes, offset, length) } void flush() { out.flush() } void close() { out.close() } } @groovy.transform.TypeChecked class Test { static void test() { def csos = new CustomServletOutputStream(out: new ByteArrayOutputStream()) } } Test.test()
This fails with:
[Static type checking] - Cannot assign value of type java.io.ByteArrayOutputStream to variable of type java.io.OutputStream
However, the following spanning two lines work:
def csos = new CustomServletOutputStream() csos.out = new ByteArrayOutputStream()