Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java @ 22123:329fe954f6f2
Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 02 Sep 2015 13:15:51 +0200 |
parents | 9c8c0937da41 |
children | dc83cc1f94f2 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java Wed Sep 02 10:54:29 2015 +0200 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java Wed Sep 02 13:15:51 2015 +0200 @@ -50,47 +50,48 @@ @SuppressWarnings("unchecked") @Override - public Object profile(Object value) { + public <T> T profile(T v) { + Object value = v; Object snapshot = this.cachedValue; if (snapshot != GENERIC) { if (snapshot instanceof Byte) { if (value instanceof Byte && (byte) snapshot == (byte) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Short) { if (value instanceof Short && (short) snapshot == (short) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Integer) { if (value instanceof Integer && (int) snapshot == (int) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Long) { if (value instanceof Long && (long) snapshot == (long) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Float) { if (value instanceof Float && exactCompare((float) snapshot, (float) value)) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Double) { if (value instanceof Double && exactCompare((double) snapshot, (double) value)) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Boolean) { if (value instanceof Boolean && (boolean) snapshot == (boolean) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot instanceof Character) { if (value instanceof Character && (char) snapshot == (char) value) { - return snapshot; + return (T) snapshot; } } else if (snapshot == value) { - return snapshot; + return (T) snapshot; } cacheMiss(value); } - return value; + return (T) value; } public byte profile(byte value) {